spatialaudio / jackclient-python

🂻 JACK Audio Connection Kit (JACK) Client for Python :snake:
https://jackclient-python.readthedocs.io/
MIT License
131 stars 26 forks source link

Segfault during import #95

Closed HaHeho closed 3 years ago

HaHeho commented 3 years ago

Hey, very recently I experience this segmentation fault whenever trying to import the package. I have no idea yet what component caused the change in behavior. The most probable candidate is building more recent versions of jack2 from source. Maybe investigating this can help to solve a bug here or upstream.

This is the most basic case where the segfault happens (empty environment, basically not more than pip install):

$ python3
Python 3.8.5 (default, Sep  4 2020, 02:22:02)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jack
[1]    41999 segmentation fault  python3

Using faulthandler reveals that it happens during the decoding of "JACK_METADATA_" during import:

$ python3 -q -X faulthandler
>>> import jack
Fatal Python error: Segmentation fault

Current thread 0x0000000114f1cdc0 (most recent call first):
  File "/Users/helmholz/miniconda3/envs/test/lib/python3.8/site-packages/jack.py", line 82 in _decode
  File "/Users/helmholz/miniconda3/envs/test/lib/python3.8/site-packages/jack.py", line 89 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 783 in exec_module
  File "<frozen importlib._bootstrap>", line 671 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 975 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 991 in _find_and_load
  File "<stdin>", line 1 in <module>
[1]    43708 segmentation fault  python3 -q -X faulthandler
HaHeho commented 3 years ago

These changes https://github.com/jackaudio/jack2/commit/f3e8a6bc6b57c15e47de6cc8640764e439594cbd might be the cause?

mgeier commented 3 years ago

Thanks for the report!

I can reproduce the problem, but I don't really understand the details of it.

I've left a comment at https://github.com/jackaudio/jack2/pull/578#issuecomment-707338266.

If we don't find a solution that's compatible with both old and new JACK versions, I think it would be best to simply hard-code the constants in the Python code without looking at the JACK library.

HaHeho commented 3 years ago

Good, thank you.

Unfortunately I am not able to contribute to the discussion or a fix at the moment since my C is too rusty at this point and I have not looked into cffi so far.

HaHeho commented 3 years ago

The change also caused other application to break. Therefore it was reverted in the most recent 1.9.16 release. We will have to keep an eye on when they are going to reintroduce the change that initially broke the Python bindings.

FYI, this time I installed via the newly available installer (macOS and Windows) which worked without problems. https://github.com/jackaudio/jack2-releases/releases/tag/v1.9.16

C0nsultant commented 3 years ago

Can confirm. The reverted changes in upstream JACK2 (v1.9.16) allow this binding to work again without SEGFAULTing.