mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
Under whole-program LTO the address of the TSD thread-local is hoisted out of the inlined malloc/free and kept across a user-space context switch (fibers/coroutines), so a fiber resumed on another OS thread keeps using the old thread's tcache, corrupting the heap. jemalloc now takes TSD addresses via JEMALLOC_TLS_ADDR (an opaque accessor with an inline initial-exec fast path), so re-enable LTO for jemalloc. Add JEMALLOC_TLS_MODEL_INITIAL_EXEC to the preconfigured headers: it gates the fast path and is defined on every platform that uses the initial-exec TLS model (everything except e2k, where tls_model is unsupported), matching the configure output. Refs: https://github.com/ClickHouse/jemalloc/pull/7 Refs: https://github.com/ClickHouse/ClickHouse/issues/102460 Co-Authored-By: Claude Fable 5 <[email protected]>