Skip to content

build runner links a tree-generation out/lib when prepare-bootstrap-link-root was fresh: seed-compiled runner segfaults (mixed-world, #761/#1797 class) #1906

Closed

Description

@ehartford

Found while measuring battery lanes on branch battery-speed (worktree based on f589bf7, driver = pinned seed nightly-20260927-local-1).

Repro

  1. In a worktree, src/main build (full chain; stage objects populate out/lib with the tree generation's runtime, .producer = the tree's hash).
  2. Edit any build/*.w or src/*.w so the runner key changes and the stage chain rebuilds out/lib.
  3. src/main build :tools-tests (not --no-deps).

Actual: [build] runner compiled 25.0s, then error: build.w target 'build' failed with exit code 139. Under lldb the runner (out/.build-state/build-runner, WITH_BUILD_ACTION_NAME=build) dies in rt_memcpy <- posix_str_to_c_buf(s=(ptr=" a/", len=4298598592)) <- rt_compat_setenv_str <- set_env at __with_build_runner.w:10 — the set_env("WITH_BUILD_TOOLFS_SUPPRESS", "") after build(ctx): a str argument crossing into runtime code with the wrong layout. Same crash with the original build/*.w restored; SIGBUS instead of SIGSEGV when unrelated files under out/ change (data-dependent corruption).

Cause (by elimination): the runner is compiled with WITH_OUT_DIR=<root>/out (src/main.w build_runner_ensure), so the link takes whichever runtime directory the probe finds. bootstrap_ready in the scheduler is true when prepare-bootstrap-link-root is fresh in this run, but freshness of that target says nothing about out/lib: the stage chain re-created out/lib/cimport_stubs.o (the probe) after prepare last ran, so the seed-compiled runner linked the tree generation's runtime objects. build_runner_runtime_dirs_are_this_generation would have refused, but it is only consulted when the prepare target is not scheduled.

Workaround used: rm out/bootstrap-lib/.prepared-link-root out/.build-state/build-runner.key so prepare re-executes (removing the probe) before the runner compiles. The runner then works.

Expected: the runner never links a runtime directory of another generation (D30: that link must be refused, not attempted). Either always check build_runner_runtime_dirs_are_this_generation before compiling the runner, or pass the runner link an explicit bootstrap link root instead of WITH_OUT_DIR probing. And the link itself is a silent mixed-world link, so the tool that should have refused it (the D30 producer check at link time) stayed silent — that check needs to cover the runner link too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions