Commit 97e123e
fix(windows): eliminate three kernel-wedge deadlock vectors
A prior clx-rust.exe instance (PID 7580) ran for 3 days and could not be
killed by taskkill or elevated Stop-Process, requiring a reboot. Analysis
of the Windows adapter found three places where a user-space lock or a
slow Win32/Tauri call could stall a thread inside an unabortable kernel
wait and leave the process unkillable.
1. core/audio_capture.rs: replace Arc<Mutex<Vec<f32>>> with a lock-free
SPSC HeapRb ring. The cpal input callback thread no longer blocks on
a user-space Mutex, so a consumer holding the lock across slow I/O
can't stall the audio thread into an unjoinable state when the stream
is later paused or dropped.
2. adapters/windows/src/hook.rs: spawn a dedicated clx-tray-worker thread
owning all update_tray_icon / cursor_visibility::enable|disable calls,
fed by an mpsc::Sender<bool>. The WH_KEYBOARD_LL callback now only
does a non-blocking tx.send on mode edges - no Tauri calls, no
SystemParametersInfoW, no GUI locks touched from the hook. Also moves
cursor_visibility::nudge out of the hook callback into tick_timer_proc
(16 ms SetTimer) so the hook stays well under the ~300 ms budget.
3. adapters/windows/src/main.rs: the quit-watch thread now polls
WaitForSingleObject with a 500 ms timeout and checks a SHUTDOWN
AtomicBool set at end of main, instead of blocking INFINITE. This
lets the thread exit cleanly during normal shutdown rather than
sitting in a kernel wait forever.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7124806 commit 97e123e
5 files changed
Lines changed: 136 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
33 | 67 | | |
34 | 68 | | |
35 | 69 | | |
| |||
86 | 120 | | |
87 | 121 | | |
88 | 122 | | |
89 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
90 | 127 | | |
91 | 128 | | |
92 | 129 | | |
93 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
94 | 135 | | |
95 | 136 | | |
96 | 137 | | |
| |||
144 | 185 | | |
145 | 186 | | |
146 | 187 | | |
147 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
148 | 192 | | |
149 | 193 | | |
150 | 194 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 195 | + | |
| 196 | + | |
156 | 197 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | 198 | | |
161 | 199 | | |
162 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
| |||
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | 160 | | |
| |||
160 | 173 | | |
161 | 174 | | |
162 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
163 | 179 | | |
164 | 180 | | |
165 | 181 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
176 | 204 | | |
177 | 205 | | |
178 | 206 | | |
| |||
239 | 267 | | |
240 | 268 | | |
241 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
242 | 273 | | |
243 | 274 | | |
244 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
| |||
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
16 | | - | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| |||
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
67 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
68 | 82 | | |
69 | 83 | | |
70 | | - | |
71 | 84 | | |
| 85 | + | |
72 | 86 | | |
73 | 87 | | |
74 | 88 | | |
| |||
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
80 | | - | |
81 | 94 | | |
82 | | - | |
| 95 | + | |
83 | 96 | | |
84 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
85 | 101 | | |
86 | 102 | | |
87 | | - | |
| 103 | + | |
88 | 104 | | |
| 105 | + | |
89 | 106 | | |
90 | 107 | | |
91 | 108 | | |
| |||
95 | 112 | | |
96 | 113 | | |
97 | 114 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 115 | | |
102 | 116 | | |
103 | | - | |
| 117 | + | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
| |||
113 | 127 | | |
114 | 128 | | |
115 | 129 | | |
116 | | - | |
117 | 130 | | |
118 | 131 | | |
119 | 132 | | |
| |||
126 | 139 | | |
127 | 140 | | |
128 | 141 | | |
129 | | - | |
130 | 142 | | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
134 | | - | |
135 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
136 | 155 | | |
137 | 156 | | |
138 | 157 | | |
| |||
0 commit comments