Skip to content

alsa_seq: no crash when the sequencer device cannot be opened - #262

Merged
jcelerier merged 1 commit into
masterfrom
fix/alsa-seq-no-device
Sep 24, 2026
Merged

jcelerier merged 1 commit into
masterfrom
fix/alsa-seq-no-device

Conversation

@jcelerier

Copy link
Copy Markdown
Member

When /dev/snd/seq cannot 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 null snd_seq_t*:

  • observer_threaded's constructor then called snd_seq_poll_descriptors(NULL, …) and segfaulted (alsa-lib's asserts are compiled out, so poll_descriptors_count returned 1 without dereferencing and the next call did).
  • for_all_ports / iterate_port_info (used by get_input_ports() etc.), midi_in_alsa_threaded (which also claimed client_open_ and went on to snd_seq_create_port(NULL)), close_port, and the in/out destructors would have dereferenced the same null handle.

Every one of those now checks seq first; init_client resets seq to null on failure so the checks do not depend on alsa-lib leaving it untouched; midi_in no 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

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
@jcelerier
jcelerier merged commit 0780351 into master Sep 24, 2026
39 of 90 checks passed
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

Successfully merging this pull request may close these issues.

1 participant