summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/_sqlite/cache.h
diff options
context:
space:
mode:
authorbabenko <[email protected]>2026-06-23 00:32:05 +0300
committerbabenko <[email protected]>2026-06-23 00:50:43 +0300
commit6ce03d8a5070753a84defdb8c4c9b43d852ad65b (patch)
tree7156ae27ac90325195bc35aa2f3c157e2dc1d74e /contrib/tools/python3/src/Modules/_sqlite/cache.h
parent8e34c03a0bd30c7d5f28400c85f7775b5f00a118 (diff)
YT-28458: Make per-CPU rseq fast path dlopen-safe
Hardens `library/cpp/yt/rseq` for the case where it is linked into a dlopen'd, position-independent module (e.g. a YQL UDF `.so`). Extracted from the profiling work that enables the rseq fast path by default. **TLS model.** The weak `__rseq_abi` gets `global-dynamic` linkage under `__PIC__/__PIE__` (`initial-exec` otherwise), mirroring `contrib/libs/tcmalloc`. `initial-exec` needs a slot in the static TLS block reserved at startup, which the loader cannot grant a module dlopen'd later — the module would fail to load with "cannot allocate memory in static TLS block". This only changes the cold `&__rseq_abi` accesses; the hot path still reads `*(thread_pointer + CpuIdFieldOffset)`. **Runtime safety probe `IsPerCpuFastPathSafe()`.** The cached thread-pointer offset is valid only when `__rseq_abi` sits at a fixed offset from the thread pointer — a glibc-owned area or the static TLS block (incl. tcmalloc), the common case. When our `__rseq_abi` instead lands in a dlopen'd module's *dynamically allocated* TLS, the offset is valid only on the thread that computed it; on other threads the hot path's first store (`area->rseq_cs`) would corrupt unrelated memory. The probe spawns one thread and checks — by pointer comparison, never dereferencing the suspect offset — that the offset names that thread's rseq area; if not, callers use the atomic fallback. Decided once and cached (one thread spawn at first use).= commit_hash:633f58f500d9d097800da81f526c56283445ffc7
Diffstat (limited to 'contrib/tools/python3/src/Modules/_sqlite/cache.h')
0 files changed, 0 insertions, 0 deletions