Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-151022: Fix remote debugging linetable reads#151036
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9b0f3ba2b79b7c464aedbbaec3c9File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -438,6 +438,56 @@ def _extract_coroutine_stacks_lineno_only(self, stack_trace): | ||
| # ============================================================================ | ||
| @requires_remote_subprocess_debugging() | ||
| class TestSelfStackTrace(RemoteInspectionTestBase): | ||
| @skip_if_not_supported | ||
| @unittest.skipIf( | ||
| sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED, | ||
| "Test only runs on Linux with process_vm_readv support", | ||
| ) | ||
| def test_self_trace_with_large_linetable(self): | ||
| script = textwrap.dedent("""\ | ||
| import os | ||
| import _remote_debugging | ||
| assignments = "\\n".join( | ||
| f"value_{i} = {i}" for i in range(1000) | ||
| ) | ||
| expected_lineno = len(assignments.splitlines()) + 1 | ||
| source = ( | ||
| f"{assignments}\\n" | ||
| "stack_trace = " | ||
| "_remote_debugging.RemoteUnwinder(os.getpid()).get_stack_trace()\\n" | ||
| ) | ||
| code = compile(source, "large_linetable.py", "exec") | ||
| assert len(code.co_linetable) > 4096, len(code.co_linetable) | ||
| namespace = {"os": os, "_remote_debugging": _remote_debugging} | ||
| exec(code, namespace) | ||
| large_linetable_frames = [ | ||
| frame | ||
| for interpreter in namespace["stack_trace"] | ||
| for thread in interpreter.threads | ||
| for frame in thread.frame_info | ||
| if frame.filename == "large_linetable.py" | ||
| ] | ||
| assert len(large_linetable_frames) == 1, large_linetable_frames | ||
| assert large_linetable_frames[0].location.lineno == expected_lineno, ( | ||
| large_linetable_frames[0] | ||
| ) | ||
| """) | ||
| result = subprocess.run( | ||
| [sys.executable, "-c", script], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=SHORT_TIMEOUT, | ||
| ) | ||
| self.assertEqual( | ||
| result.returncode, 0, | ||
| f"stdout: {result.stdout}\nstderr: {result.stderr}" | ||
Comment on lines
+485
to
+487
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @goutamadwant It would be interesting to ensure that the returned linetable is also correct, not Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maurycy Updated this too. The test now checks the returned frame for large_linetable.py and asserts the resolved line number matches the generated RemoteUnwinder call line, so it should catch the -1 fallback case. | ||
| ) | ||
| @requires_remote_subprocess_debugging() | ||
| class TestGetStackTrace(RemoteInspectionTestBase): | ||
| @skip_if_not_supported | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix ``_remote_debugging`` stack traces for code objects with large line | ||
| tables. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goutamadwant I think there's a missing
@requires_remote_subprocess_debugging()decorator :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed @maurycy.. added the missing @requires_remote_subprocess_debugging() decorator to the new test class.