weird segmentation violation

The basics of how to develop, test, and use models.
Post Reply
eacheon
Posts: 97
Joined: Wed Jan 18, 2006 2:20 pm

weird segmentation violation

Post by eacheon »

Code: Select all

:~/tmp/neuronoo$ nrngui test.hoc
NEURON -- VERSION 6.2.1006 (2048) 2008-04-07 (2051M)
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html

nrniv: unable to open font "*helvetica-medium-r-normal*--14*", using "fixed"
loading membrane mechanisms from mod/i686/.libs/libnrnmech.so
Additional mechanisms from files
 ampa.mod gabaa.mod NMDA_MgNN.mod pxrglu.mod terminal.mod
        1 
        1 
        1 
add_release(pxrglu[0] )
        0 
add_mech(AMPA[0] )
        0 
add_mech(GABAa[0] )
        0 
add_mech_concent(NMDA_MgNN[0] )
/lhome/nrnsvn/nrn/i686/bin/nrniv: Segmentation violation
 in test.hoc near line 13
 s.add_mech_concent(new NMDA_MgNN(.5), "glu")
                                             ^
        Segmentation fault
But add a "-" in the end of the line survived:

Code: Select all

~/tmp/neuronoo$ nrngui test.hoc -
NEURON -- VERSION 6.2.1006 (2048) 2008-04-07 (2051M)
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html

nrniv: unable to open font "*helvetica-medium-r-normal*--14*", using "fixed"
loading membrane mechanisms from mod/i686/.libs/libnrnmech.so
Additional mechanisms from files
 ampa.mod gabaa.mod NMDA_MgNN.mod pxrglu.mod terminal.mod
        1 
        1 
        1 
add_release(pxrglu[0] )
        0 
add_mech(AMPA[0] )
        0 
add_mech(GABAa[0] )
        0 
add_mech_concent(NMDA_MgNN[0] )
pxrglu[0] 0 
        0 
terminal[0] -> AMPA[0] weight=5.2404722 max_g=1.2 
        0 
terminal[0] -> NMDA_MgNN[0] weight=3.2386566 max_g=0.1 
        0 
terminal[0] -> GABAa[0] delay=1 
        0 
oc>
With the same source code (test.hoc and the files it loads are the same) in 3 different working copies, I got:
1. one as the above where add "-" in the command line makes it run fine;
2. one runs fine no matter whether or not "-" is added;
3. one always gives a different "Segmentation violation error" compared to the one shown in the first example whether "-" is appended or not, but this time it complains about an list iterator in my code (which is copied from http://www.neuron.yale.edu/neuron/stati ... netconlist):

Code: Select all

~/nrn/neuronoo$ nrngui test.hoc
NEURON -- VERSION 6.2.1006 (2048) 2008-04-07 (2051M)
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html

nrniv: unable to open font "*helvetica-medium-r-normal*--14*", using "fixed"
loading membrane mechanisms from mod/i686/.libs/libnrnmech.so
Additional mechanisms from files
 ampa2exp.mod ampa.mod gabaa.mod hh3.mod NMDA_MgNN.mod pxrglu.mod terminal.mod
        1 
        1 
        1 
add_release(pxrglu[0] )
        0 
add_mech(AMPA[0] )
        0 
add_mech(GABAa[0] )
        0 
add_mech_concent(NMDA_MgNN[0] )
/home/nrnsvn/nrn/i686/bin/nrniv: Segmentation violation
 in test.hoc near line 13
 s.add_mech_concent(new NMDA_MgNN(.5), "glu")
                                             ^
        Synapse[0].ltr(pxrglu[0], List[12])
      Synapse[0].add_mech_concent(..., "glu")
initcode failed with 1 left
How can I debug this?
ted
Site Admin
Posts: 6302
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: weird segmentation violation

Post by ted »

With the same source code (test.hoc and the files it loads are the same) in 3 different working copies
There must be some difference between the three cases--perhaps where the files are located?
How can I debug this?
Localization is the first task. Usually this means answering the question "where in my code does the problem lie?" but occasionally the bug is in NEURON itself. The most recent revision of 6.2 is dated August 28; you might try updating to that, if you are reasonably sure of the correctness of your own code (do all the parts, tested on toy problems, work ok?).
eacheon
Posts: 97
Joined: Wed Jan 18, 2006 2:20 pm

Re: weird segmentation violation

Post by eacheon »

ted wrote: Localization is the first task. Usually this means answering the question "where in my code does the problem lie?" but occasionally the bug is in NEURON itself. The most recent revision of 6.2 is dated August 28; you might try updating to that, if you are reasonably sure of the correctness of your own code (do all the parts, tested on toy problems, work ok?).
Thanks, I will try the official 6.2 maybe this weekend and report back. But just FYI, the newest version in git repository complains similarly:

Code: Select all

~/tmp/neuronoo-fresh$ nrngui test-git-head.hoc 
NEURON -- VERSION 7.0 (264+:5f335f53c245+) 2008-12-03
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html
...
nrniv: unable to open font "*helvetica-medium-r-normal*--14*", using "fixed"
loading membrane mechanisms from mod/i486/.libs/libnrnmech.so
Additional mechanisms from files
 ampa.mod gabaa.mod NMDA_MgNN.mod pxrglu.mod terminal.mod

/usr/bin/nrniv: Segmentation violation
 in test-git-head.hoc near line 13
 s.add_mech_concent(new NMDA_MgNN(.5), "glu")
                                             ^
        Synapse[0].add_mech_concent(..., "glu")
initcode failed with 1 left

I quickly find every version of NEURON I got have started to complain as the above. Currently only NEURON imported into python works for this test.hoc file (another version in svn though, I will test nrngui in r2174 and report back):

Code: Select all

In [1]: import neuron; h=neuron.h
NEURON -- VERSION 6.2.1041 (2174) 2008-07-21
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html


In [2]: h.load_file("test.hoc")
loading membrane mechanisms from mod/i686/.libs/libnrnmech.so
Additional mechanisms from files
 ampa.mod gabaa.mod NMDA_MgNN.mod pxrglu.mod terminal.mod
        1 
        1 
        1 
add_release(pxrglu[0] )
        0 
add_mech(AMPA[0] )
        0 
add_mech(GABAa[0] )
        0 
add_mech_concent(NMDA_MgNN[0] )
pxrglu[0] 0 
        0 
terminal[0] -> AMPA[0] weight=5.2404722 max_g=1.2 
        0 
terminal[0] -> NMDA_MgNN[0] weight=3.2386566 max_g=0.1 
        0 
terminal[0] -> GABAa[0] delay=1 
        0 

Out[2]: 1.0

In [3]: pwd

Out[3]: '/home/tmp/neuronoo-fresh'

hines
Site Admin
Posts: 1692
Joined: Wed May 18, 2005 3:32 pm

Strategy for debugging segmentation violations

Post by hines »

How can I debug this?
I debug segmentation violations using gdb and looking at the stack trace.
If the stack trace file line numbers seem incomplete or gdb refuses to
print local variables, I use a non-optimized version of neuron with
the configure options 'CXXFLAGS=-g' 'CFLAGS=-g'.
Memory errors can be quite indirect and if the above does not immediately
diagnose the problem then I use valgrind and avoid huge numbers of
false python memory errors by using yet another build that links to
a special build of python configured with '--without-pymalloc'.

I'll look into the problem if you send me a zip file containing all the
hoc,ses,mod files needed to exhibit it. Send to michael.hines@yale.edu.
eacheon
Posts: 97
Joined: Wed Jan 18, 2006 2:20 pm

Re: Strategy for debugging segmentation violations

Post by eacheon »

Thanks for the tips, Dr. Hines.

I tried a bit with gdb with "run /path/to/nrngui.hoc test.hoc -" and got the following traceback that points me to hoc_object_asgn () from /usr/lib/libnrnoc.so.0. Maybe I need to recompile NEURON with debug symbols. At the same time I find "run test.hoc -" finishes successfully, which means "nrniv test.hoc -" actually runs fine. Let me see what I can find with NEURON compiled with debug flag, and then maybe in the weekend I can send you the minimal code that demonstrate this problem. Thanks for the offer!

Code: Select all

...
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb7428a80 (LWP 16659)]
(no debugging symbols found)
NEURON -- VERSION 7.0 (264+:5f335f53c245+) 2008-12-03
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
nrniv: unable to open font "*helvetica-medium-r-normal*--14*", using "fixed"
loading membrane mechanisms from mod/i486/.libs/libnrnmech.so
Additional mechanisms from files
 ampa.mod gabaa.mod NMDA_MgNN.mod pxrglu.mod terminal.mod
        1 
        1 
        1 
add_release(pxrglu[0] )
        0 
add_mech(AMPA[0] )
        0 
add_mech(GABAa[0] )
        0 
add_mech_concent(NMDA_MgNN[0] )

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7428a80 (LWP 16659)]
0xb7ed10ca in hoc_object_asgn () from /usr/lib/libnrnoc.so.0
(gdb) bt
#0  0xb7ed10ca in hoc_object_asgn () from /usr/lib/libnrnoc.so.0
#1  0x00000001 in ?? ()
#2  0x08b31f20 in ?? ()
#3  0x00000000 in ?? ()
hines wrote: I debug segmentation violations using gdb and looking at the stack trace.
If the stack trace file line numbers seem incomplete or gdb refuses to
print local variables, I use a non-optimized version of neuron with
the configure options 'CXXFLAGS=-g' 'CFLAGS=-g'.
Memory errors can be quite indirect and if the above does not immediately
diagnose the problem then I use valgrind and avoid huge numbers of
false python memory errors by using yet another build that links to
a special build of python configured with '--without-pymalloc'.

I'll look into the problem if you send me a zip file containing all the
hoc,ses,mod files needed to exhibit it. Send to michael.hines@yale.edu.
Post Reply