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:36–51  ·  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

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