Salar Khan
Salar Khan

Reputation: 487

Script compiled with Nuitka, raises Segmentation Fault

I have a script 'test.py' which imports some '.so' modules and depends upon them. the '.so' modules are present inside a folder 'COMPILED' whose absolute path I've added to PYTHONPATH environment variable. So, now when I run it - "$ python test.py" - it runs great. And when I compile it using Nuitka - "$ nuitka --recurse-all test.py" - it compiles too and produces a 'test.exe' executable, now when I execute it instead of importing the module and running normally it raises a 'Segmentation Fault'

And Lastly, I'd like to add that I have generated the '.so' files using Nuitka too - they're basically modules. They work like a dream with normal uncompiled python, but as soon as I compile test.py with Nuitka.... KABOOM!

THIS QUESTION HAS BEEN POSTED BEFORE:

But It has not been answered and I could not comment or notify someone there, because I've just created my account, so I have asked it again. Here's the link to the previously asked version: python package complied with nuitka fails with segmentation fault

Directory Structure:
/PARENT_FOLDER
|______/COMPILED: <---- this folder contains all the '.so' files
|       file1.so
|       file2.so
|       .
|       .
|______test.py    <---- here is the test.py script

Upvotes: 1

Views: 1890

Answers (1)

Salar Khan
Salar Khan

Reputation: 487

Ok! so my problem has been solved. Turns out that it was some issue with memory layout and stuff I got some hints from here: http://www.freelists.org/post/nuitka-dev/Building-modules-separately-from-the-main-application,3

The page basically says that using clang with nuitka instead of gcc removes the segfault. I was going to try that, but I randomly typed in "nuitka --help" and came across this option "--lto(link time optimizations)". I thought of giving it a try - note, according to --help this requires g++ - so instead of running

nuitka --recurse-all test.py 

I ran

nuitka --lto test.py

and the resulting binary executes just fine with no 'segmentation faults'. I also ran

nuitka --recurse-all --lto test.py 

that works too - in case you're wondering. This has also been reported as a bug on the Nuitka bug list:

http://bugs.nuitka.net/issue238?@ok_message=msg%201799%20created%0Aissue%20238%20messages%20edited%20ok&@template=item

Environment:

Nuitka version: 0.5.18

gcc version: 4.8.4

Ubuntu 14.04 64bit on intel corei5

Upvotes: 1

Related Questions