Page 1 of 1

Python crashes when loading nrnmech.dll

Posted: Tue Oct 04, 2011 4:43 am
by uri.cohen
I have NEURON compiled from sources on WinXP machine and can use it to successfully compile mod files into nrnmech.dll.
However, when loading nrnmech.dll the process crashes (that is, exits without any visible error).
Opening the same nrnmech.dll from NEURON works well, so it seems like some python issue.

Have anyone seen a similar issue? Thanks!

Re: Python crashes when loading nrnmech.dll

Posted: Tue Oct 04, 2011 9:06 am
by ted
uri.cohen wrote:when loading nrnmech.dll the process crashes (that is, exits without any visible error).
Opening the same nrnmech.dll from NEURON works well, so it seems like some python issue
What python statement are you usign to load the nrnmech.dll file, or are you referring to the "automatic load" that occurs upon starting NEURON when the working directory contains a nrnmech.dll file?

Re: Python crashes when loading nrnmech.dll

Posted: Tue Oct 04, 2011 10:40 am
by uri.cohen
The crash happen both under automatic load using

Code: Select all

import neuron
from the directory where the dll reside and when using

Code: Select all

h.nrn_load_dll()
.

Re: Python crashes when loading nrnmech.dll

Posted: Tue Oct 04, 2011 10:10 pm
by ted
What version of NEURON are you using--what exactly does NEURON print to its xterm when it first starts up?

Re: Python crashes when loading nrnmech.dll

Posted: Wed Oct 05, 2011 2:39 am
by uri.cohen
For the python integration I need to compile it from sources. Here's the printout:

Code: Select all

NEURON -- VERSION 7.2 (527+:a38b8d137de6+) 2011-07-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html
Also it should be noted I use python 2.7.

Re: Python crashes when loading nrnmech.dll

Posted: Wed Oct 05, 2011 12:29 pm
by hines
I'll try to reproduce this on my xp machine.
What configure command did you use?
Are you using the latest cygwin updates?
I see that the code is modified (the '+' after revision 527).
Can you email me the patch?

Another test is for you to navigate to c:/nrn72/demo/release, launch python
and see if "import neuron" loads the nrnmech.dll of the demo. If that works
please email the mod files you used to create the nrnmech.dll

Re: Python crashes when loading nrnmech.dll

Posted: Wed Oct 05, 2011 8:03 pm
by uri.cohen
I get the failure in half a dozen models, all with consistent behavior. For example with http://senselab.med.yale.edu/modeldb/sh ... del=139654. Now regarding your questions.
What configure command did you use?
I was using the following:

Code: Select all

$ export PYHOME=/cygdrive/c/Python27
$ export PYLIB=”-L$PYHOME/libs -lpython27”
$ export PYLIBDIR=$PYHOME/libs
$ export PYLIBLINK=”-L$PYHOME/libs -lpython27”
$ export PYINCDIR=$PYHOME/include
$
$ ./configure --prefix=`pwd` --with-nrnpython=$PYHOME/python CC=gcc-3 CXX=g++-3 use_pthread=no
Are you using the latest cygwin updates?
Yes
I see that the code is modified (the '+' after revision 527).
Can you email me the patch?
Those were the changes I've done so that it will compile correctly on Windows. I believe you've merged this patch to the tip at revision 536.
Another test is for you to navigate to c:/nrn72/demo/release, launch python
and see if "import neuron" loads the nrnmech.dll of the demo. If that works
please email the mod files you used to create the nrnmech.dll
Very nice, it fails with a popup window and an error message (unlike loading my dlls, not sure what's the difference):
The popup title is "python.exe - Entry Point Not Found" and the error reads "The procedure entry point _nmodlmutex could not be located in the dynamic link library nrniv.dll." The output is as below:

Code: Select all

>>> import neuron
NEURON -- VERSION 7.2 (527+:a38b8d137de6+) 2011-07-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

loading membrane mechanisms from nrnmech.dll
LoadLibrary("nrnmech.dll") failed with error 127
dlopen failed -

Re: Python crashes when loading nrnmech.dll

Posted: Thu Oct 06, 2011 7:30 am
by hines
Is that a cygwin version of python or pure windows enthought distribution?
I presume the latter.
./configure ... use_pthread=no
...
_nmodlmutex could not be located in the dynamic link library nrniv.dll
I should be able to reproduce the problem. It must be that use_pthread=no is
allowing a reference to threads to creep into the mknrndll process of constructing
nrnmech.dll
I'm guessing this is a problem on either cygwin/enthought, and perhaps on all other os's as well. I must admit it has been
a long time since I tried to build NEURON without posix threads.
Will get back to you when I know more or have fixed the problem.

Re: Python crashes when loading nrnmech.dll

Posted: Thu Oct 06, 2011 8:15 pm
by uri.cohen
The reason I've chosen to add to configure the flag "use_pthread=no" is that when using pthread I run type into conflicts: one of the Windows header files included in MinGW (/usr/i686-pc-mingw32/sys-root/mingw/include/rpcndr.h) contained a conflicting definition of boolean.
You can reproduce the issue by removing the "use_pthread=no":

Code: Select all

$ export PTHREAD_LIBS="-lpthreadGC2 -L/usr/i686-pc-mingw32/sys-root/mingw/bin/"
$ ./configure --prefix=`pwd` --with-nrnpython=$PYHOME/python CC=gcc-3 CXX=g++-3
...
$ make
...
/usr/i686-pc-mingw32/sys-root/mingw/include/rpcndr.h:52: error: conflicting declaration 'typedef unsigned char osboolean'
../../src/ivos/OS/enter-scope.h:43: error: 'osboolean' has a previous declaration as `typedef unsigned int osboolean'
/usr/i686-pc-mingw32/sys-root/mingw/include/rpcndr.h:52: error: declaration of `typedef unsigned char osboolean'
../../src/ivos/OS/enter-scope.h:43: error: conflicts with previous declaration `typedef unsigned int osboolean'
/usr/i686-pc-mingw32/sys-root/mingw/include/rpcndr.h:52: error: declaration of `typedef unsigned char osboolean'
../../src/ivos/OS/enter-scope.h:43: error: conflicts with previous declaration `typedef unsigned int osboolean'

Re: Python crashes when loading nrnmech.dll

Posted: Sun Oct 09, 2011 8:48 pm
by hines
With win7 32 bit and epd-7.1-2 i was able to successfully build a loadable nrnmech.dll
after building the latest repository sources with:

Code: Select all

 ../nrn/configure  '--prefix=/home/hines/neuron/uri' \
 '--with-nrnpython=/cygdrive/c/Python27/python' \
 'CC=gcc-3' 'CXX=g++-3' 'use_pthread=no' \
 'PYLIB=-L/cygdrive/c/Python27/libs -lpython27' \
 'PYLIBDIR=/cygdrive/c/Python27/libs' \
 'PYLIBLINK=-L/cygdrive/c/Python27/libs -lpython27' \
 'PYINCDIR=/cygdrive/c/Python27/include'

make
make mswin
The dos command box environment I used is

Code: Select all

set PYTHONPATH=c:/marshalnrn/nrn/lib/python;c:/marshalnrn/nrn/bin
set NEURONHOME=c:/marshalnrn/nrn
set PATH=%PATH%;c:\marshalnrn\nrn\bin
However, to use mknrndll in an rxvt terminal, i did have to set
export N=/cygdrive/c/marshalnrn/nrn
and also edit $N/lib/mknrndll.mak
to change all the gcc to $(CC) and set the latter to
CC=gcc-3

In other words, I did not have a problem with 'use_pthread=no'.
If you do not invoke 'use_pthread=no' and wish to use the mingw compilers supplied by cygwin
it turns out that most of the nrnwin7-64-epd.patch I sent to you has the changes needed to avoid the
boolean conflict. See nrntypes.h. I'll experiment with factoring the patch into two pieces. the first
would fix the 32 bit problems and the second would do the minor additional changes to fix the remaining
64 bit problems.