Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using square brackets in get_ports() results in a segmentation fault. #63

Open
MaurizioB opened this issue Apr 11, 2019 · 4 comments
Open
Labels

Comments

@MaurizioB
Copy link
Contributor

With this code, python just crashes:

import jack
client = jack.Client('test')
print(client.get_ports('[]'))

I also tried different combinations (single bracket, adding text before, etc). The segfault happens on both Python 2.7.12 and 3.4.5.

@mgeier
Copy link
Member

mgeier commented Apr 12, 2019

Thanks for the report!

This seems to be a bug in JACK which was reported to the mailing list in February: http://lists.jackaudio.org/pipermail/jack-devel-jackaudio.org/2019-February/001694.html (link may be for list members only?).

Anyway, this was transferred to a Github issue (jackaudio/jack2#433) and the bug was promptly fixed (jackaudio/jack2@d4ef680).

There has been no new JACK2 release since then, so you'll have to compile it yourself to get the fixed version.

The same issue is not yet fixed in JACK1: jackaudio/jack1#85

@mgeier mgeier added the bug label Apr 12, 2019
@MaurizioB
Copy link
Contributor Author

Ok, if I understand it correctly, the fix just checks if the regex pattern is valid, right?
For the time being (since I'm still using jack1), I think I'll override the get_ports method like this:

import re
import jack

def _get_ports_fix(self, name_pattern='', is_audio=False, is_midi=False,
                   is_input=False, is_output=False, is_physical=False,
                   can_monitor=False, is_terminal=False):
    if name_pattern:
        try:
            re.compile(name_pattern)
        except:
            return []
    return jack.Client._get_ports(self, name_pattern, is_audio, is_midi, 
                                  is_input, is_output, is_physical, 
                                  can_monitor, is_terminal)

jack.Client._get_ports = jack.Client.get_ports
jack.Client.get_ports = _get_ports_fix

Thank you for your answer.
Let me know If you have a better solution.

@mgeier
Copy link
Member

mgeier commented Apr 20, 2019

@MaurizioB Yes, I think in the meantime this is a reasonable work-around.

There might be some edge cases though, because I assume the two regex engines may have slightly different rules.

@EternityForest
Copy link

EternityForest commented Jul 29, 2019

Not sure if this is helpful, but I have a trace of (what I think is) this thanks to faulthandler

Current thread 0x00007f7b04ff9700 (most recent call first):
File "/usr/lib/python3/dist-packages/jack.py", line 315 in owns
File "/usr/lib/python3/dist-packages/jack.py", line 1377 in _wrap_port_ptr
File "/usr/lib/python3/dist-packages/jack.py", line 1265 in get_port_by_name
File "/usr/lib/python3/dist-packages/jack.py", line 1361 in _port_list_from_pointers
File "/usr/lib/python3/dist-packages/jack.py", line 1329 in get_ports
File "Event_Carnyx_WebUI Backend", line 4 in _event_action
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/newevt.py", line 590 in _do_action
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/newevt.py", line 440 in _on_trigger
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/newevt.py", line 861 in _check
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/newevt.py", line 547 in check
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/newevt.py", line 195 in _run
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/workers.py", line 92 in workerloop
File "/usr/lib/python3.6/threading.py", line 864 in run
File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Version is 0.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants