Skip to content

Windows cache corruption after repeatedly running tests #12664

Closed
@jcmoyer

Description

@jcmoyer

Zig Version

0.10.0-dev.3659+e5e6eb983

Steps to Reproduce

This is a weird issue and I'm not entirely sure how to trigger it. Over time, tests begin to fail building more frequently. Here's an example on a brand new project:

// build.zig
const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    const a_tests = b.addTest("src/a.zig");
    const b_tests = b.addTest("src/b.zig");
    const c_tests = b.addTest("src/c.zig");

    const test_step = b.step("test", "Run unit tests");
    test_step.dependOn(&a_tests.step);
    test_step.dependOn(&b_tests.step);
    test_step.dependOn(&c_tests.step);
}
// a.zig, b.zig, c.zig all contain the following
test {}

I'm not sure if this problem also exists on stage1 because self-hosted recompiles things every zig build test, but stage1 just runs the cached test binaries.

Expected Behavior

There shouldn't be any build failures.

Actual Behavior

Command line output:

d:\Scratch\testfailure>zig init-exe
info: Created build.zig
info: Created src\main.zig
info: Next, try `zig build --help` or `zig build run`

[fill in the files using the above snippets]

d:\Scratch\testfailure>zig build test
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
error: InvalidFormat
error: test...
error: The following command exited with error code 1:
D:\Scratch\zig-install\bin\zig.exe test D:\Scratch\testfailure\src\b.zig --cache-dir D:\Scratch\testfailure\zig-cache --global-cache-dir C:\Users\jcmoyer\AppData\Local\zig --name test --enable-cache
error: the following build command failed with exit code 1:
d:\Scratch\testfailure\zig-cache\o\6be072760b1c422c81d96f0d8413e4e5\build.exe D:\Scratch\zig-install\bin\zig.exe d:\Scratch\testfailure d:\Scratch\testfailure\zig-cache C:\Users\jcmoyer\AppData\Local\zig test

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
error: InvalidFormat
error: test...
error: The following command exited with error code 1:
D:\Scratch\zig-install\bin\zig.exe test D:\Scratch\testfailure\src\b.zig --cache-dir D:\Scratch\testfailure\zig-cache --global-cache-dir C:\Users\jcmoyer\AppData\Local\zig --name test --enable-cache
error: the following build command failed with exit code 1:
d:\Scratch\testfailure\zig-cache\o\6be072760b1c422c81d96f0d8413e4e5\build.exe D:\Scratch\zig-install\bin\zig.exe d:\Scratch\testfailure d:\Scratch\testfailure\zig-cache C:\Users\jcmoyer\AppData\Local\zig test

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.
All 1 tests passed.

d:\Scratch\testfailure>zig build test
All 1 tests passed.
error: InvalidFormat
error: test...
error: The following command exited with error code 1:
D:\Scratch\zig-install\bin\zig.exe test D:\Scratch\testfailure\src\b.zig --cache-dir D:\Scratch\testfailure\zig-cache --global-cache-dir C:\Users\jcmoyer\AppData\Local\zig --name test --enable-cache
error: the following build command failed with exit code 1:
d:\Scratch\testfailure\zig-cache\o\6be072760b1c422c81d96f0d8413e4e5\build.exe D:\Scratch\zig-install\bin\zig.exe d:\Scratch\testfailure d:\Scratch\testfailure\zig-cache C:\Users\jcmoyer\AppData\Local\zig test

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
All 1 tests passed.
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.

d:\Scratch\testfailure>zig build test
LLD Link... warning(link): failed to write cache manifest when linking: LockViolation
All 1 tests passed.
error: InvalidFormat
error: test...
error: The following command exited with error code 1:
D:\Scratch\zig-install\bin\zig.exe test D:\Scratch\testfailure\src\b.zig --cache-dir D:\Scratch\testfailure\zig-cache --global-cache-dir C:\Users\jcmoyer\AppData\Local\zig --name test --enable-cache
error: the following build command failed with exit code 1:
d:\Scratch\testfailure\zig-cache\o\6be072760b1c422c81d96f0d8413e4e5\build.exe D:\Scratch\zig-install\bin\zig.exe d:\Scratch\testfailure d:\Scratch\testfailure\zig-cache C:\Users\jcmoyer\AppData\Local\zig test

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions