Repository navigation
sys.audit(0) aborts due to an assertion in debug build #126018
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirinterpreter-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
Description
Activity
- addedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
on Oct 26, 2024 - addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)extension-modulesC modules in the Modules dirC modules in the Modules dir
on Oct 26, 2024 - added3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes
on Oct 26, 2024 Ok, 3.12 is actually not affected:
Lines 499 to 514 in 67b2701
if (!should_audit(tstate->interp)) { Py_RETURN_NONE; } PyObject *auditEvent = args[0]; if (!auditEvent) { _PyErr_SetString(tstate, PyExc_TypeError, "expected str for argument 'event'"); return NULL; } if (!PyUnicode_Check(auditEvent)) { _PyErr_Format(tstate, PyExc_TypeError, "expected str for argument 'event', not %.200s", Py_TYPE(auditEvent)->tp_name); return NULL; } - added a commit that references this issue
on Oct 27, 2024 - added a commit that references this issue
on Oct 27, 2024 Closing since completed and backported. Thanks!
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirinterpreter-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
Crash report
What happened?
There is an assert in
sysmodule.cthat makes the interpreter abort when callingsys.auditwith a non-string value in debug builds:cpython/Python/sysmodule.c
Line 522 in f6cc7c8
This assert seems completely unnecessary, as the code that runs the hooks (which only triggers if there is some hook registered) will raise an exception if the first argument to
sys.auditisn't a string:I'll submit a trivial PR removing this assert.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, Windows
Output from running 'python -VV' on the command line:
Python 3.14.0a1+ (heads/main:c5b99f5c2c, Oct 26 2024, 12:35:53) [GCC 13.2.0]
Linked PRs
sys.audit#126020sys.audit(GH-126020) #126042