Repository navigation
Description
Summary
A partner workload drives every kernel-c-abi worker thread to a high-water stack usage
of ~3113 KB (peak 3172 KB). The C-ABI runtime's worker stacks are whatever Rust std's
default gives — 2048 KB — which is ~1.1 MB below the observed requirement. Any
consumer running this workload on the default configuration will overflow a worker stack
and take the process down with a SIGSEGV.
This is not specific to that partner's environment: their threads were 3117 KB (larger
than our default) and still overflowed.
Measurement
LD_PRELOAD interposer on pthread_create that paints each new thread's stack with a
known byte and, at exit, reports the lowest surviving byte (true high-water). Partner ran
their real workload with RUST_MIN_STACK=8388608, which makes it pass:
[stackdiag] RLIMIT_STACK: 8388608 bytes (8192 KB) soft, unlimited hard
[stackdiag] RUST_MIN_STACK: 8388608
kernel-c-abi LWP 3947 8192 KB HW 3172 KB req 8388608 libdatabricksodbc64.so+0x105ed41
kernel-c-abi LWP 3948 8192 KB HW 3113 KB req 8388608 libdatabricksodbc64.so+0x105ed41
... 30 more workers, all HW 3113-3172 KB ...
Note the uniformity: all ~32 workers reach ~3113 KB, including ones unlikely to have
done heavy work. That points at a cost paid on the worker's startup/first-use path rather
than something proportional to the query workload.
| configuration | worker stack | vs. observed 3172 KB requirement |
|---|---|---|
Rust std default (RUST_MIN_STACK unset) |
2048 KB | too small by ~1.1 MB |
#326 thread_stack_size(2 MiB) |
2048 KB | too small by ~1.1 MB |
| partner's actual (pre-workaround) | 3117 KB | too small — this is what crashed |
RUST_MIN_STACK=8388608 (their workaround) |
8192 KB | ok |
Where the stack goes
Recovered from the partner's core dumps by fingerprinting each frame against the string
literals its function references (the shipped driver is stripped). Innermost first:
malloc ← driver Rust allocation code ← reqwest/hyper proxy environment discovery ←
reqwest ClientBuilder::build ← TLS config ← DatabricksHttpClient::new ←
SessionBuilder ← session-config validation ← block_on_ffi ← tokio task/worker
machinery ← worker thread entry.
The 39 frames' own prologues account for only ~15 KB, so the ~3 MB is not explained by that
chain's frame sizes — the remaining consumption is somewhere in that path and still needs
to be localised.
Why this matters for #328
Issue #328 already notes that #326 sets a fixed 2 MiB rather than a floor. This makes
that worse than a cosmetic problem:
- 2 MiB is not merely "not larger than the host asked for" — it is demonstrably below
what a real workload needs. databricks-odbccurrently pins9ecd357, which predates#326. Bumping that pin
would cap every worker at 2 MiB and could introduce this crash for consumers who today
get more from their runtime.
Suggested actions
- Do not let the ODBC pin move past
#326until the value is revisited. - Make the size a floor (per c-abi: thread_stack_size(2 MiB) is a cap, not a floor — it shrinks workers when RUST_MIN_STACK is larger #328) and set it from measurement — ≥ 8 MiB would clear
the observed 3172 KB with margin; 4 MiB would be uncomfortably close. - Separately, find what consumes ~3 MB on the session-open path. A per-worker fixed cost
of 3 MB is worth understanding on its own, independent of the stack sizing.
Reproduction aid
The interposer used for this measurement (odbc_stackdiag.c) installs a per-thread
sigaltstack, so it can also report a guard-page SIGSEGV that would otherwise produce no
usable output at all, and prints for each thread: real bounds, high-water, the stack size
the creator requested, and the creating call site. Happy to attach it.
Activity
vikrantpuppala commentedon Sep 9, 2026
Update after inspecting the supplied
core3-guardpages.gtestcore and reproducing the pthread layout with a standalone probe: the original diagnosis in this issue is incorrect. The reported 3113–3172 KiB is not kernel call-stack usage;odbc_stackdiag.cis counting static TLS as stack.Evidence:
PT_TLSsegment withp_memsz = 3,167,285bytes andp_filesz = 120bytes. Including the other loaded objects, raw static TLS is about 3,168,645 bytes.stack_hi - deepest_write. That necessarily includes the static TLS region, producing the uniform ~3.1 MiB baseline on every worker even when little ordinary stack has been used.A controlled probe with a 3,167,285-byte TLS object reproduced the same geometry: the glibc minimum stack became 3,191,936 bytes; a 3,194,880-byte request left only about 23 KiB usable; and a 2 MiB request could not create the thread because it was below the TLS-aware minimum.
So the crash is real, but the primary cause is the unusually large static TLS allocation in the partner executable/build, not a ~3 MiB stack requirement in the kernel. I do not think we should raise the kernel-wide floor to 8 MiB. The behavior merged in #329 is the appropriate generic policy: retain the 2 MiB floor while preserving any larger caller-provided
RUST_MIN_STACK.The partner should identify the large TLS symbol:
If the binary is stripped, rebuild it with a linker map:
Then inspect the
.tbssand.tdatacontributors and comparePT_TLSwith the production executable. That will tell us whether this is test-only instrumentation/dependency state or production code. The durable fix is to move the multi-megabytethread_local/__threadobject to heap-backed storage (or reduce it).As a temporary workaround, 4 MiB leaves roughly 1 MiB for ordinary stack, 6 MiB gives comfortable headroom, and 8 MiB is conservative but unnecessary based on these cores. The partner should validate the chosen temporary value under its full workload. Please share the TLS-symbol or linker-map output so we can identify the exact contributor.
The diagnostic itself should also be corrected to exclude static TLS/use the initial stack pointer as its ordinary-stack baseline.
github-actions commentedon Oct 10, 2026
This issue has been marked as Stale because it has been open for 30 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue.
github-actions commentedon Oct 18, 2026
This issue was closed because it has been inactive for 7 days since being marked as stale.