Skip to content
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

frame.setlineno has serious flaws. #94438

Open
1 of 3 tasks
markshannon opened this issue Jun 30, 2022 · 0 comments
Open
1 of 3 tasks

frame.setlineno has serious flaws. #94438

markshannon opened this issue Jun 30, 2022 · 0 comments
Assignees
Labels
3.11 3.12 deferred-blocker type-crash

Comments

@markshannon
Copy link
Member

@markshannon markshannon commented Jun 30, 2022

The frame_setlineno function works in in stages:

  • Determine a set of possible bytecode offsets as targets from the line number.
  • Compute the stack state for these targets and the current position
  • Determine a best target. That is, the first one that has a compatible stack.
  • Pop values form the stack and jump.

The first steps is faulty (I think, I haven't demonstrated this) as it might be possible to jump to an instruction involved in frame creation. This should be easy to fix using the new _co_firsttraceable field.

The second step has (at least) three flaws:

  • It does not account for NULLs on the stack, making it possible to jump from a stack with NULLs to one that cannot handle NULLs.
  • It does not skip over caches, so could produce incorrect stacks by misinterpreting cache entries as normal instructions.
  • It is out of date. For example it thinks that PUSH_EXC_INFO pushes three values. It only pushes one.

Setting the line number of a frame is only possible in the debugger, so this isn't as terrible as might appear, but it definitely needs fixing.

@markshannon markshannon added type-crash deferred-blocker labels Jun 30, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 1, 2022
…nes. (pythonGH-94444)

(cherry picked from commit be80db14c432c621e44920f8fd95a3f3191aca9b)

Co-authored-by: Mark Shannon <mark@hotpy.org>
markshannon added a commit that referenced this issue Jul 1, 2022
* Account for NULLs on evaluation stack when jumping lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 3.12 deferred-blocker type-crash
Projects
Status: No status
Development

No branches or pull requests

2 participants