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

test_sys_settrace leaked [6604, 6602, 6604] on main branch #94979

Closed
kumaraditya303 opened this issue Jul 18, 2022 · 5 comments
Closed

test_sys_settrace leaked [6604, 6602, 6604] on main branch #94979

kumaraditya303 opened this issue Jul 18, 2022 · 5 comments
Assignees
Labels
3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@kumaraditya303
Copy link
Contributor

Commit tested: a25a803

@kumaraditya303 ➜ /workspaces/cpython (main) $ ./python -m test -R 3:3 test_sys_settrace
0:00:00 load avg: 31.03 Run tests sequentially
0:00:00 load avg: 31.03 [1/1] test_sys_settrace
beginning 6 repetitions
123456
......
test_sys_settrace leaked [6604, 6602, 6604] references, sum=19810
test_sys_settrace leaked [1835, 1860, 1856] memory blocks, sum=5551
test_sys_settrace failed (reference leak)

== Tests result: FAILURE ==

1 test failed:
    test_sys_settrace

Total duration: 1.2 sec
Tests result: FAILURE
@kumaraditya303 kumaraditya303 added type-bug An unexpected behavior, bug, or error 3.12 bugs and security fixes labels Jul 18, 2022
@kumaraditya303
Copy link
Contributor Author

cc @markshannon @pablogsal

@kumaraditya303
Copy link
Contributor Author

Git bisect points to 2f8bff6 as first bad commit:

commit 2f8bff6879c5d76d143068e8bc867196a7d28afc (HEAD)
Author: Mark Shannon <mark@hotpy.org>
Date:   Mon Jul 18 16:06:42 2022 +0100

    GH-94739: Mark stacks of exception handling blocks for setting frame.f_lineno in the debugger. (GH-94958)

@mdboom
Copy link
Contributor

mdboom commented Jul 18, 2022

frame.setlineno strikes again.

@brandtbucher
Copy link
Member

Checking this out now.

@brandtbucher
Copy link
Member

brandtbucher commented Jul 18, 2022

The following three tests are leaking:

  • test_jump_from_except_to_finally
  • test_jump_out_of_bare_except_block
  • test_jump_out_of_qualified_except_block

The issue is when we jump out of an exception handler into non-exception-handling code. We skip over POP_EXCEPT, which is supposed to clear tstate->exc_info->exc_value, the currently active exception. This exception references thousands of objects through its traceback frames.

I'm not sure what a good solution is. Perhaps clearing the thread's exception state if we can detect that we're jumping out of an exception handler? I'm not sure if that's always correct (or even easy to detect). Maybe we can flag every stack between an exception handler entry and a POP_EXCEPT?

Or, just disallow jumping out of exception handlers like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants