fix(initimg): stabilize Linux startup stack layout

Merged
NO
21d ago
+254-38

TLDR: Argument and environment sizes move the initial guest stack pointer and change simulated cache misses. Reserve a fixed startup region to keep the stack pointer stable (Linux).

  • Store pointer tables and original strings in a fixed 16 MiB region; reject overflow rather than shifting the stack. Preserve auxiliary data, including AT_RANDOM.
  • Account for the region separately from the runtime stack limit.
  • A frozen workload executable shows variation in all 47 workloads before the fix and exact equality across all 11 checked counters afterward. Changed-work and child-failure controls still behave as expected.
  • Verified argument/environment preservation with none, Callgrind and Memcheck; exercised stack growth and stable mmap addresses.
  • Local 12-case startup regression passes with the fix and fails on the rebuilt parent: a 15-byte argument moves the initial SP by 16 bytes. The full none suite retains the same 38 pre-existing stdout/stderr failure records, with no new failures.

This removes startup stack-address variation, not input-dependent work, randomness or scheduling nondeterminism.

Before/after variance matrix — 47 workloads

Same x86-64 Linux host and byte-identical workload executable; parent e1e4bdf3 versus stack-layout fix a5dc7701. Both Valgrind builds report 3.26.0.codspeed9; the parent was rebuilt cleanly. Each build runs 18 controlled process states × three repetitions: 54 samples per workload, 2,538 samples total. The states vary ignored environment values/counts, argument contents/counts and directory contents.

CV is population standard deviation / mean × 100 across these controlled states, not walltime variance or a speedup. D1mr/D1mw are L1 data read/write misses; DLmr/DLmw are last-level data read/write misses. Small miss counts can produce large relative CVs. The after column is the maximum CV across all 11 checked counters (Ir, Dr, Dw, I1mr, D1mr, D1mw, ILmr, DLmr, DLmw, Ct, Cl): every value is exactly invariant, not merely rounded to zero.

BenchmarkBefore D1mr CVBefore D1mw CVBefore DLmr CVBefore DLmw CVAfter max CV
expr_eval_recursive0.16%0.00%0.16%0.00%0.00%
expr_accumulate_recursive0.16%3.22%0.16%3.22%0.00%
insertion_sort_646.28%3.70%6.28%3.70%0.00%
merge_sort_recursive_644.20%3.10%4.20%3.10%0.00%
dense_stack_checksum_4k1.25%14.39%1.25%14.39%0.00%
strided_static_table_sum1.23%14.39%1.23%14.39%0.00%
heap_slice_sum_control0.32%14.39%0.32%14.39%0.00%
register_arithmetic_control34.02%18.33%34.02%18.33%0.00%
sparse_64b_d0823.39%2.63%23.39%2.63%0.00%
sparse_80b_d0823.39%2.34%23.39%2.34%0.00%
dense_64b_d0823.39%2.63%23.39%2.63%0.00%
dense_80b_d0823.39%2.34%23.39%2.34%0.00%
aligned_64b_d0823.39%1.53%23.39%1.53%0.00%
aligned_80b_d0823.39%1.78%23.39%1.78%0.00%
sparse_64b_d3223.39%0.72%23.39%0.72%0.00%
sparse_80b_d3223.39%0.63%23.39%0.63%0.00%
dense_64b_d3223.39%0.72%23.39%0.72%0.00%
dense_80b_d3223.39%0.63%23.39%0.63%0.00%
aligned_64b_d3223.39%0.42%23.39%0.42%0.00%
aligned_80b_d3223.39%0.49%23.39%0.49%0.00%
sparse_64b_d6423.39%0.37%23.39%0.37%0.00%
sparse_80b_d6423.39%0.32%23.39%0.32%0.00%
dense_64b_d6423.39%0.37%23.39%0.37%0.00%
dense_80b_d6423.39%0.32%23.39%0.32%0.00%
aligned_64b_d6423.39%0.21%23.39%0.21%0.00%
aligned_80b_d6423.39%0.25%23.39%0.25%0.00%
sparse_784b_d0823.39%3.98%23.39%3.98%0.00%
sparse_800b_d0823.39%3.98%23.39%3.98%0.00%
dense_784b_d0823.39%0.39%23.39%0.39%0.00%
aligned_784b_d0823.39%1.78%23.39%1.78%0.00%
spread_784b_d0823.39%11.61%23.39%11.61%0.00%
spread_800b_d0823.39%3.03%23.39%3.03%0.00%
aligned_spread_784b_d0823.39%1.38%23.39%1.38%0.00%
sparse_784b_d3223.39%1.14%23.39%1.14%0.00%
sparse_800b_d3223.39%1.14%23.39%1.14%0.00%
dense_784b_d3223.39%0.10%23.39%0.10%0.00%
aligned_784b_d3211.00%0.49%23.39%0.49%0.00%
spread_784b_d3223.39%13.98%23.39%13.98%0.00%
spread_800b_d3223.39%0.84%23.39%0.84%0.00%
aligned_spread_784b_d3211.00%0.37%23.39%0.37%0.00%
sparse_784b_d6423.39%0.58%23.39%0.58%0.00%
sparse_800b_d6423.39%0.58%23.39%0.58%0.00%
dense_784b_d6427.16%1.41%23.39%0.05%0.00%
aligned_784b_d641.16%0.21%23.39%0.25%0.00%
spread_784b_d6423.39%14.46%23.39%14.46%0.00%
spread_800b_d6423.39%0.43%23.39%0.43%0.00%
aligned_spread_784b_d641.16%0.17%23.39%0.19%0.00%

Workload executable SHA-256: cd9d44401bb329cb33d54463ecea22d6ebb1b6517d67dd948f1804b91aa921cc.