PipeWire: dropping callback captures on the realtime worker can terminate the process with SIGXCPU
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Start in src/host/pipewire/device.rs around the output worker's mainloop.run() and drop(listener) sequence, then read the realtime promotion and stream shutdown paths in rt_promote.rs and stream.rs. Investigate how callback captures are destroyed and whether teardown can leave the worker realtime-promoted. Done means normal stream shutdown no longer triggers SIGXCPU when a callback owns a large PCM allocation, with a regression test or reproduction covering teardown.
索引モデルが issue の本文から書いたものです。
説明
Summary
With CPAL 0.18.2's native PipeWire host and realtime-dbus, normal stream shutdown can terminate the entire process with SIGXCPU when destroying a data callback frees a large PCM allocation.
Playback was running before shutdown. The failing thread is in callback/renderer destruction after the PipeWire main loop returns, while the application thread is joining that worker in Stream::drop.
Environment
- Arch Linux / Omarchy, x86_64; running kernel
7.3.6-5-omarchy - CPAL
0.18.2, crates.io, featurespipewireandrealtime-dbus - Packaged VCS revision:
e1612d5d98152f8dc2a62e1b51ef7cbf4f7f26b7 audio_thread_priority 0.35.1- PipeWire / libpipewire
1.6.12-1, WirePlumber0.5.19-1 - rtkit
0.14-2, service active - glibc
2.44+r78+gfcfb867c58ab-1 - Native PipeWire output to local null/remap sinks; requested buffer duration 10 ms
The relevant CPAL source files (device.rs, stream.rs, and rt_promote.rs) were compared byte-for-byte against the cached crates.io archive and match. The archive SHA-256 matches the Cargo.lock checksum.
Trigger observed in the application
- Build an output stream with CPAL's native PipeWire host and realtime promotion enabled.
- Let the data callback own a renderer containing a large decoded
Vec<f32>. - Run playback, then ask the application to shut down normally. The test sends SIGINT, which the application's shutdown handler uses to call its audio finish routine and drop the stream.
- The main thread waits in CPAL's
Stream::drop. Thepw_outworker drops the listener and captured renderer/PCM, and the process receives SIGXCPU.
This was observed in two separate host/guest test runs: four processes total, at 16:55:57 and 17:01:05 CST on 2026-12-03. In the shorter teardown reproduction, both processes returned -24 (SIGXCPU), and neither wrote its final audio summary.
This is an application-level reproduction, not a standalone reduced test case.
Core-dump evidence
The core reports SIGXCPU, si_code = SI_KERNEL (128), delivered to the pw_out thread.
Symbolized stack, with template/inlining noise removed:
pw_out:
munmap
_int_free_chunk
alloc::alloc::dealloc_nonnull
RawVec<f32>::drop
Vec<f32>::drop
lmp::media::Pcm::drop
lmp::audio::Renderer::drop
[data callback capture / UserData / ListenerLocalCallbacks destruction]
core::mem::drop<pipewire::stream::StreamListener<...>>
cpal::host::pipewire::device::build_output_stream_raw::{closure}
src/host/pipewire/device.rs:662
main thread:
pthread_join
std::thread::JoinHandle::join
cpal::host::pipewire::stream::Stream::drop
src/host/pipewire/stream.rs:123
lmp::audio::finish
At munmap, the x86_64 argument register rsi was 0x20001000 (536,875,008 bytes, approximately 512 MiB).
The test saved /proc/<pid>/limits immediately before requesting shutdown:
Max realtime timeout 5333 200000 us
Ordinary CPU time was unlimited. In coredump metadata the realtime soft limit was 1005333 us; this is consistent with Linux increasing it by one second after sending SIGXCPU. No OOM-kill records were found around these crashes.
Suspected mechanism and possible direction
The evidence strongly suggests that PCM deallocation exceeded the realtime allowance during teardown.
In the released output worker, mainloop.run() is followed immediately by drop(listener). The listener owns the callback captures. RtPromoter requests promotion through audio_thread_priority, but the inspected teardown path does not restore normal scheduling before destroying those captures.
Would it make sense to restore the worker's prior scheduling policy before dropping the listener and callbacks, or otherwise arrange for callback captures to be destroyed off the realtime worker? This is a proposed direction, not a tested CPAL fix.
An application-level workaround is to keep a separate PCM owner alive until the audio worker has fully exited, so the large allocation is freed on a normal thread.
I also inspected current master: its output worker still calls drop(listener) directly after mainloop.run(). I have not built or reproduced this against master.
Related but apparently different: #1193 concerned ALSA routed through PulseAudio during active processing; this report concerns native PipeWire callback destruction on shutdown.
Only sanitized stack/limit excerpts are included; no core dump or process memory is attached.
Filed with OpenAI Codex assistance.
- 主要言語
- Rust
- スター
- 4k
- フォーク
- 554
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustAudio/cpal のほかの issue
-
API design
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
correctness
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)対応中かも @dannyward630 が 39 日前に担当しました。 オープンhost - aaudio platform - android
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
-
WebAudio wasm build fails with wasm-bindgen panic=unwind closures対応中かも @bogusyogi が 48 日前に担当しました。 オープンhost - webaudio platform - web
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
WebAudio: after a main-thread stall, playback runs at 2x speed until the time cursor catches upオープンhost - webaudio platform - web
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
ci: migrate pinned macos-15 runners to macos-26 and macos-26-intel対応中かも @hawkingrei が今日担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
nowledge-co/hawdb#2224 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
eclipse-score/coverage_tool#95 ·
メンテナーはふだん 2 日以内に返信
-
bug nvim
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100