Commit 88b484b
Fix volmeter use-after-free on audio thread during teardown
The volmeter held only a weak reference to its attached source. When the
source was concurrently going to refcount 0, obs_volmeter_detach_source's
weak->strong upgrade returned NULL and it skipped
obs_source_remove_audio_capture_callback, leaving a dangling
{volmeter_source_data_received, freed-volmeter} entry in the source's
audio_cb_list. The WASAPI RT capture thread could then call into the freed
volmeter before obs_source_destroy frees that list, crashing in
signal_levels_updated (EXCEPTION_ACCESS_VIOLATION_EXEC) or the peak path
(EXCEPTION_ACCESS_VIOLATION_READ).
Hold a strong reference to the attached source for the lifetime of the
attachment (via findAndRef), released only after detach. The source can no
longer reach refcount 0 while attached, so the detach always removes the
audio capture callback before the volmeter is freed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1c54906 commit 88b484b
2 files changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
0 commit comments