Commit 5aaebab
fix(logger): eliminate deadlock and data race in set_config()
FileLogger and UniqueFileLogger set_config() held m_mutex while calling
executor->wait(), but async tasks in those executors also acquire m_mutex
to perform write_log(). This caused a deadlock when a pending task tried
to lock m_mutex while set_config() was waiting for it under the same lock.
Additionally, set_config() did not take m_lifecycle_mutex, so log() could
read m_config/m_executor while they were being modified -> use-after-move /
data race.
Fix:
- set_config() now takes m_lifecycle_mutex first to serialize with log().
- executor->wait() is called WITHOUT holding m_mutex, removing the deadlock.
- FileLogger flushes m_file under a brief m_mutex scope after the wait.
- m_config/m_executor mutations remain under m_mutex for consistency.
- old_executor->shutdown() is still performed outside all locks.
Scope-risk: moderate (fixes a deadlock introduced in the same PR chain)
Confidence: high
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent d747734 commit 5aaebab
2 files changed
Lines changed: 40 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
| 216 | + | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
222 | 227 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
230 | 244 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
177 | 187 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
| |||
0 commit comments