8000 gh-128632: fix segfault on nested __classdict__ type param by tom-pytel · Pull Request #128744 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128632: fix segfault on nested __classdict__ type param #128744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
requested comment changes
  • Loading branch information
tom-pytel committed Jan 12, 2025
commit 4d736e9d0d9dd7b4eecdd6982749ec2fa0c7b3a5
3 changes: 3 additions & 0 deletions Python/assemble.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
assert(offset >= 0);
offset += nlocals - numdropped;
assert(offset < nlocalsplus);
/* XXX If the assertion below fails it is most likely because a freevar
was added to u_freevars with the wrong index due to not taking into
account cellvars already present, see gh-128632. */
assert(offset > cellvar_offset);
_Py_set_localsplus_info(offset, k, CO_FAST_FREE, names, kinds);
}
Expand Down
3 changes: 0 additions & 3 deletions Python/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3065,9 +3065,6 @@ codegen_addop_yield(compiler *c, location loc) {
return SUCCESS;
}

/* XXX: Currently if this is used to insert a new name into u_freevars when
there are already entries in u_cellvars then the wrong index will be put
into u_freevars causing a hard error downstream. */
static int
codegen_load_classdict_freevar(compiler *c, location loc)
{
Expand Down
3 changes: 0 additions & 3 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,6 @@ _PyCompile_ResolveNameop(compiler *c, PyObject *mangled, int scope,
break;
}
if (*optype != COMPILE_OP_FAST) {
/* XXX: Currently if this is used to insert a new name into u_freevars when
there are already entries in u_cellvars then the wrong index will be put
into u_freevars causing a hard error downstream. */
*arg = _PyCompile_DictAddObj(dict, mangled);
RETURN_IF_ERROR(*arg);
}
Expand Down
Loading
0