Skip to content

Source-only bootstrap exposes libc globals hidden by bundle interfaces #1116

Closed

Description

@ehartford

The stage1 compiler with empty embedded bundle slots rejects this source, while stage2 with embedded PCRE2 accepts it:

use std.regex.Regex
fn main:
    let stderr = "ok"
    print(stderr)

Stage1 reports shadowing is not allowed for 'stderr'; subsequent uses resolve to libc's *mut c_void global. This also makes a relative-path with-stage1 check src/main.w fail on the reducer's local/parameter named stderr. The bundled stage2 check succeeds on the same tree. No source renaming workaround was applied.

Debugger route: stop Sema.emit_error on the four-line input. The stack is Sema.scope_put_consuming_rebind_at -> Sema.check_let_binding -> Sema.check_block -> Sema.check_fn_body_with_sig_at. The error is the existing-binding branch at src/Sema.w:4604: binding_is_unseen_global has not hidden the transitive libc global.

The visibility walk at src/Sema.w:2702 stops at a corpus boundary only when module_in_bundle_corpus succeeds. At line 2720 that helper requires a nonempty explicit bundle_corpus. Its arm64 disassembly loads self + 0x23d0, compares the length with 1, and branches to false at offset +28. At the error breakpoint, LLDB reads the bundle_corpus pair at self + 0x23c8 as {pointer, 0} and the message as shadowing is not allowed for 'stderr'. An ordinary source-only stage1 check has no --bundle-corpus, so the walk can traverse std.regex -> std.re -> std.libc; the populated .wi path excludes those body-only imports.

Foundation needed: model the corpus/import boundary independently of the presence of compiled bundle blobs or a single command-line corpus selection. EmbeddedBundlesData currently identifies empty slots by bundle name and blob addresses; absent manifests provide no corpus/module metadata. Hardcoding std.re in Sema or renaming consumer locals would conceal the inconsistency. Coordinate with D29 source-module visibility and #954's canonical module identity work. This is separate from zlib object/interface generation, which re-migrates byte-identically in #1103.

Spec references: §18 module/import visibility and D39 source/interface parity. Reproduction and debugger log are retained in the #1103 worktree's out/zlib-1103-validation/.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce. The stage1 compiler with empty bundle slots now accepts the program:

    $ cat main.w
    use std.regex.Regex
    fn main:
        let stderr = "ok"
        print(stderr)
    $ out/bootstrap/bin/with-stage1 run main.w   # :dev stage1 at a261b6598
    ok
    $ with run main.w
    ok
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions