[New-bugs-announce] [issue31290] segfault on missing library symbol

Richard report at bugs.python.org
Mon Aug 28 03:28:43 EDT 2017


New submission from Richard:

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.)

----------
messages: 300942
nosy: immortalplants
priority: normal
severity: normal
status: open
title: segfault on missing library symbol
versions: Python 2.7, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31290>
_______________________________________


More information about the New-bugs-announce mailing list