Repository navigation
atexit.unregister() can remove wrong callback #142881
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes
on Dec 17, 2025 @ZeroIntensity
extension-modulesReacted by Peter Bierma- addedextension-modulesC modules in the Modules dirC modules in the Modules dir
on Dec 17, 2025 - added a commit that references this issue
on Jan 12, 2026 3.13 required completely different solution than 3.14+.
- added a commit that references this issue
on Jan 12, 2026 - added a commit that references this issue
on Jan 12, 2026
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
atexit.unregister()can call the user__eq__()when it searches the callback(s) to remove. If__eq__()returns true, the callback is removed by index. But__eq__()can call arbitrary code, it can release the GIL, andatexit.unregister()can be called in other thread. If it removes the callback at the current index or before current index, the current index will no point to the compared callable, and the following deletion will delete wrong callable.This issue is similar to #112127, but causes different symptoms.
Linked PRs