Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144068: fix JIT tracer memory leak when daemon thread exits#144077

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Fidget-Spinner merged 2 commits intopython:mainfromcocolato:fix_gh_144068
Jan 24, 2026
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletionsLib/test/test_capi/test_opt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3792,6 +3792,29 @@ def __next__(self):
"""), PYTHON_JIT="1", PYTHON_JIT_STRESS="1")
self.assertEqual(result[0].rc, 0, result)

def test_144068_daemon_thread_jit_cleanup(self):
result = script_helper.run_python_until_end('-c', textwrap.dedent("""
import threading
import time

def hot_loop():
end = time.time() + 5.0
while time.time() < end:
pass

# Create a daemon thread that will be abandoned at shutdown
t = threading.Thread(target=hot_loop, daemon=True)
t.start()

time.sleep(0.1)
"""), PYTHON_JIT="1", ASAN_OPTIONS="detect_leaks=1")
self.assertEqual(result[0].rc, 0, result)
stderr = result[0].err.decode('utf-8', errors='replace')
self.assertNotIn('LeakSanitizer', stderr,
f"Memory leak detected by ASan:\n{stderr}")
self.assertNotIn('_PyJit_TryInitializeTracing', stderr,
f"JIT tracer memory leak detected:\n{stderr}")

def global_identity(x):
return x

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fix JIT tracer memory leak, ensure the JIT tracer state is freed when daemon threads are cleaned up during interpreter shutdown.
4 changes: 4 additions & 0 deletionsPython/pystate.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1836,6 +1836,10 @@ PyThreadState_Clear(PyThreadState *tstate)

_PyThreadState_ClearMimallocHeaps(tstate);

#ifdef _Py_TIER2
_PyJit_TracerFree((_PyThreadStateImpl *)tstate);
#endif

tstate->_status.cleared = 1;

// XXX Call _PyThreadStateSwap(runtime, NULL) here if "current".
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp