-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
classmethod and staticmethod can crash with NULL / uninitialized callables #144330
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Fields
Give feedbackNo fields configured for issues without a type.
Crash report
The following code crashes in a debug build:
Or equivalently:
The problem is that
sm_callable/cm_callablefields are only initialized in the__init__function and not all code (like the repr) handles the NULL case.Additionally, even though
__func__isn't writable, you can modify it by calling__init__on an already initialized staticmethod or classmethod.Linked PRs