Repository navigation
test: Wait for the PipeWire loop thread before the teardown test stops it - #3593
Merged
Merged
Conversation
…s it pw_thread_loop_stop() can hang when it runs before the loop thread has entered the loop. Invoke then runs do_stop on the caller, and nothing wakes the loop thread if it is on its way into epoll_wait. Ask for PipeWire's start signal and wait for it, and drop the test from the asan known list. Fixes #3577 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #3577 Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=6ca91016186f4c28dc34f928fccab976cb6495dc secs=269 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1793744255,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9b162236985d802117c4a38aace7c47f603fc690a73eba7d37e66f3288133eff","lane":"lint","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":34,"stamp":"12aba21771c2fbd75546c20dde84cfd4","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9b162236985d802117c4a38aace7c47f603fc690a73eba7d37e66f3288133eff","lane":"lint","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":34,"stamp":"3b525dbe90040e1b5f290e9264a2d642","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8c5a69b63160fdd6c82bf71a44ebd412abded44b7969eedf65c3ff3ad442b916","lane":"rust-test","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":83,"stamp":"ce807bda133d5d0620388f20cb9457a4","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"1e7d3c70550159cfc3d53587e55902336ec073a2402c81969389c9f4da5f4414","lane":"cross","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":24,"stamp":"e600f320406f97a2e3b23aa68f1e6cb6","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"1e7d3c70550159cfc3d53587e55902336ec073a2402c81969389c9f4da5f4414","lane":"cross","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":24,"stamp":"15d39231417456c9a2afe84ce64d5b31","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"1e7d3c70550159cfc3d53587e55902336ec073a2402c81969389c9f4da5f4414","lane":"cross","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":24,"stamp":"c6ee3eef6d2f35a453cbb99a65eeaf46","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"1e7d3c70550159cfc3d53587e55902336ec073a2402c81969389c9f4da5f4414","lane":"cross","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":24,"stamp":"36750d4ef4da7df1d7cbb31ac85738e0","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"} Ci-Attestation: {"at":1793744255,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"e505db2a69ec37c4c49b3649d0b5c77e58d4aea9aeb01653d69d98628212be15","lane":"tier2-linux","parents":["54b197cee0f2c691517e267558098a28844a98de"],"secs":269,"stamp":"197e1affded4d06cde3693392b0c6de5","tree":"6ca91016186f4c28dc34f928fccab976cb6495dc","v":1,"via":"run"}
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.
What changed
test_pipewire_teardown_waitnow creates its loop withthread-loop.start-signaland waits for that signal before it stops the loop. The test leaves the asan known list, andKNOWN_ENTRIESgoes from 5 to 4.New concept
docs/knowledge/pipewire-stop-after-start.md.Cause
This is a race in PipeWire (1.6.2, from reading its source):
pw_thread_loop_stop()callspw_loop_invoke(do_stop).loop_queue_invoke()readsimpl->threadwith no lock. If it is still 0, it treats the caller as the loop thread, sodo_stopruns on the caller, with no wakeup.runningstill true, and goes intoepoll_wait.running = falseand waits inpthread_join. Nothing wakes the loop thread.A stack of the hang shows the main thread in
pthread_joinunderpw_thread_loop_stop, and the loop thread inepoll_wait. Attachinggdbended the hang, because the interruptedepoll_waitlets the loop thread see the flag.The loop thread sends the start signal after it has entered the loop, so a stop after that signal takes the normal path.
RED and GREEN
ASan build, 48 copies at a time, with 24 CPU hogs:
pw_loop_invokefirst (not this PR: it takes the same path)On CI, the test hit the 10-minute limit in 2 of 13 asan jobs.
Test cost: no new test. The wait adds only the thread start.
Not in this PR
obs_pipewire_connect_fd()has the same race on itsfail:path, whenpw_context_connect_fd()fails right after the start. I did not reproduce that. A fix needs care, because the wait does not return on a PipeWire version that does not have this option.Fixes #3577
🤖 Generated with Claude Code