Skip to content

ToolFs copy_file silently turns an unreadable source into an empty successful output #1164

Closed

Description

@ehartford

ToolFs.copy_file reports success and overwrites the destination with zero bytes when its source cannot be read. Both the native std.build implementation and the comptime evaluator call the legacy with_fs_read_file, which discards the I/O status. read_binary has the same unchecked read; read_text was already corrected by #953.

Minimal build action:

use std.build
fn copy(ctx: ActionCtx) -> i32:
    ctx.fs().copy_file("missing.dll", "out/copied.dll")
pub fn build(ctx: BuildCtx) -> Build:
    var out = ctx.new_build()
    var target = target_new(.Action, "copy", "").output("out/copied.dll")
    target.action = copy
    out = out.add_target(target)
    out.default("copy")

Run with build --strict-effects in an initialized project. Expected: a nonzero read/copy failure, naming the missing source, without replacing a destination. Actual: survey: all targets green and an empty output. An existing readable empty source must still succeed.

Native proof on the actual release compiler: LLDB in with_fs_read_file receives /Users/eric/with/out/with-get-investigation/dll-copy-probe/missing.dll from ComptimeEvaluator.eval_toolfs_capability_method; stepping out returns a str with x1 = 0. Source branch: src/ComptimeEval.w copy_file path calls with_fs_write_file(resolved_dst, with_fs_read_file(resolved_src)). The native counterpart is lib/std/build.w:ToolFs.copy_file. Evidence: out/with-get-investigation/dll-copy-missing-read-correct-lldb.log and dll-copy-current-missing.log.

The pinned Darwin seed additionally treats D:/... as project-relative: LLDB observes capability_resolve_project_path return <project>/D:/a/_temp/mesa/opengl32.dll. That legacy path failure combined with the unchecked read can explain a zero-byte Mesa copy. Native and interpreted relative copies of the actual Mesa DLL are byte-identical on Darwin and both Windows seeds (diagnostic run 35202112398); the exact external absolute Windows path remains under investigation. No product workaround is applied yet.

The build contract and repository's No Silent Fallbacks rule require reporting the failed operation, not manufacturing a successful empty output. Cover missing, unreadable/directory, readable empty, binary contents, and preservation of an existing destination across native and interpreted actions.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce; ToolFs.copy_file now fails loudly.

    # build.w action: ctx.fs().copy_file("missing.dll", "out/copied.dll")
    $ with build :copy
    error: copy_file: …/missing.dll: No such file or directory (os error 2)
    error: build.w target 'copy' failed with exit code 254
    $ ls out/copied.dll
    ls: out/copied.dll: No such file or directory
    
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