Skip to content

Segfault importing pytrellis.so on Apple M1 #185

@ccattuto

Description

@ccattuto

Apple Macbook Pro M1
OSX Monterey 12.2.1
Native arm64 Python 3.9.10 via Miniforge
Xcode 13.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
boost 1.78.0_1 (Homebrew)

The library and executables build cleanly. No warnings of notice except for a few deprecations:

/opt/homebrew/include/boost/format/group.hpp:59:12: warning: definition of implicit copy constructor for 'group1<boost::io::detail::group0>' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
   group1& operator=(const group1&);

pytrellis.so is very big (~8 Mb). On importing it from Python, it segfaults:

Python 3.9.10 | packaged by conda-forge | (main, Feb  1 2022, 21:27:43) 
[Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytrellis.so
zsh: segmentation fault  python

Digging a bit deeper shows that this happens when calling take_gil() when importing pytrellis.so.

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  * frame #0: 0x000000010489cad8 libpython3.9.dylib`take_gil + 84
    frame #1: 0x00000001048ffce0 libpython3.9.dylib`PyGILState_Ensure + 56
    frame #2: 0x0000000103ff57ec pytrellis.so`pybind11::detail::get_internals() + 64
    frame #3: 0x0000000103ff567c pytrellis.so`PyInit_pytrellis + 120

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions