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:33–48  ·  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

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