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

Segfault when booting server (invalid port names) #160

Closed
paulie-g opened this issue Aug 15, 2019 · 10 comments
Closed

Segfault when booting server (invalid port names) #160

paulie-g opened this issue Aug 15, 2019 · 10 comments

Comments

@paulie-g
Copy link

Linux (Arch,5.3-rc-latest from git), latest pyo from pypi.

I have no inputs available. Default (set to portaudio for some reason) wouldn't work at all, server wouldn't boot complaining about input channels < 2, both when running pulseaudio only and jack+pulseaudio. Setting duplex=0 didn't help. I did manage to get it to boot once by hard setting input channels in the jack config, but output didn't work.

Setting audio='jack' and duplex=0 didn't work either. It now segfaults because it can't connect to input ports = 'system'. This was supposed to be partially fixed via #15, since pyo has no reason to connect to inputs when duplex=0, but the fix does not work for me.

This is a problem, because:

  1. It is a common setup and having it be broken is a barrier for people trying out pyo as well as those who wish to distribute projects using pyo.
  2. duplex=0 doesn't work as intended.
  3. A segfault is not an acceptable failure mode.

I've managed to work around the issue with:

s = Server(duplex=0,audio='jack')
s.setJackAuto(False,False)
s.boot()
... connect to output programmatically or manually ...

However, this is imo unsatisfactory, especially since it's not documented anywhere. I recall having this same issue when attempting to try out pyo many months back, and not having the time/motivation to debug at the time, concluded that it wasn't worth the time to do so just to try it out.

This is not intended to be harsh, btw, although my LKML-influenced style might make it read that way ;) Please assume that I'm thrilled that someone took the time to create this.

@belangeo
Copy link
Owner

It now segfaults because it can't connect to input ports = 'system'. This was supposed to be partially fixed via #15, since pyo has no reason to connect to inputs when duplex=0, but the fix does not work for me.

This means that pyo can't connect its "output ports" to system's input ports, not the other way!

I don't think the problem is with duplex=0 (it behaves as it is supposed to) but rather with pyo assuming that jack's default port names are "system". I guess this is not the case for you, is it?

However, I agree that a segfault is unacceptable in the case of failure to connect...

@paulie-g
Copy link
Author

paulie-g commented Aug 30, 2019

It now segfaults because it can't connect to input ports = 'system'. This was supposed to be partially fixed via #15, since pyo has no reason to connect to inputs when duplex=0, but the fix does not work for me.

This means that pyo can't connect its "output ports" to system's input ports, not the other way!

I meant pyo expects jack output ports named 'system' to exist, which it then intends to use as input.

I don't think the problem is with duplex=0 (it behaves as it is supposed to)

Documentation says setting duplex to 0 will set pyo to output-only mode where it will only attempt to connect to jack's input ports. It demonstrably doesn't work like that, still attempts to connect to jack's output ports, fails to find them and sigsegvs. Doing this manually by disabling auto-connection, booting the server and connecting just the output to jack's input does work.

but rather with pyo assuming that jack's default port names are "system". I guess this is not the case for you, is it?

Jack, for me, has input ports named 'system', but no output ports named 'system'. I suspect the latter appear if there is a line in/mic in active, but do not exist at other times. I'm going to guess that the dev who committed this works on a laptop, where a mic is always present.

However, I agree that a segfault is unacceptable in the case of failure to connect...

+1.

I could be missing/wrong about something as I haven't had cause to fully grok linux audio to date.

@paulie-g
Copy link
Author

Output of jack-client for python

Python 3.7.4 (default, Jul 16 2019, 07:12:58) 
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jack
>>> client = jack.Client("test")
Cannot lock down 82280346 byte memory area (Cannot allocate memory)
Jack: JackClient::SetupDriverSync driver sem in flush mode
Jack: JackLinuxFutex::Connect name = jack_sem.1000_default_test
Jack: Clock source : system clock via clock_gettime
Jack: JackLibClient::Open name = test refnum = 6
>>> client.activate()
Jack: JackClient::Activate
Jack: JackClient::ClientNotify ref = 6 name = test notify = 2
Jack: JackClient::kActivateClient name = test ref = 6 
>>> client.get_ports()
[jack.Port('system:playback_1'), jack.Port('system:playback_2'), jack.Port('PulseAudio JACK Sink:front-left'), jack.Port('PulseAudio JACK Sink:front-right'), jack.Port('PulseAudio JACK Source:front-left'), jack.Port('PulseAudio JACK Source:front-right')]

@belangeo
Copy link
Owner

I think I got it. Nothing prevent the auto-connection in the Server's jack backend. This does not create any trouble in my Debian computer so I've never spot it. I'm out of town, I'll fix it when I come back and let you know when it's ready for testing.

@paulie-g
Copy link
Author

My apologies - this would normally be a pull request instead of a bug report, but I don't understand pyo and jack well enough nor would I know your preferred way to fix it. Very happy to test of course.

@belangeo
Copy link
Owner

belangeo commented Sep 2, 2019

Setting audio='jack' and duplex=0 didn't work either. It now segfaults because it can't connect to input ports = 'system'. This was supposed to be partially fixed via #15, since pyo has no reason to connect to inputs when duplex=0, but the fix does not work for me.

Can you give me the exact error message, if any, when you try with duplex=0 ? Thanks!

@paulie-g
Copy link
Author

paulie-g commented Sep 2, 2019

Pyo error: Jack cannot find any physical capture ports called 'system'
Segmentation fault (core dumped)

This is with Server(audio='jack', duplex=0). With Server(), which uses portaudio which in turn uses jack on my system, the server boots, doesn't segfault, but audio doesn't work and nothing shows up in the jack connections.
setJackAuto(False, True) before boot solves the problem. My understanding is duplex=0 should have the same effect, but doesn't.

belangeo added a commit that referenced this issue Sep 2, 2019
…king if input ports variable is NULL (trying to fix issue #160).
@belangeo
Copy link
Owner

belangeo commented Sep 2, 2019

Can you compile pyo from latest sources and tell me if my fix is working? Thank you!

@paulie-g
Copy link
Author

paulie-g commented Sep 3, 2019

Duplex works as expected now. Unless someone knows to use it, pyo still sigsegvs by default in my config. Since a fix for that is not present in the last commit, I'm assuming this is expected.

belangeo added a commit that referenced this issue Sep 3, 2019
@belangeo
Copy link
Owner

belangeo commented Sep 3, 2019

The segfault is now fixed. If Jack doesn't have any input ports, pyo's Server simply falls back to playback-only mode. It's in git now.

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

No branches or pull requests

2 participants