Segfault on errors

Post Reply
jhl

Segfault on errors

Post by jhl » Thu Jun 05, 2014 10:51 pm

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)

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

Re: Segfault on errors

Post by hines » Fri Jun 06, 2014 2:37 pm

Thanks for the bug fix. I've added it to the sources:
http://www.neuron.yale.edu/hg/neuron/nr ... 1e4a0404a4

jhl

Re: Segfault on errors

Post by jhl » Sat Jun 07, 2014 2:04 am

Great. Thanks!

Post Reply