Page 1 of 1

Segfault on errors

Posted: Thu Jun 05, 2014 10:51 pm
by jhl
I apologise if this bug has already been reported or fixed; I couldn't find anything on it.

When you run NEURON 7.3 on Gentoo Linux with no stdin, the error handler tries to fseek() the input even though it's NULL, and it segfaults.
This can be reproduced from the commandline:

Code: Select all

nrniv -c flibberty
Or from ipython:

Code: Select all

from neuron import h
h("frobozz")
A very simple fix follows. I'm not sure why the fin==stdin or nrn_istty_ checks seem to return the wrong result in the commandline case.

Code: Select all

diff -urN nrn-7.3/src/oc/hoc.c nrn-7.3-fseek/src/oc/hoc.c
--- nrn-7.3/src/oc/hoc.c        2014-05-16 03:58:03.000000000 +1000
+++ nrn-7.3-fseek/src/oc/hoc.c  2014-06-04 14:45:31.610050605 +1000
@@ -626,7 +626,7 @@
        }
 #endif
        hoc_execerror_messages = 1;
-       if (pipeflag == 0 && (!nrn_fw_eq(fin, stdin) || !nrn_istty_))
+       if (fin && pipeflag == 0 && (!nrn_fw_eq(fin, stdin) || !nrn_istty_))
                IGNORE(nrn_fw_fseek(fin, 0L, 2));       /* flush rest of file */
        hoc_oop_initaftererror();
 #if defined(WIN32) && !defined(CYGWIN)

Re: Segfault on errors

Posted: Fri Jun 06, 2014 2:37 pm
by hines
Thanks for the bug fix. I've added it to the sources:
http://www.neuron.yale.edu/hg/neuron/nr ... 1e4a0404a4

Re: Segfault on errors

Posted: Sat Jun 07, 2014 2:04 am
by jhl
Great. Thanks!