Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Jan 19, 2025

tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(), PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check tracemalloc_config.tracing after calling TABLES_LOCK().

_PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(), especially setting tracemalloc_config.tracing to 1.

Add a test using PyTraceMalloc_Track() to test tracemalloc.stop() race condition.

Call _PyTraceMalloc_Init() at Python startup.

(cherry picked from commit 6b47499)

…n#128897)

tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(),
PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check
tracemalloc_config.tracing after calling TABLES_LOCK().

_PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(),
especially setting tracemalloc_config.tracing to 1.

Add a test using PyTraceMalloc_Track() to test tracemalloc.stop()
race condition.

Call _PyTraceMalloc_Init() at Python startup.

(cherry picked from commit 6b47499)
@vstinner
Copy link
Member Author

I tested manually my change on FreeBSD with Python built in release mode. I ran test_tracemalloc_track_race() 1,000x in a loop (using -F option) and it doesn't crash.

@vstinner vstinner enabled auto-merge (squash) January 19, 2025 13:12
@vstinner vstinner merged commit 6df22cb into python:3.12 Jan 19, 2025
30 checks passed
@vstinner vstinner deleted the tracemalloc_stop12 branch January 19, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant