alsa_seq: no crash when the sequencer device cannot be opened - #262
Merged
Merged
Conversation
When /dev/snd/seq is missing (snd-seq not loaded, container, no permission), init_client() fails and the error handler only logs, leaving seq null. The observer then called snd_seq_poll_descriptors(NULL, ...) and segfaulted, and port enumeration, virtual input ports and the in/out destructors would have dereferenced the same null handle. Every one of those now checks seq first, and midi_in no longer reports itself open without a client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014tPT7bc2XWmFyQUtv9B4MX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
/dev/snd/seqcannot be opened (snd-seq not loaded, a container, no permission),init_client()fails and the error handler only logs, so the object carries on with a nullsnd_seq_t*:observer_threaded's constructor then calledsnd_seq_poll_descriptors(NULL, …)and segfaulted (alsa-lib's asserts are compiled out, sopoll_descriptors_countreturned 1 without dereferencing and the next call did).for_all_ports/iterate_port_info(used byget_input_ports()etc.),midi_in_alsa_threaded(which also claimedclient_open_and went on tosnd_seq_create_port(NULL)),close_port, and the in/out destructors would have dereferenced the same null handle.Every one of those now checks
seqfirst;init_clientresetsseqto null on failure so the checks do not depend on alsa-lib leaving it untouched;midi_inno longer reports itself open without a client.Found by the ossia score test suite on a machine whose kernel modules directory had been removed by an upgrade (so snd-seq could not load): four tests segfaulted in
snd_seq_poll_descriptors. After the fix they pass, and with the device present nothing changes.🤖 Generated with Claude Code