Segmentation violation with gcc -finline-functions

Post Reply
shhong
Posts: 9
Joined: Wed Jan 07, 2009 6:52 am

Segmentation violation with gcc -finline-functions

Post by shhong »

I am getting segmentation violation both in version 7alpha and 6.2 when NEURON is compiled with gcc and -finline-functions option, which is a part of -O3 optimization. A similar thing happens also in our linux cluster, which generates more outputs as:

Code: Select all

$ nrngui
NEURON -- Release 6.2.3 (2203) 2008-08-28
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html

51eb58 2ae0d10f5610 objectvar
glist
51eb68 2ae0d10ee3d0 VARPUSH
i
51eb78 2ae0d10f14d0 EVAL
51eb80 2ae0d10f64d0 objectcomponent()
remove
/users/shhong/local/NEURON-6.2/nrn/x86_64/bin/nrniv: Segmentation violation
 in wingroup.hoc near line 166
 		glist.remove(i)
                 ^
        xopen("wingroup.hoc")
      execute1("{xopen("wingroup.hoc")}")
    load_file("wingroup.hoc")
  xopen("stdgui.hoc")
and others
51e7e0 2ae0d10f0ef0 push_string
constant or string pointer
51e7f0 2ae0d10f2100 CALL
execute1
relative 1
51e808 2ae0d10ee3d0 VARPUSH
hoc_ac_
51e818 2ae0d10f0940 ASSIGN
STOP
51e828 2ae0d10f18a0 POP
STOP
51e838 2ae0d10f0ef0 push_string
constant or string pointer
51e848 2ae0d10f2100 CALL
xopen
relative 1
51e860 2ae0d10f18a0 POP
STOP
51e870 2ae0d10f7ad0 objvardecl
cvode
/users/shhong/local/NEURON-6.2/nrn/x86_64/bin/nrniv: Segmentation violation
 in stdrun.hoc near line 1
 objref cvode
             ^
        xopen("stdrun.hoc")
      execute1("{xopen("stdrun.hoc")}")
    load_file("stdrun.hoc")
  xopen("stdgui.hoc")
and others
51e7e0 2ae0d10f0ef0 push_string
constant or string pointer
51e7f0 2ae0d10f2100 CALL
execute1
relative 1
51e808 2ae0d10ee3d0 VARPUSH
hoc_ac_
51e818 2ae0d10f0940 ASSIGN
STOP
51e828 2ae0d10f18a0 POP
STOP
51e838 2ae0d10f0ef0 push_string
constant or string pointer
51e848 2ae0d10f2100 CALL
xopen
relative 1
51e860 2ae0d10f18a0 POP
STOP
51e870 2ae0d10f7ad0 objvardecl
mt
/users/shhong/local/NEURON-6.2/nrn/x86_64/bin/nrniv: Segmentation violation
 in inserter.hoc near line 21
 objectvar mt, sec, ms[1], sf, v1, this
             ^
        xopen("inserter.hoc")
      execute1("{xopen("inserter.hoc")}")
    load_file("inserter.hoc")
  xopen("stdgui.hoc")
and others
51e7e0 2ae0d10f0ef0 push_string
constant or string pointer
51e7f0 2ae0d10f2100 CALL
execute1
relative 1
51e808 2ae0d10ee3d0 VARPUSH
hoc_ac_
51e818 2ae0d10f0940 ASSIGN
STOP
51e828 2ae0d10f18a0 POP
STOP
51e838 2ae0d10f0ef0 push_string
constant or string pointer
51e848 2ae0d10f2100 CALL
xopen
relative 1
51e860 2ae0d10f18a0 POP
STOP
51e870 2ae0d10f7ad0 objvardecl
pp
/users/shhong/local/NEURON-6.2/nrn/x86_64/bin/nrniv: Segmentation violation
 in pointman.hoc near line 31
 objectvar pp
             ^
        xopen("pointman.hoc")
      execute1("{xopen("pointman.hoc")}")
    load_file("pointman.hoc")
  xopen("stdgui.hoc")
and others
51e648 2ae0d10f7ad0 objvardecl
mt
/users/shhong/local/NEURON-6.2/nrn/x86_64/bin/nrniv: Segmentation violation
 in pointman.hoc near line 32
 objref mt, sec, ms[1], sf, v1, this
          ^
        xopen("stdgui.hoc")
      execute1("{xopen("stdgui.hoc")}")
    load_file("stdgui.hoc")
51e580 2ae0d10f7ad0 objvardecl
shape
/users/shhong/local/NEURON-6.2/nrn/x86_64/bin/nrniv: Segmentation violation
 in pointman.hoc near line 33
 objref shape, d1
             ^
oc>
Any idea?
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Segmentation violation with gcc -finline-functions

Post by hines »

Sounds easy to reproduce if you would tell me what compiler and configure command you used.
shhong
Posts: 9
Joined: Wed Jan 07, 2009 6:52 am

Re: Segmentation violation with gcc -finline-functions

Post by shhong »

In linux, I used gcc 4.1.0 (SUSE Linux) and

Code: Select all

./configure --prefix=$HOME/local/NEURON-6.2/nrn --with-iv=$HOME/local/NEURON-6.2/iv CFLAGS='-O2 -m64 -finline-functions' CPPFLAGS='-O2 -m64 -finline-functions'
In mac, I will take the 6.2.3 case back, but the 7.0-232 still causes segmentation violations. I used gcc 4.0.1 (Apple build 5490) and

Code: Select all

./configure --prefix=/Applications/NEURON/nrn --with-iv=/Applications/NEURON/iv --with-nrnpython=/Library/Frameworks/Python.framework/Versions/2.5/bin/python PYLIB='-framework Python' PYLIBLINK='-framework Python' CFLAGS='-O2 -finline-functions -mtune=i686 -mfpmath=sse -msse3' CPPFLAGS='-O2 -finline-functions mtune=i686 -mfpmath=sse -msse3' 
Here,

Code: Select all

$ nrngui
NEURON -- VERSION 7.0 (232:fdfcab747fa3) 2008-11-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

oc>create soma
oc>access soma
oc>run()
/Applications/NEURON/nrn/i686/bin/nrniv: Segmentation violation
 near line 3
 run()
      ^
        fadvance()
      advance()
    step()
  continuerun(5)
and others
oc>
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Segmentation violation with gcc -finline-functions

Post by hines »

I probably will not be able to figure out what is wrong with -O3 (uses -finline-functions) when compiling
nrn/src/oc/code.c
but you can work around by configuring with
'CFLAGS=-O3 -m64' 'CXXFLAGS=-O3 -m64'
and installing and then
cd src/nrnoc
rm code.lo
editing Makefile and modifying the CFLAGS = line so it reads
CFLAGS = -O2 -m64
and then
make install # in the src/nrnoc directory where you modified the Makefile
shhong
Posts: 9
Joined: Wed Jan 07, 2009 6:52 am

Re: Segmentation violation with gcc -finline-functions

Post by shhong »

Thanks a lot. But the trick did not work in mac and so I had to remove fadvance.lo, too.
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Segmentation violation with gcc -finline-functions

Post by hines »

I did find an old bug in code.c that becomes visible with optimization level -O3 and -O4 on linux.
http://www.neuron.yale.edu/hg/neuron/nr ... 23c251843f
If this is not sufficient for the mac as well, let me know but a quick look in fadvance.c did not
turn up any similar mistakes.
Post Reply