Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed file with absolute path from same drive as build panics compiler #9465

Closed
Sirius902 opened this issue Jul 26, 2021 · 2 comments · Fixed by #10044
Closed

Embed file with absolute path from same drive as build panics compiler #9465

Sirius902 opened this issue Jul 26, 2021 · 2 comments · Fixed by #10044
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@Sirius902
Copy link

Assume we run zig test on the below program from drive D on a Windows machine.

comptime {
    _ = @embedFile("D:/test.txt");
}

This will cause the following compiler panic:

Assertion failed at D:\a\1\s\src\stage1\util.hpp:229 in memCopy. This is a bug in the Zig compiler.thread 3332 panic: 
Unable to dump stack trace: debug info stripped

However if we try and embed from a different drive as the current such as C or E, then zig test gives the expected output.

.\src\main.zig:2:20: error: unable to find 'E:\test.txt'
    _ = @embedFile("E:/test.txt");
                   ^
.\src\main.zig:2:9: note: referenced here
    _ = @embedFile("E:/test.txt");
        ^

I did make a debug build of the zig compiler to get a stacktrace and here it is: https://pastebin.com/WsnzL85a.

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Jul 27, 2021
@Vexu Vexu added this to the 0.9.0 milestone Jul 27, 2021
@maxxnino
Copy link

I got it today too

LemonBoy added a commit to LemonBoy/zig that referenced this issue Oct 27, 2021
Backport a missing change from `path.zig`.

Fixes ziglang#9465
@marler8997
Copy link
Contributor

Very odd, it doesn't reproduce on my box, I get the expected error:

C:\temp>type d:\test.txt
The system cannot find the file specified.

C:\temp>type foo.zig
comptime {
    _ = @embedFile("D:/test.txt");
}

C:\temp>zig version
0.9.0-dev.1444+e2a2e6c14

C:\temp>zig test foo.zig
.\foo.zig:2:20: error: unable to find 'D:\test.txt'
    _ = @embedFile("D:/test.txt");
                   ^
.\foo.zig:2:9: note: referenced here
    _ = @embedFile("D:/test.txt");
        ^

andrewrk pushed a commit that referenced this issue Oct 27, 2021
Backport a missing change from `path.zig`.

Fixes #9465
@andrewrk andrewrk added stage1 The process of building from source via WebAssembly and the C backend. and removed frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants