Commit 6b62522
committed
gh-150818: Wire logger parent before publishing it
getLogger() returns existing loggers through a lock-free fast path that
reads loggerDict without the lock (added in GH-150825). The slow path
inserted a freshly created logger into loggerDict before _fixupParents()
assigned its parent, so a concurrent caller could fetch a logger whose
parent was still None and see it detached from the hierarchy:
getEffectiveLevel() returns NOTSET and records do not propagate until the
creating thread finishes.
Publish the logger only after its parent and children are wired. Neither
_fixupParents() nor _fixupChildren() reads loggerDict[name], so the
reorder is safe; the fast path is unchanged and confined to the locked
creation path taken once per logger.1 parent e833f57 commit 6b62522
2 files changed
Lines changed: 46 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1377 | 1377 | | |
1378 | 1378 | | |
1379 | 1379 | | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
1383 | 1384 | | |
1384 | 1385 | | |
1385 | 1386 | | |
| |||
1390 | 1391 | | |
1391 | 1392 | | |
1392 | 1393 | | |
1393 | | - | |
1394 | 1394 | | |
1395 | 1395 | | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1396 | 1399 | | |
1397 | 1400 | | |
1398 | 1401 | | |
1399 | | - | |
1400 | 1402 | | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1401 | 1406 | | |
1402 | 1407 | | |
1403 | 1408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4269 | 4269 | | |
4270 | 4270 | | |
4271 | 4271 | | |
| 4272 | + | |
| 4273 | + | |
| 4274 | + | |
| 4275 | + | |
| 4276 | + | |
| 4277 | + | |
| 4278 | + | |
| 4279 | + | |
| 4280 | + | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
| 4284 | + | |
| 4285 | + | |
| 4286 | + | |
| 4287 | + | |
| 4288 | + | |
| 4289 | + | |
| 4290 | + | |
| 4291 | + | |
| 4292 | + | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
4272 | 4308 | | |
4273 | 4309 | | |
4274 | 4310 | | |
| |||
0 commit comments