Skip to content

test_remote_pdb hangs randomly #132912

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

Closed
vstinner opened this issue Apr 25, 2025 · 7 comments
Closed

test_remote_pdb hangs randomly #132912

vstinner opened this issue Apr 25, 2025 · 7 comments
Labels
3.14 new features, bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented Apr 25, 2025

Example on "Hypothesis tests on Ubuntu": https://github.com/python/cpython/actions/runs/14660752238/job/41144501229?pr=132906

(...)
0:46:29 load avg: 0.00 running (1): test_remote_pdb (43 min 3 sec)
0:46:59 load avg: 0.00 running (1): test_remote_pdb (43 min 33 sec)
0:47:29 load avg: 0.00 running (1): test_remote_pdb (44 min 3 sec)
0:47:59 load avg: 0.00 running (1): test_remote_pdb (44 min 33 sec)
0:48:29 load avg: 0.00 running (1): test_remote_pdb (45 min 3 sec)
0:48:59 load avg: 0.00 running (1): test_remote_pdb (45 min 33 sec)

Sadly, the "Hypothesis tests on Ubuntu" job has no timeout :-(

Linked PRs

vstinner added a commit to vstinner/cpython that referenced this issue Apr 25, 2025
@picnixz picnixz added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir 3.14 new features, bugs and security fixes infra CI, GitHub Actions, buildbots, Dependabot, etc. labels Apr 25, 2025
@picnixz
Copy link
Member

picnixz commented Apr 25, 2025

The test has been added in 797b29b (cc @pablogsal @godlygeek)

@vstinner
Copy link
Member Author

I reproduced an issue locally on Linux:

$ ./python -m test test_remote_pdb -v --forever -j10 --timeout=60
...
0:02:56 load avg: 7.49 [242/1] test_remote_pdb worker non-zero exit code (Exit code 1)
test_breakpoints (test.test_remote_pdb.PdbConnectTestCase.test_breakpoints)
Test setting and hitting breakpoints. ... ok
test_connect_and_basic_commands (test.test_remote_pdb.PdbConnectTestCase.test_connect_and_basic_commands)
Test connecting to a remote debugger and sending basic commands. ... ok
test_handle_eof (test.test_remote_pdb.PdbConnectTestCase.test_handle_eof)
Test that EOF signal properly exits the debugger. ... ok
test_help_system (test.test_remote_pdb.PdbConnectTestCase.test_help_system)
Test that the help system properly sends help text to the client. ... ok
test_keyboard_interrupt (test.test_remote_pdb.PdbConnectTestCase.test_keyboard_interrupt)
Test that sending keyboard interrupt breaks into pdb. ... Timeout (0:01:00)!
Thread 0x00007fc086c20780 [python] (most recent call first):
  File "/home/vstinner/python/main/Lib/subprocess.py", line 2019 in _try_wait
  File "/home/vstinner/python/main/Lib/subprocess.py", line 2061 in _wait
  File "/home/vstinner/python/main/Lib/subprocess.py", line 1275 in wait
  File "/home/vstinner/python/main/Lib/subprocess.py", line 1129 in __exit__
  File "/home/vstinner/python/main/Lib/test/test_remote_pdb.py", line 492 in test_keyboard_interrupt
  (...)
  File "/home/vstinner/python/main/Lib/runpy.py", line 198 in _run_module_as_main
...

@vstinner
Copy link
Member Author

The problem comes from the with process: statement. If a test fails, it waits until the process completes. But the child process does not complete, and so Python hangs.

@vstinner
Copy link
Member Author

With a local fix for with process:, I get an error message instead:

======================================================================
FAIL: test_keyboard_interrupt (test.test_remote_pdb.PdbConnectTestCase.test_keyboard_interrupt)
Test that sending keyboard interrupt breaks into pdb.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/test_remote_pdb.py", line 509, in test_keyboard_interrupt
    self.assertIn("bar()", interrupt_msg)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'bar()' not found in '> /home/vstinner/python/main/Lib/socket.py(855)create_connection()\n-> sock.connect(sa)\n'

@pablogsal
Copy link
Member

pablogsal commented Apr 25, 2025

I will take a look soon

vstinner added a commit to vstinner/cpython that referenced this issue Apr 25, 2025
If a test fails (such as an assertion error), kill the child process.
@vstinner
Copy link
Member Author

The problem comes from the with process: statement. If a test fails, it waits until the process completes. But the child process does not complete, and so Python hangs.

I wrote #132920 to prevent test_remote_pdb to hang: it kills the child process on error.

@picnixz picnixz removed the infra CI, GitHub Actions, buildbots, Dependabot, etc. label Apr 25, 2025
vstinner added a commit that referenced this issue Apr 25, 2025
If a test fails (such as an assertion error), kill the child process.
vstinner added a commit to vstinner/cpython that referenced this issue Apr 25, 2025
pablogsal added a commit to pablogsal/cpython that referenced this issue Apr 25, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 25, 2025
…2914)

(cherry picked from commit eb2e430)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit to vstinner/cpython that referenced this issue Apr 25, 2025
Replace hardcoded timeout of 5 seconds with SHORT_TIMEOUT.
vstinner added a commit that referenced this issue Apr 25, 2025
…#132937)

gh-132912: Set 15 min timeout on GHA Hypothesis CI (GH-132914)
(cherry picked from commit eb2e430)

Co-authored-by: Victor Stinner <vstinner@python.org>
pablogsal pushed a commit that referenced this issue Apr 25, 2025
Replace hardcoded timeout of 5 seconds with SHORT_TIMEOUT.
@vstinner
Copy link
Member Author

The root issue was fixed by 6cbeb6a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants