mirror of
https://github.com/Tencent/flare.git
synced 2026-10-17 04:41:22 +08:00
8833dfa279
* base: never-destroy tls_queues to fix an exit-time mutex crash
A static `MonitoredTimer` (and similar globals) calls
DeleteThreadOutOfDutyCallback in its destructor during static destruction, which
locks the `tls_queues` ThreadLocal's internal mutex. `tls_queues` was a plain
namespace static, so on macOS it could already be destroyed by then, and
std::mutex::lock() throws std::system_error EINVAL ("mutex lock failed") ->
std::terminate at process exit. monitoring_test reproduced this reliably
(all cases pass, then SIGABRT on shutdown).
Wrap it in NeverDestroyed, exactly as GetGlobalQueue() already does in the same
file, so the lock stays valid for the whole process lifetime. Leaking it is
harmless (the OS reclaims it at exit).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* base: clang-format the tls_queues comment
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>