MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / thread_release_heap_enabled

Function thread_release_heap_enabled

src/foundation/compat_thread.c:83–93  ·  view source on GitHub ↗

Release each thread's allocator heap at DLL_THREAD_DETACH. * * Doing this from the thread wrapper instead crashes: the wrapper returns * before the CRT's own thread teardown, and abandoning the heap there raced * with frees still in flight (daemon_ipc_wait_forever_is_interruptible * segfaulted, rc=139, reproducibly and only with the release enabled). A TLS * callback is the mechanism mimallo

Source from the content-addressed store, hash-verified

81 * CBM_MI_THREAD_DONE=0 disables it, so one binary can demonstrate both
82 * behaviours rather than requiring a rebuild to establish causality. */
83static bool thread_release_heap_enabled(void) {
84 static int state = -1;
85 if (state < 0) {
86 char buf[CBM_SZ_16];
87 state =
88 (cbm_safe_getenv("CBM_MI_THREAD_DONE", buf, sizeof(buf), NULL) != NULL && buf[0] == '0')
89 ? 0
90 : 1;
91 }
92 return state == 1;
93}
94
95static void NTAPI cbm_thread_detach_callback(PVOID handle, DWORD reason, PVOID reserved) {
96 (void)handle;

Callers 1

Calls 1

cbm_safe_getenvFunction · 0.85

Tested by

no test coverage detected