fix dynamically built grate#1242
Open
qianxichen233 wants to merge 4 commits into
Open
Conversation
Grates previously had to be compiled statically (-s): the runtime gated
grate-worker registration to non-dylink modules. This lets grates run as
shared/dynamic builds while keeping static working.
- instance.rs: reserve the grate stack arena in the dynamic InstantiateFirst
branch and always inherit it to the fork child; execve now unsets the arena
base for all builds (fixes fork+exec 'already initialized' panic).
- linker.rs: add build_dylink_child_store + LindDylinkChildStore, the per-store
dynamic-linking replay used to construct grate workers (separate Store sharing
the cage memory; fresh per-store linker/table/GOT; global-snapshot + GOT
reloc + TLS replay). Mirrors the pthread thread-creation path.
- lind-3i: GrateTemplate gains an optional worker_builder; create_worker uses it
for dynamic grates and keeps the clone-linker path for static.
- lind-multi-process / lind-boot: build the worker_builder at the initial-cage
and fork registration sites; drop the static-only gate.
- gratetestreport.py: add --grate-build {static,shared,both} (default shared).
In-repo tests/grate-tests pass in both static and shared modes.
Each grate worker reserves a stack slot in a per-cage arena sized MAX_GRATE_WORKERS * (guard + slot). At the previous 8 MiB slot that arena was ~256 MiB per cage, which is far more than grate handler code (shallow syscall interposition) needs. Replace the GRATE_STACK_SLOT_SIZE constant with DEFAULT_GRATE_STACK_SLOT_SIZE (1 MiB) plus grate_stack_slot_size(), which reads LIND_GRATE_STACK_SIZE (bytes, page-rounded) once and caches it. The arena reservation (instance.rs, both the static and dynamic branches) and the per-worker slot addressing (lind-3i) both call it, so they always agree on the layout. Default arena drops to ~32 MiB.
…k arena The grate worker stack arena is mapped accessible at the low end of linear memory (after the stack/data region), so 0x1234567 (~18 MiB) now falls inside it and reads as valid instead of faulting. Move the probe to 0x40000000 (1 GiB): above the stack, data region, grate stack arena, and the tiny heap, yet within the 4 GiB linear memory, so it reliably hits a reserved PROT_NONE page and traps. Verified both tests fault under default settings.
…ctor
The grate test harness should exercise dynamically-linked grates only and
expose no public switch to change that. Remove the --grate-build
{static,shared,both} option (and GRATE_BUILD env), and always compile the
grate without -s (dynamic). Cages are unchanged (lind-clang dynamic default).
Contributor
End-to-End Test ReportTest Previewgrate harnessGrate Test Report
Cases
static harnessTest ReportDeterministic TestsSummary
Test Results by Category
Fail TestsSummary
wasm harnessTest ReportDeterministic TestsSummary
Test Results by Category
Fail TestsSummary
Test Results by Category
C++ harnessSummary
Cases
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix dynamically built grate so that grate can be dynamically built and run
also adjust the default stack space for grate worker to be 1MB rather than 8MB