Commit 3e3f941
Fix UAF crash from dangling output signal handlers (#1716)
* Fix UAF crash from dangling output signal handlers
osn::Output connected the "stop" handler and per-signal
OutputSignalCallback (each with a heap CallbackData carrying `this`)
but never disconnected them or freed the CallbackData. When the
underlying obs_output_t outlived the wrapper -- delay buffer, reconnect,
or a shared SetOutput ref -- a later signal fired into freed
CallbackData/this, crashing in signal_handler_signal (seen in Sentry as
EXCEPTION_ILLEGAL_INSTRUCTION via ISimpleReplayBuffer::Stop ->
obs_output_stop). Heavy start/stop churn (e.g. recording repeatedly
failing to write) widened the window.
- Add DisconnectSignals(): disconnects OnStopped and every
OutputSignalCallback, then frees the CallbackData (also fixes the
pre-existing leak).
- Track allocated CallbackData in m_signalCallbackData.
- Promote the anonymous "stop" lambda to a named static OnStopped so it
has a stable address to disconnect.
- Call DisconnectSignals() in DeleteOutput after the stop-wait and before
obs_output_release, so OnStopped stays live during the wait and no
connection survives the release.
All output types tear down through DeleteOutput (Simple/Advanced ->
Streaming/Recording/ReplayBuffer dtors, plus CreateOutput/SetOutput
recreate), so this covers every path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Make ConnectSignals private
Only called internally from InitOutput; addresses review feedback.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent fb1658d commit 3e3f941
2 files changed
Lines changed: 51 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 23 | | |
33 | 24 | | |
34 | 25 | | |
| |||
40 | 31 | | |
41 | 32 | | |
42 | 33 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 34 | | |
51 | | - | |
| 35 | + | |
52 | 36 | | |
53 | 37 | | |
54 | 38 | | |
55 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
56 | 48 | | |
57 | 49 | | |
58 | 50 | | |
| |||
89 | 81 | | |
90 | 82 | | |
91 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
97 | 95 | | |
98 | | - | |
| 96 | + | |
99 | 97 | | |
100 | 98 | | |
101 | 99 | | |
| |||
122 | 120 | | |
123 | 121 | | |
124 | 122 | | |
| 123 | + | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
129 | 145 | | |
130 | 146 | | |
131 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
66 | 73 | | |
67 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
68 | 83 | | |
69 | 84 | | |
70 | 85 | | |
| |||
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
0 commit comments