Skip to content

Commit 861974b

Browse files
authored
gh-89455: Fix an uninitialized bool in exception print context. (#91466)
Fix an uninitialized bool in exception print context. `struct exception_print_context.need_close` was uninitialized. Found by oss-fuzz in a test case running under the undefined behavior sanitizer. https://oss-fuzz.com/testcase-detail/6217746058182656 ``` Python/pythonrun.c:1241:28: runtime error: load of value 253, which is not a valid value for type 'bool' #0 0xbf2203 in print_chained cpython3/Python/pythonrun.c:1241:28 #1 0xbea4bb in print_exception_cause_and_context cpython3/Python/pythonrun.c:1320:19 #2 0xbea4bb in print_exception_recursive cpython3/Python/pythonrun.c:1470:13 #3 0xbe9e39 in _PyErr_Display cpython3/Python/pythonrun.c:1517:9 ``` Pretty obvious what the ommission was upon code inspection.
1 parent 7acedd7 commit 861974b

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed an uninitialized bool value in the traceback printing code path that
2+
was introduced by the initial bpo-45292 exception groups work.

Python/pythonrun.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ _PyErr_Display(PyObject *file, PyObject *exception, PyObject *value, PyObject *t
15041504
struct exception_print_context ctx;
15051505
ctx.file = file;
15061506
ctx.exception_group_depth = 0;
1507+
ctx.need_close = false;
15071508
ctx.max_group_width = PyErr_MAX_GROUP_WIDTH;
15081509
ctx.max_group_depth = PyErr_MAX_GROUP_DEPTH;
15091510

0 commit comments

Comments
 (0)