Expand description
The native stack contract for every thread that can run Harn code.
Harn has two independent stack hazards, each with its own owner:
- Walking an arbitrarily deep value —
x = [x]in a loop — is made stack-size independent byharn_vm::value::recursion, which grows the native stack on demand and tears values down iteratively. - Walking an arbitrarily deep program — parse, type-check, compile, and
evaluate all recurse over nested syntax — is not. It relies on the thread
simply having enough stack, and that is what
RUNTIME_STACK_SIZEis.
This module owns the second contract because the parser is the lowest crate
that recurses over a program: the module loader, the VM, and every host
depend on it. A thread in any crate that can reach the parser or the VM is
created here, through spawn, builder, or scope. Rust’s 2 MiB
default is never the right answer for such a thread, and a stack overflow
aborts the whole process rather than failing one request.
RUST_MIN_STACK does not substitute. Every CI test lane exports it, which
makes an unsized thread large enough in CI and nowhere else, so a host that
relies on it passes its own tests and aborts the first time a customer runs
a deep enough script. harn_vm’s runtime_stack tests scan the workspace
and refuse a thread created any other way.
Structs§
- Runtime
Scope - A scope whose threads hold
RUNTIME_STACK_SIZE. Seescope.
Constants§
- PARSE_
STACK_ SIZE - Native stack a thread needs to parse any source the parser accepts.
- RUNTIME_
STACK_ SIZE - Native stack size a thread needs in order to run Harn code.
Functions§
- builder
- A thread builder that already holds
RUNTIME_STACK_SIZE. - on_
vm_ stack - Run
bodyon a thread that holds theRUNTIME_STACK_SIZEcontract. - scope
std::thread::scopewhose spawned threads holdRUNTIME_STACK_SIZE.- spawn
std::thread::spawnwithRUNTIME_STACK_SIZE.