Python crashes when loading nrnmech.dll

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
uri.cohen
Posts: 24
Joined: Wed Jul 20, 2011 9:14 am

Python crashes when loading nrnmech.dll

Post 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!
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python crashes when loading nrnmech.dll

Post 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?
uri.cohen
Posts: 24
Joined: Wed Jul 20, 2011 9:14 am

Re: Python crashes when loading nrnmech.dll

Post 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()
.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python crashes when loading nrnmech.dll

Post by ted »

What version of NEURON are you using--what exactly does NEURON print to its xterm when it first starts up?
uri.cohen
Posts: 24
Joined: Wed Jul 20, 2011 9:14 am

Re: Python crashes when loading nrnmech.dll

Post 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.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Python crashes when loading nrnmech.dll

Post 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
uri.cohen
Posts: 24
Joined: Wed Jul 20, 2011 9:14 am

Re: Python crashes when loading nrnmech.dll

Post 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 -
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Python crashes when loading nrnmech.dll

Post 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.
uri.cohen
Posts: 24
Joined: Wed Jul 20, 2011 9:14 am

Re: Python crashes when loading nrnmech.dll

Post 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'
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Python crashes when loading nrnmech.dll

Post 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.
Post Reply