2

I'm trying to wrap around an existing C++ llibrary we have for Python 3.6. I've followed the tutorials of Boost Python:

All of them SIGSEV, so I run the command under gdb:

gdb --args python -c 'import MyPyLib'

And the actual output is:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3bb02a9 in GlobalError::PushToStack() () from /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0

I tried to run the boost-python-examples from Github and I get the same problem. If it helps, I'm on:

  • gcc 7.4.0
  • g++ 7.4.0
  • python 3.6.8
  • ibboost-python-dev 1.65.1

1 Answer 1

3

I found the problem, all examples use

find_package(Boost REQUIRED COMPONENTS python)

But if you pay attention, there are two libraries in the system:

sudo ldconfig -p | grep "libboost_python*"
        libboost_python3-py36.so.1.65.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libboost_python3-py36.so.1.65.1
        libboost_python3-py36.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libboost_python3-py36.so
        libboost_python-py27.so.1.65.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1
        libboost_python-py27.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so

So I started suspecting that my module was being linked to python 2.7 boost-python. I swapped in CMakeLists.txt the actual component:

find_package(Boost REQUIRED COMPONENTS python3)

And now it works fine. It's quite surprising that such a miss-match throws such a cryptic error. Also cmake complains when using python3 that no headers were found or indexed.

Sign up to request clarification or add additional context in comments.

3 Comments

I had a similar issue (with the same segfault in GlobalError::PushToStack) when I added some dependency of my python module on an external C library, but forgot to link to it. Instead of bailing out with some missing symbol error, you get this cryptic error, and very little of a meaningful backtrace.
I am having a similar issue when using Cython. Any tips what might be the issue?
@skboro make absolutely sure the python library versions absolutely match. If they don't the ABI will throw sneaky errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.