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

Function cbm_thread_stack_floor

src/foundation/compat_thread.c:34–49  ·  view source on GitHub ↗

Thread stacks are sized in code (explicitly by most callers, by the default * above otherwise), so RLIMIT_STACK does NOT reach them and a sanitizer lane * cannot size them with ulimit. MemorySanitizer's origin tracking inflates * every frame enough that deep parser recursion overflows the normal worker * stack, and without this hook that lane cannot run the parsing suites at all. * * The flo

Source from the content-addressed store, hash-verified

32 * exactly the threads that overflow. Diagnostic builds only: the shipping
33 * binary keeps its fixed, predictable stack sizes. */
34static size_t cbm_thread_stack_floor(size_t requested) {
35#if CBM_SANITIZED
36 const char *env = getenv("CBM_THREAD_STACK_MB");
37 if (env && env[0]) {
38 char *end = NULL;
39 unsigned long mb = strtoul(env, &end, 10);
40 if (end && *end == '\0' && mb > 0 && mb <= 1024) {
41 size_t floor_bytes = (size_t)mb * CBM_SZ_1K * CBM_SZ_1K;
42 if (floor_bytes > requested) {
43 return floor_bytes;
44 }
45 }
46 }
47#endif
48 return requested;
49}
50
51static size_t cbm_thread_default_stack_size(void) {
52 return cbm_thread_stack_floor(CBM_DEFAULT_STACK_SIZE);

Callers 2

cbm_thread_createFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected