Berildocs GitHub

Memory cards

Thread-local storage has a model and a destructor order

confidence: mediumupdated: 2026-11-25status: activeruntimetlsthreads

Claim#

The TLS model decides the lookup cost. The destructor runs at thread exit, and the order is not yours to choose.

Test#

Read the TLS model in the binary. Start and stop a thread. Check the destructor.

Proof#

A correct per-thread value and a clean destructor.

Failure modes#

A dynamic TLS in a dlopen library has a slow path. A destructor that touches freed state crashes.