gh-146442: Fix various bugs in compiler pipeline from bug report#146443
gh-146442: Fix various bugs in compiler pipeline from bug report#146443vstinner merged 4 commits intopython:mainfrom
Conversation
vstinner
left a comment
There was a problem hiding this comment.
LGTM
// NOTE: ref of mangled can be leaked on ADDOP* and VISIT macros due to early returns
// fixing would require an overhaul of these macros
That's unfortunate, but this change already fix multiple issues and is worth it. The issues described in the comment can be fixed in a follow-up change is someone is interested.
| _Py_DECLARE_STR(format, ".format"); | ||
| ADDOP_I(c, loc, LOAD_FAST, 0); | ||
| ADDOP_LOAD_CONST(c, loc, value_with_fake_globals); | ||
| ADDOP_LOAD_CONST_NEW(c, loc, value_with_fake_globals); |
There was a problem hiding this comment.
That's a real bugfix, but in practice _Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS=2 which is an immortal small integer, and so refcount is not really an issue. It's not worth it to backport this change in practice.
|
Merged, thanks for your fixes. |
Would the preferred approach here be to introduce the same macros but accepting an object to DecRef. Similar to how some of the other existing do? |
|
You may move to a subfunction and DECREF(mangled) if the subfunction fails. |
|
Ah ok, I can raise the issue and work on the refactor over the next couple days. |
* main: pythongh-145458: use `self.skip_idle` consistently in the tachyon profiler (python#145459) pythongh-146615: Fix format specifiers in Objects/ directory (pythonGH-146620) pythongh-146615: Fix format specifiers in Python/ directory (pythonGH-146619) pythongh-146615: Fix format specifiers in test cextensions (pythonGH-146618) pythongh-146615: Fix format specifiers in extension modules (pythonGH-146617) pythongh-146615: Fix crash in __get__() for METH_METHOD descriptors with invalid type argument (pythonGH-146634) pythongh-146376: Reduce timeout in Emscripten GHA workflow (python#146378) pythongh-146442: Fix various bugs in compiler pipeline (python#146443) pythongh-146238: Support half-floats in the array module (python#146242) pythongh-145056: Add support for merging collections.UserDict and frozendict (pythonGH-146465) pythongh-145056: Fix merging of collections.OrderedDict and frozendict (pythonGH-146466) pythongh-139633: Run netrc file permission check only once per parse (pythonGH-139634)
Compiler Pipeline (codegen + compile + symtable + flowgraph + assemble) | 6 FIX
codegen.c (6,632 lines) — 4 FIX
codegen_setup_annotations_scope(line 716-720):PyLong_FromLongresult not NULL-checked, passed toADDOP_LOAD_CONSTwhich dereferences it. Also never DECREF'd even on success.mangledincodegen_nameop(line 3280):RETURN_IF_ERROR(scope)early-returns without DECREF'ingmangledfrom_PyCompile_MaybeMangle._PyCompile_PushFBlockincodegen_unwind_fblock_stack(line 669): Return value silently discarded, error lost, frame block stack left inconsistent.compile.c (1,772 lines) — 1 FIX
origin_PyCompile_TweakInlinedComprehensionScopes(line 1096-1114):PyDict_GetItemRefreturns new ref inorig, never DECREF'd on any path (success or error). Leaks on every inlined comprehension.assemble.c (802 lines) — 1 FIX
assemble_emit_instrreturns ERROR without exception (line 420-421): Bytecode overflow check returns ERROR withoutPyErr_NoMemory()→ SystemError.symtable.c (3,355 lines) — 0 FIX (clean)
flowgraph.c (4,088 lines) — 0 FIX (clean)
Did not fix
mangledincodegen_deferred_annotations_body(line 792-818)