-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
[3.13] gh-134163: fix: exec('_testcapi.set_nomemory(0)') hang in new repl 3.13 #138491
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
Changes from 28 commits
1202ec6
4cd38e8
e557017
53f713c
9cc89f1
a9b6f96
66ec42e
a9e6b64
791ca86
4827680
8ec5769
edcfff7
81c6244
847bd7b
ff3c7f4
175a13e
d952d53
5fa3a1b
d3274fb
c89c5b5
63a6b7d
977703f
095f865
932c15e
52310f0
bb790af
06b779a
30cd34d
26ce31b
5ab08c7
789040c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,36 @@ def test_no_memory(self): | |
# Exit code 120: Py_FinalizeEx() failed to flush stdout and stderr. | ||
self.assertIn(p.returncode, (1, 120)) | ||
|
||
@cpython_only | ||
# Python built with Py_TRACE_REFS fail with a fatal error in | ||
# _PyRefchain_Trace() on memory allocation error. | ||
@unittest.skipIf(support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build') | ||
def test_exec_set_nomemory_hang(self): | ||
import_module("_testcapi") | ||
# gh-134163: Test case that triggers no memory hang condition | ||
# The frame_lasti need to upper 257, | ||
# because when calling PyLong_FromLong, malloc is not invoked, | ||
# so no MemError is triggered | ||
# we need to warm up the memory to reproduce the issue | ||
warmup_code = "a = list(range(0, 1))\n" * 20 | ||
user_input = warmup_code + dedent(""" | ||
try: | ||
import _testcapi | ||
_testcapi.set_nomemory(0) | ||
b = list(range(1000, 2000)) | ||
except Exception as e: | ||
import traceback | ||
traceback.print_exc() | ||
""") | ||
p = spawn_repl() | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
with SuppressCrashReport(): | ||
p.stdin.write(user_input) | ||
|
||
output = kill_python(p) | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
self.assertIn(p.returncode, (0, 1, 120)) | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
self.assertGreater(len(output), 0) # At minimum, should not hang | ||
self.assertIn("MemoryError", output) | ||
|
||
@cpython_only | ||
def test_multiline_string_parsing(self): | ||
# bpo-39209: Multiline string tokens need to be handled in the tokenizer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a hang when the process is out of memory inside an exception handler. |
Uh oh!
There was an error while loading. Please reload this page.