Skip to content

Comments

Crash fix in case of forks: use static TLS for alloc tracking storage#490

Draft
r1viollet wants to merge 3 commits intomainfrom
r1viollet/tls-initial-exec-cleanup
Draft

Crash fix in case of forks: use static TLS for alloc tracking storage#490
r1viollet wants to merge 3 commits intomainfrom
r1viollet/tls-initial-exec-cleanup

Conversation

@r1viollet
Copy link
Collaborator

What does this PR do?

Replacement of PR #483 to remove pthread APIs to manage TLS.
This is an idea from @nsavoire in following PR

Motivation

A user reported a crash in case of forks.
Although we do not understand the sequence that lead to calling init inside the child, with this PR we remove the risk as the storage will always be available through static TLS

Additional Notes

NA

How to test the change?

The PR includes a test for forks.
I did not use gtest as it was not safe with forks.

nsavoire and others added 2 commits February 5, 2026 00:43
initial-exec __thread and placement new.

- Add `initialized` field to TrackerThreadLocalState
- Shared C header (tls_state_storage.h) for size/alignment
  constants between loader.c and C++ code, with static_assert
- Clean up dead code: _key_once, _tl_state_key, delete_tl_state
- Add standalone fork test validating TLS zero-init, fork
  inheritance, and fresh-thread behavior
@r1viollet r1viollet force-pushed the r1viollet/tls-initial-exec-cleanup branch from 67204b8 to 7fd9a0d Compare February 22, 2026 17:28
@r1viollet r1viollet changed the title Crash fix in case of forks: use static TLS for alloc structure Crash fix in case of forks: use static TLS for alloc tracking storage Feb 22, 2026
@pr-commenter
Copy link

pr-commenter bot commented Feb 22, 2026

Benchmark results for collatz

Parameters

Baseline Candidate
config baseline candidate
profiler-version ddprof 0.23.0+820196ba.96300814 ddprof 0.23.0+b5615391.98307349

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean execution_time
scenario:ddprof -S bench-collatz --preset cpu_only collatz_runner.sh same

@pr-commenter
Copy link

pr-commenter bot commented Feb 22, 2026

Benchmark results for BadBoggleSolver_run

Parameters

Baseline Candidate
config baseline candidate
profiler-version ddprof 0.23.0+820196ba.96300814 ddprof 0.23.0+b5615391.98307349

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean execution_time
scenario:ddprof -S bench-bad-boggle-solver BadBoggleSolver_run work 1000 same

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.

2 participants