Segmentation violation

Anything that doesn't fit elsewhere.
Post Reply
Wosen

Segmentation violation

Post by Wosen »

Hello!

I am running a multi compartment model with a stochastic input current and eventually getting the following segmentation violation:
exp(1689.77) out of range, returning exp(700)
A math function was called that returned an out of range value
0 errno=34 at t=24457.6 during call to mechanism hh_Cs_scaled
/usr/nld/nrn-6.0/x86_64/bin/nrniv: errno set during calculation of states
in mylibs/runme_new.hoc near line 79
}
^
/usr/nld/nrn-6.0/x86_64/bin/nrniv: Segmentation violation
in mylibs/runme_new.hoc near line 79
^
fadvance()
advance()
step()
continuerun(41100)
and others
I tried the code with Neuron 6 and Neuron 7.1 on two different linux computers (Suse and Debian). Didn't help.
The error is also not really reproducible in the sense that neuron crashes at different running times. Could this be due to the stochasticity of the input current?
According to the neuron output, the math function exp() was called with an argument that is to large. However, this should be only the case if the voltage gets unreasonably large. I tried to monitor this by setting a voltage threshold dependent output, telling when the voltage exceeds +70mV (using NetCon). This value would be far below the problematic value, however, even this threshold is not exceeded. This leads me to two conclusions:
1. I didn't check all compartments with this methods but only at soma(0.5) where the stochastic current is injected. Might it be that a voltage overshoot happens in another compartment? But I wouldn't know why this should be the case.
2. Some memory overwriting happens that leads to exp(1689.77).

The following is the part of the mechanism where exp() reaches the unreasonable high value. exp() is called one time in the procedure explicitly and many times via the function vtrap implicitly.
PROCEDURE rates(v(mV)) { :Computes rate and other constants at current v.
:Call once from HOC to initialize inf at resting v.
LOCAL alpha, beta, sum
TABLE minf, mtau, hinf, htau, ninf, ntau DEPEND celsius FROM -100 TO 100 WITH 200

UNITSOFF
q10 = 3^((celsius - 23)/10)
:"m" sodium activation system
alpha = -.182 * vtrap(-(v+40),6)
beta = -.124 * vtrap((v+40),6)
sum = alpha + beta
mtau = 0.2/(q10*sum)
minf = alpha/sum
:"h" sodium inactivation system
alpha = -0.015 * vtrap((v+66),6)
beta = -0.015 * vtrap(-(v+66),6)
sum = alpha + beta
htau = 1/(q10*sum)
hinf = alpha/sum
:"n" potassium activation system
alpha = .01*vtrap(-(v+55),10)
beta = .125*exp(-(v+65)/80)
sum = alpha + beta
ntau = 1/(q10*sum)
ninf = alpha/sum
}

FUNCTION vtrap(x,y) { :Traps for 0 in denominator of rate eqns.
if (fabs(x/y) < 1e-6) {
vtrap = -y*(1 - x/y/2)
}else{
vtrap = x/(1 - exp(x/y))
}
}

UNITSON
Does anybody have an idea about what I could further test and probably isolate the error? I would be very, very thankful!

David
ted
Site Admin
Posts: 6395
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Segmentation violation

Post by ted »

The code excerpts in your message provide no clue to the sources of the problems you reported.
The error is also not really reproducible in the sense that neuron crashes at different running times.
This symptom suggests two possibilities: inadequate initialization of one or more mechanisms defined by mod files, so that, even in the absence of a stocastic signal source, a series of simulations generates different results; inadequate initialization of random number generators, i.e. user-written code does not seed the random number generator(s). These are bugs that should be fixed because they destroy reproducibility and interfere with debugging, but they will not cause numeric overflow.

One possible cause of numeric overflow would be an NMODL-defined mechanism that calls a random number generator from a BREAKPOINT block. For an example of this, and how to fix it, see
Adding white nose to current injection
viewtopic.php?f=16&t=2055
Note that the revised NMODL code contains PROCEDURE seed, which you should call from hoc to set the seed for the random number generator (if you like reproducibility).

The easiest random distributions to use in mod files are:
random() Actually this is scop_random(). It returns a random sample from the uniform distribution over [0,1].
exprand(mean) Returns a random sample from the exponential distribution exp(-mean*x)
normrand(mean, std_dev) Returns a random sample from the normal distribution with specified mean and standard deviation.
poisrand(mean) Returns a random sample (integer) from the Poisson distribution with specified mean

All of these are derived from the same 32 bit internal generator called scop_random(). By default this is a fairly low quality but fast generator which has its seed set by a call to set_seed(integer). The default seed is 1.

You can switch to a much higher quality generator by calling the hoc function use_mcell_ran4(1). See
http://www.neuron.yale.edu/neuron/stati ... mcell_ran4
Use of mcell_ran4 is strongly recommended since it is very high quality 64 bit generator, gives the same results on all machines, and allows the generation of many different
but reproducible random streams.
Wosen

Re: Segmentation violation

Post by Wosen »

Dear Ted,

thank you very much for your reply! Now everything is set up so that runs are reproducible. Unfortunately, the error persists even if I put the random number generation in the BEFORE BREAKPOINT block, as suggested by the thread you posted:

Code: Select all

BEFORE BREAKPOINT {
    if (tau > 0)
    {
        x = x +(1. - exp(-dt/tau)) * (mean - x) + sqrt(1. - exp(-2.*dt/tau)) * sig * normrand(0,1)
    } else {
        x = mean + sig * normrand(0,1)
    }

    i_tmp = x + amp * sin(constant*freq*t + phase)
}

BREAKPOINT {
    i = i_tmp
}
The error output is this:

Code: Select all

49 of 60 simulations completed.
Entering WriteSpikeTrain routine.
exp(27589.5) out of range, returning exp(700)
A math function was called that returned an out of range value
0 errno=34 at t=552.25 during call to mechanism hh_Cs_scaled
/usr/nld/nrn-6.0/x86_64/bin/nrniv: errno set during calculation of states
 in mylibs/runme.hoc near line 53
 }
  ^
/usr/nld/nrn-6.0/x86_64/bin/nrniv: Segmentation violation
 in mylibs/runme.hoc near line 53


 ^
        fadvance()
      advance()
    step()
  continuerun(10100)
and others
But curiously with another seed NEURON gives the following warning (out of range value, the same es above) this time without crashing:

Code: Select all

17 of 60 simulations completed.
Entering WriteSpikeTrain routine.
exp(1031.65) out of range, returning exp(700)
exp(1031.38) out of range, returning exp(700)
A math function was called that returned an out of range value
0 errno=34 at t=3862.97 during call to mechanism hh_Cs_scaled
/usr/nld/nrn-6.0/x86_64/bin/nrniv: errno set during calculation of states
 in mylibs/runme.hoc near line 53
 }
  ^
WriteSpikeTrain done.
18 of 60 simulations completed.
So now I'm confronted with the question as to whether the segmentation violation is indeed caused by an out of range value. So the main question by now would be: can I exclude that, because NEURON is taking care of it by returning exp(700) instead of exp(some large number)?

Thank you very much for this information!
David
ted
Site Admin
Posts: 6395
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Segmentation violation

Post by ted »

In order to give any further advice, I would have to be able to reproduce the problem myself. This means sending me the source code so I can run the simulation myself. If you decide to do this, zip up the necessary files and send them, with whatever instructions are necessary to use your code, to
ted dot carnevale at yale dot edu
But first please read this item:
What to include in a zip file, and what to leave out
viewtopic.php?f=28&t=560
Post Reply