Skip to content

Conversation

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Dec 11, 2025

This cleans up PRs #136104 and #135860. Fixing a refleak as well.

Mostly just moving code around.

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a separate PRs for fixing the leak? I'd like to get that in ASAP.

For the larger changes:

  • There is no need for _POP_TOP_NOT_NULL as it still needs to check for immortal objects and NULL is immortal
  • The changes to the code generator need more explanation and maybe a new issue.

assert(oparg == 1);
STAT_INC(CALL, hit);
PyObject *res_o = PySequence_Tuple(arg_o);
DEAD(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DEAD(null);

No need to declare null dead here as it will be handled by INPUTS_DEAD below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required so that ERROR_IF doesn't emit a useless close for it.

@bedevere-app
Copy link

bedevere-app bot commented Dec 12, 2025

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@Fidget-Spinner
Copy link
Member Author

Can you make a separate PRs for fixing the leak? I'd like to get that in ASAP.

I can't without a partial revert. The problem is that we don't allow live inputs at ERROR_IF. This PR simply changes the ERROR_IF behavior to close all live inputs.

The rest of this PR to the cases generator is just moving stuff around if you take a closer look. I mainly had to expose the close_variable function as it was previously a nested one.

@Zheaoli
Copy link
Contributor

Zheaoli commented Dec 12, 2025

Just for personal thought(correct me plz if I'm wrong)

The root cause about this refleak is related with the wrong position about ERROR_IF. In this case, in old generated code, the arg will leak after ERROR_IF

So the core point about this PR is the behavior change "raise an exception when here's live variable on TOS -> close all the live variable"

So we can mark the stack INPUT_DEAD safety after ERROR_IF after this PR

@Fidget-Spinner
Copy link
Member Author

@Zheaoli yes you're right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants