Skip to content

Commit d9b8d13

Browse files
committed
gh-144766: Fix flaky test_trampoline_works_with_forks
The fork child ran full Python finalization instead of calling os._exit(0), which is fragile when perf trampoline support is active (unmapping executable memory and unregistering code watchers during finalization can crash intermittently). The newer test added in the same file (test_trampoline_works_after_fork_with_many_code_objects) already uses os._exit(0) for this reason. Also fix the parent's wait status handling: os.waitpid returns a raw wait status, not an exit code. Use os.WEXITSTATUS to extract the actual exit code, and check os.WIFSIGNALED for signal deaths. <claude>
1 parent cb76ab3 commit d9b8d13

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ def foo():
118118
if pid == 0:
119119
print(os.getpid())
120120
baz_fork()
121+
os._exit(0)
121122
else:
122123
_, status = os.waitpid(-1, 0)
123-
sys.exit(status)
124+
if os.WIFSIGNALED(status):
125+
sys.exit(1)
126+
sys.exit(os.WEXITSTATUS(status))
124127
125128
def bar():
126129
foo()

0 commit comments

Comments
 (0)