classification
Title: segfault on missing library symbol
Type: Stage:
Components: Versions: Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: immortalplants, xtreak
Priority: normal Keywords:

Created on 2017-08-28 07:28 by immortalplants, last changed 2018-09-14 09:49 by xtreak.

Messages (1)
msg300942 - (view) Author: Richard (immortalplants) Date: 2017-08-28 07:28
I'm building a Python library with a C++ component composed of a number of source .cpp files.

After some changes today, compiling and loading in Python3 resulted in a segfault:


Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mymodule
Segmentation fault (core dumped)


As you might imagine, this is not the funnest thing ever to debug.

Thankfully, when I compiled the module for Python2 and tried to load, a much more helpful and informative error message was displayed.


Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mymodule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mymodule/__init__.py", line 1, in <module>
    import _mymodule
ImportError: ./_mymodule.so: undefined symbol: DBFGetRecordCount
>>> 


And indeed, it seems that in my setup.py file where I had

setuptools.Extension(
  "_mymodule",
  glob.glob('src/*.cpp') + glob.glob('lib/mylib/*.cpp') + glob.glob('lib/mylib/sublib/*.c'),

I should have had 'lib/mylib/sublib/*.cpp'.



I think the current behaviour can be improved:

1. Python3 should provide a helpful error message, like Python2 does.

2. setup.py should fail or at least provide a warning if there are missing symbols. (Perhaps this suggestion should be aimed at one of the setup utilities, but I'm not sure where to send it.)
History
Date User Action Args
2018-09-14 09:49:38xtreaksetnosy: + xtreak
2017-08-28 07:28:43immortalplantscreate