Segfault on errors
Posted: 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:
Or from ipython:
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.
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
Code: Select all
from neuron import h
h("frobozz")
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)