Zig Version
0.11.0-dev.2648+3cd19dd89
Steps to Reproduce and Observed Behavior
Note: This is almost certainly a bug in std.http rather than the build system.
- Create a minimal
build.zig:
const std = @import("std");
pub fn build(b: *std.Build) void {
_ = b;
}
- Create a
build.zig.zon with a link to reproduce the bug:
.{
.name = "test",
.version = "0.0.0",
.dependencies = .{
.test_dep = .{
// The code of this repo is likely not important, it's just a link that allows to reproduce this.
.url = "https://github.com/lordmzte/dawn/archive/9e2a193db129ebaf42eccfb9d6bb40055645c5d9.tar.gz",
},
},
}
-
zig build
-
The build will fail with one of two errors, seemingly at random:
error: TarComponentsOutsideStrippedPrefix
error: BadReaderState
Note that the tar archive the link points to is very large (>90MB). I suspect that this causes the GitHub server to use chunked encoding, which may cause either invalid data or a crash in the HTTP implementation in the two possible cases.
This is the stack trace produced by a debug build of Zig in the former case:
error: TarComponentsOutsideStrippedPrefix
/home/lordmzte/dev/zig/lib/std/tar.zig:181:13: 0x6000f17 in stripComponents (zig)
return error.TarComponentsOutsideStrippedPrefix;
^
/home/lordmzte/dev/zig/lib/std/tar.zig:130:35: 0x6001c2c in pipeToFileSystem__anon_49378 (zig)
const file_name = try stripComponents(unstripped_file_name, options.strip_components);
^
/home/lordmzte/dev/zig/src/Package.zig:561:5: 0x6002a57 in unpackTarball__anon_49145 (zig)
try std.tar.pipeToFileSystem(out_dir, decompress.reader(), .{
^
/home/lordmzte/dev/zig/src/Package.zig:490:13: 0x60139ea in fetchAndUnpack (zig)
try unpackTarball(gpa, &req, tmp_directory.handle, std.compress.gzip);
^
/home/lordmzte/dev/zig/src/Package.zig:282:25: 0x6018e6b in fetchAndAddDependencies (zig)
const sub_pkg = try fetchAndUnpack(
^
/home/lordmzte/dev/zig/src/main.zig:4402:13: 0x5e7a46a in cmdBuild (zig)
try fetch_result;
^
/home/lordmzte/dev/zig/src/main.zig:298:9: 0x5e46dfb in mainArgs (zig)
return cmdBuild(gpa, arena, cmd_args);
^
/home/lordmzte/dev/zig/src/main.zig:211:5: 0x5e458eb in main (zig)
return mainArgs(gpa, arena, args);
^
Expected Behavior
The dependency is downloaded.
Zig Version
0.11.0-dev.2648+3cd19dd89
Steps to Reproduce and Observed Behavior
Note: This is almost certainly a bug in
std.httprather than the build system.build.zig:build.zig.zonwith a link to reproduce the bug:.{ .name = "test", .version = "0.0.0", .dependencies = .{ .test_dep = .{ // The code of this repo is likely not important, it's just a link that allows to reproduce this. .url = "https://github.com/lordmzte/dawn/archive/9e2a193db129ebaf42eccfb9d6bb40055645c5d9.tar.gz", }, }, }zig buildThe build will fail with one of two errors, seemingly at random:
error: TarComponentsOutsideStrippedPrefixerror: BadReaderStateNote that the tar archive the link points to is very large (>90MB). I suspect that this causes the GitHub server to use chunked encoding, which may cause either invalid data or a crash in the HTTP implementation in the two possible cases.
This is the stack trace produced by a debug build of Zig in the former case:
Expected Behavior
The dependency is downloaded.