Repository navigation
Import clr fails on Linux64/Mono #119
Copy link
Copy link
Closed
Description
Running python -c 'import clr' 2>&1 gives
*** Error in `python': double free or corruption (out): 0x00007ff2a2b41180 ***
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Initialize () <0xffffffff>
at Python.Runtime.Runtime.Initialize () <0x0003f>
at Python.Runtime.PythonEngine.Initialize () <0x00047>
at Python.Runtime.PythonEngine.InitExt () <0x0000f>
at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
/usr/lib/libmonoboehm-2.0.so.1(+0xcce3a) [0x7ff2a417de3a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10) [0x7ff2a56ffd10]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7ff2a535a267]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7ff2a535beca]
/lib/x86_64-linux-gnu/libc.so.6(+0x78c53) [0x7ff2a539dc53]
/lib/x86_64-linux-gnu/libc.so.6(+0x80c69) [0x7ff2a53a5c69]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c) [0x7ff2a53a989c]
/usr/lib/x86_64-linux-gnu/libpython2.7.so(PyString_InternInPlace+0x90) [0x7ff2a2c65ae0]
/usr/lib/x86_64-linux-gnu/libpython2.7.so(PyString_InternFromString+0x2a) [0x7ff2a2c65b6a]
/usr/lib/x86_64-linux-gnu/libpython2.7.so(PyType_Ready+0x1b25) [0x7ff2a2c6b6f5]
/usr/lib/x86_64-linux-gnu/libpython2.7.so(_Py_ReadyTypes+0xb0) [0x7ff2a2c59360]
/usr/lib/x86_64-linux-gnu/libpython2.7.so(Py_InitializeEx+0x76) [0x7ff2a2ce2106]
[0x4181c411]
Debug info from gdb:
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Aborted (core dumped)
I'm on a clean Ubuntu Wily64 system with some deps installed ontop:
mono-complete
libperl-dev
libgtk2.0-dev
python-dev
Pythonnet seems to install fine. Installing from develop branch gives
Unpacking /home/vagrant/src/pythonnet
Running setup.py (path:/tmp/pip-ndk1WW-build/setup.py) egg_info for package from file:///home/vagrant/src/pythonnet
Installing collected packages: pythonnet
Running setup.py install for pythonnet
All packages listed in packages.config are already installed.
XBuild Engine Version 12.0
Mono, Version 3.2.8.0
Copyright (C) 2005-2013 Various Mono authors
/tmp/pip-ndk1WW-build/pythonnet.sln: warning : The project configuration for project 'clrmodule' corresponding to the solution configuration 'ReleaseMono|x64' was not found.
XBuild Engine Version 12.0
Mono, Version 3.2.8.0
Copyright (C) 2005-2013 Various Mono authors
Configuration: ReleaseMono Platform: x64
/tmp/pip-ndk1WW-build/pythonnet.sln: warning : The project configuration for project 'clrmodule' corresponding to the solution configuration 'ReleaseMono|x64' was not found.
Configuration: ReleaseMono Platform: x64
Configuration: ReleaseMono Platform: x64
Configuration: Release Platform: x64
assemblyinfo.cs(24,49): warning CS0618: `System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete: `This requests should not be used'
pythonconsole.cs(24,24): warning CS0219: The variable `a' is assigned but its value is never used
building 'clr' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/monoclr/pynetinit.c -o build/temp.linux-x86_64-2.7/src/monoclr/pynetinit.o -D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
src/monoclr/pynetinit.c: In function ‘main_thread_handler’:
src/monoclr/pynetinit.c:100:17: warning: variable ‘init_result’ set but not used [-Wunused-but-set-variable]
MonoObject *init_result;
^
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/monoclr/clrmod.c -o build/temp.linux-x86_64-2.7/src/monoclr/clrmod.o -D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
src/monoclr/clrmod.c:42:18: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
static PyObject *_initclr() {
^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/monoclr/pynetinit.o build/temp.linux-x86_64-2.7/src/monoclr/clrmod.o -o build/lib.linux-x86_64-2.7/clr.so -L/usr/lib/pkgconfig/../../lib -lmono-2.0 -lm -lrt -ldl -lpthread -lglib-2.0
Successfully installed pythonnet
Cleaning up...
Metadata
Metadata
Assignees
Labels
No labels
Activity
den-run-ai commentedon Jan 22, 2016
UCS2 or UCS4?
tonyroberts commentedon Jan 22, 2016
Try the develop branch.
rihardsk commentedon Jan 25, 2016
@denfromufa UCS4
@tonyroberts i tried both the develop and the master branch
tonyroberts commentedon Jan 25, 2016
You could take a look at the travis CI build (which is also Ubuntu)
https://travis-ci.org/pythonnet/pythonnet/builds/101033785
One thing it could be is a problem with the version of Python you're using. There used to be issues depending on whether the python exe statically or dynamically linked the python shared object, but that (I thought) had been fixed in 9b2d6f2.
Maybe the Py_ENABLE_SHARED config var isn't set correctly in your build of Python. You could try hacking setup.py (just grep for Py_ENABLED_SHARED) and build it with and without PYTHON_WITHOUT_ENABLE_SHARED defined.
rihardsk commentedon Jan 27, 2016
Setting
defines.append("PYTHON_WITHOUT_ENABLE_SHARED")solves the issue.I checked that
lddwhich python`` givesSo it seems that the
get_config_var("Py_ENABLE_SHARED")check mistakenly setsenable_sharedtoTrue.oysols commentedon Feb 10, 2016
I experience the same problem.
Setting
defines.append("PYTHON_WITHOUT_ENABLE_SHARED")insetup.pysolves the issue for me as well.mikofski commentedon Mar 15, 2016
works for me too in develop branch on Ubuntu-14.04LTS
yay, works!
master branch in virtualenv did not work even with patch. :frown: but not sure about develop in virtualenv or master with
--userAlvarz commentedon Apr 6, 2016
I'm still having this error on fedora 23 even after i did the steps given by @mikofski
Mono, Version 4.0.5.0
Python 2.7
den-run-ai commentedon Apr 28, 2016
@Alvarz is your python 2.7 and mono provided with fedora or installed/built from elsewhere? I'm downloading fedora 23 iso image to test your problem.
Alvarz commentedon Apr 28, 2016
Thanks for your answer, both was the provided by fedora but un any case our
team decided to Run a window mschine with .net to avoid issues.
Again thanks
El jue 28/04/2016, 12:24 a.m., denfromufa [email protected]
escribió:
maksimlinio commentedon Aug 18, 2016
I am still having this error
Linux Mint 17.2, Python 2.7, Mono 4.4.2
Tried recipe of @mikofski , didn't help:
`
den-run-ai commentedon Aug 19, 2016
@maksimlinio use mono 4.2.4.4 and see discussion here:
#241
den-run-ai commentedon Sep 6, 2016
FYI, today I found out that Py_ENABLE_SHARED set incorrectly is a bug in Ubuntu/Debian linux distros, that was discussed here:
https://bitbucket.org/anthony_tuininga/cx_freeze/issues/32/cant-compile-cx_freeze-in-ubuntu-1304
Here is a patch that can be applied to setup.py to workaround this bug in Ubuntu/Debian packages for CPython:
https://bitbucket.org/anthony_tuininga/cx_freeze/commits/6e933509e4528f24919708eee1a68683f8aa029b
Update setup.py
den-run-ai commentedon Dec 4, 2016
@tonyroberts @vmuriart @filmor I would like to resolve this issue before doing a release. This is breaking "import clr" on Ubuntu/Mint, Fedora.
In cx_freeze the check for PYTHON_ENABLE_SHARED is completely disabled now, maybe we should do the same?
I will try to get this tested now:
#300
Work around a broken shared detection on some platforms (#300)
den-run-ai commentedon Dec 7, 2016
@rihardsk @maksimlinio @Alvarz @mikofski @oysols this is now fixed in the master branch, by inspecting the output of ldd for libpython.
AlexCatarino commentedon Dec 13, 2016
After this fix, when you try to run nPython:
mono nPython.exe, does it run?In #303, I wrote what happens:
libpython is not linked dynamically with my python installation, thus setup.py compiled with the PYTHON_WITHOUT_ENABLE_SHARED flag.
If I remove this flag, I can execute nPython, but cannot import clr...
den-run-ai commentedon Mar 20, 2017
@AlexCatarino like discussed in this issue both embedding and extending are now resolved by @vmuriart:
#245 (comment)