Skip to content

linux-alsa: stop reopen thread before destroying abort_event#13480

Open
quine00 wants to merge 1 commit into
obsproject:masterfrom
quine00:alsa-reopen-race
Open

linux-alsa: stop reopen thread before destroying abort_event#13480
quine00 wants to merge 1 commit into
obsproject:masterfrom
quine00:alsa-reopen-race

Conversation

@quine00

@quine00 quine00 commented May 26, 2026

Copy link
Copy Markdown

Description

Was hitting an abort in glibc's__pthread_mutex_cond_lock from os_event_timedwait in the ALSA plugin's reopen thread.

Motivation and Context

While running obs on on Ubuntu 26.04 (32.1.0-0ubuntu3), occassionally I would see crashes. I investigated one such crash using apport-retrace and came to the attached fix.

How Has This Been Tested?

I rebuilt my changes against the affected Ubuntu version, and did my usual OBS workflow for a few days. No crashes found so far, whereas before it was common.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@quine00

quine00 commented May 26, 2026

Copy link
Copy Markdown
Author

@kkartaltepe kkartaltepe added the platform/linux Categorizes issue or PR as affecting Linux specifically label May 26, 2026
This was found by inspecting a crash backtrace that aborted in
glibc's __pthread_mutex_cond_lock from os_event_timedwait in the ALSA
plugin's reopen thread.

alsa_destroy was destroying abort_event without first stopping and
joining the thread, which also waits on that event. If destruction
wins the race, the waiter can wake and try to relock a mutex belonging
to an event that has already been destroyed. Stop the reopen thread
first so abort_event stays valid for the lifetime of the
wait.
@quine00 quine00 force-pushed the alsa-reopen-race branch from 21b44c0 to 95056af Compare May 27, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/linux Categorizes issue or PR as affecting Linux specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants