zig master + http.zig dev not compiling due to websocket
Is http.zig dev branch supposed to work with zig master (0.16.0) ? When I try to build a little program I am doing that uses http.zig dev with zig master, I get an error on websocket, imported by src/http.zig, saying "src/proto.zig:100:48: error: root source file struct 'compress.flate' has no member named 'Decompressor' ". It seems http.zig is importing an older version of websocket.zip, not the master one that is already using Io. I have removed websocket from cache and zig fetched the master version, but it seems http.zig keep installing and using an older version.
It should, but I'm a bit behind. The changes have been hard to keep up with. I'll spend some time this weekend to try to get them caught up with zig master.
the dev branch should be working for 0.16.0-dev.427+86077fe6b
broken on my linux box:
🕙 Sep 29 02:37:57.182 PM UTC-0400 wolfgangsanyer ~/Program/http.zig
❯ ../zig/zig-out/bin/zig version
0.16.0-dev.427+86077fe6b
🕙 Sep 29 02:38:14.485 PM UTC-0400 wolfgangsanyer ~/Program/http.zig
❯ ../zig/zig-out/bin/zig build test
Segmentation fault at address 0xffffffffffffff40
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/debug.zig:945:52: 0x11b90a2 in next_internal (std.zig)
const new_fp = math.add(usize, @as(*usize, @ptrFromInt(fp)).*, fp_bias) catch
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/debug.zig:868:39: 0x1165611 in next (std.zig)
var address = it.next_internal() orelse return null;
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/debug.zig:507:29: 0x1102168 in captureStackTrace (std.zig)
addr.* = it.next() orelse {
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/heap/debug_allocator.zig:515:40: 0x1164c34 in collectStackTrace (std.zig)
std.debug.captureStackTrace(first_trace_addr, &stack_trace);
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/heap/debug_allocator.zig:333:34: 0x10fefe0 in captureStackTrace (std.zig)
collectStackTrace(ret_addr, stack_addresses);
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/heap/debug_allocator.zig:801:41: 0x10dbc1b in alloc (std.zig)
bucket.captureStackTrace(ret_addr, slot_count, 0, .alloc);
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/mem/Allocator.zig:142:26: 0x10de481 in allocBytesWithAlignment__anon_6194 (std.zig)
return a.vtable.alloc(a.ptr, len, alignment, ret_addr);
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/mem/Allocator.zig:170:59: 0x118ddcc in create__anon_31711 (std.zig)
const ptr: *T = @ptrCast(try a.allocBytesWithAlignment(.of(T), @sizeOf(T), @returnAddress()));
^
/home/wolfgangsanyer/Program/http.zig/src/worker.zig:455:51: 0x112915a in init (httpz.zig)
const websocket = try allocator.create(ws.Worker(WSH));
^
/home/wolfgangsanyer/Program/http.zig/src/httpz.zig:430:49: 0x112b91e in listen (httpz.zig)
workers[i] = try Worker.init(allocator, self, &config);
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/Thread.zig:530:21: 0x112d5bc in callFn__anon_28627 (std.zig)
@call(.auto, f, args) catch |err| {
^
/home/wolfgangsanyer/Program/zig/zig-out/lib/zig/std/Thread.zig:783:30: 0x10eef99 in entryFn (std.zig)
return callFn(f, args_ptr.*);
^
???:?:?: 0x7fc7e3ea1b7a in ??? (libc.so.6)
test
└─ run test failure
error: the following command terminated unexpectedly:
./.zig-cache/o/3d11d2f490b543734a96b980b21a3974/test
Build Summary: 3/5 steps succeeded; 1 failed
test transitive failure
└─ run test failure
error: the following build command failed with exit code 1:
.zig-cache/o/995a01a4ac5c627285c4781de536a1dc/build /home/wolfgangsanyer/Program/zig/zig-out/bin/zig /home/wolfgangsanyer/Program/zig/zig-out/lib/zig /home/wolfgangsanyer/Program/http.zig .zig-cache /home/wolfgangsanyer/.cache/zig --seed 0xa0b92465 -Z8415f56d8cf6c7ab test
🕙 Sep 29 02:38:28.685 PM UTC-0400 wolfgangsanyer ~/Program/http.zig
❯
I'll dig into it and see if I can find what's going on. I'll update here if I find anything
Do you have the code somewhere? Maybe you're passing a stack value where you shouldn't?
Are you using listenInNewThread? If so, maybe https://github.com/karlseguin/http.zig/issues/144 ?
this was me trying to run httpz tests themselves
I think the issue may be upstream in websocket.zig, their tests similarly fail for me:
🕙 Sep 29 08:32:11.528 PM UTC-0400 wolfgangsanyer ~/Program/websocket.zig
❯ zig build test
Segmentation fault at address 0xffffffffffffff20
/home/wolfgangsanyer/.zvm/master/lib/std/debug.zig:945:52: 0x109c422 in next_internal (std.zig)
const new_fp = math.add(usize, @as(*usize, @ptrFromInt(fp)).*, fp_bias) catch
^
/home/wolfgangsanyer/.zvm/master/lib/std/debug.zig:868:39: 0x106be51 in next (std.zig)
var address = it.next_internal() orelse return null;
^
/home/wolfgangsanyer/.zvm/master/lib/std/debug.zig:507:29: 0x1191068 in captureStackTrace (std.zig)
addr.* = it.next() orelse {
^
/home/wolfgangsanyer/.zvm/master/lib/std/heap/debug_allocator.zig:515:40: 0x178c874 in collectStackTrace (std.zig)
std.debug.captureStackTrace(first_trace_addr, &stack_trace);
^
/home/wolfgangsanyer/.zvm/master/lib/std/heap/debug_allocator.zig:333:34: 0x1782220 in captureStackTrace (std.zig)
collectStackTrace(ret_addr, stack_addresses);
^
/home/wolfgangsanyer/.zvm/master/lib/std/heap/debug_allocator.zig:801:41: 0x177e1ab in alloc (std.zig)
bucket.captureStackTrace(ret_addr, slot_count, 0, .alloc);
^
/home/wolfgangsanyer/.zvm/master/lib/std/mem/Allocator.zig:142:26: 0x104e421 in allocBytesWithAlignment__anon_3127 (std.zig)
return a.vtable.alloc(a.ptr, len, alignment, ret_addr);
^
/home/wolfgangsanyer/.zvm/master/lib/std/mem/Allocator.zig:282:40: 0x1780a89 in allocWithSizeAndAlignment__anon_377024 (std.zig)
return self.allocBytesWithAlignment(alignment, byte_count, return_address);
^
/home/wolfgangsanyer/.zvm/master/lib/std/mem/Allocator.zig:270:89: 0x178d5cc in alloc__anon_379206 (std.zig)
const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address));
^
/home/wolfgangsanyer/Program/websocket.zig/src/server/server.zig:231:52: 0x178945d in listen__anon_379149 (websocket.zig)
const threads = try allocator.alloc(Thread, worker_count);
^
/home/wolfgangsanyer/.zvm/master/lib/std/Thread.zig:530:21: 0x178bebc in callFn__anon_379019 (std.zig)
@call(.auto, f, args) catch |err| {
^
/home/wolfgangsanyer/.zvm/master/lib/std/Thread.zig:783:30: 0x17815d9 in entryFn (std.zig)
return callFn(f, args_ptr.*);
^
???:?:?: 0x7f0597481b7a in ??? (libc.so.6)
test
└─ run test failure
error: the following command terminated unexpectedly:
./.zig-cache/o/b49bf5e8383bd3c09dc7b1d2e082f405/test
Build Summary: 2/4 steps succeeded; 1 failed
test transitive failure
└─ run test failure
error: the following build command failed with exit code 1:
.zig-cache/o/31c57241863880b84ca3918324cadc90/build /home/wolfgangsanyer/.zvm/master/zig /home/wolfgangsanyer/.zvm/master/lib /home/wolfgangsanyer/Program/websocket.zig .zig-cache /home/wolfgangsanyer/.cache/zig --seed 0x540e21af -Z5ba972d8ffe4fb29 test
kind of same problem here (linux).
/home/kalapalo/programas/zig/testhttpz > zig-out/bin/testhttpz
General protection exception (no address available)
/opt/zig/lib/std/heap/debug_allocator.zig:755:42: 0x119ede9 in alloc (std.zig)
const slot_index = bucket.allocated_count;
^
/opt/zig/lib/std/mem/Allocator.zig:142:26: 0x10bbca1 in allocBytesWithAlignment__anon_8889 (std.zig)
return a.vtable.alloc(a.ptr, len, alignment, ret_addr);
^
/opt/zig/lib/std/mem/Allocator.zig:170:59: 0x119219c in create__anon_24265 (std.zig)
const ptr: *T = @ptrCast(try a.allocBytesWithAlignment(.of(T), @sizeOf(T), @returnAddress()));
^
/home/kalapalo/.cache/zig/p/httpz-0.0.0-PNVzrCfFBgDbCovnXYvDsbdflmgGyuNAjXSQTUrzqxAz/src/worker.zig:455:51: 0x118808a in init (httpz.zig)
const websocket = try allocator.create(ws.Worker(WSH));
^
/home/kalapalo/.cache/zig/p/httpz-0.0.0-PNVzrCfFBgDbCovnXYvDsbdflmgGyuNAjXSQTUrzqxAz/src/httpz.zig:430:49: 0x118a852 in listen (httpz.zig)
workers[i] = try Worker.init(allocator, self, &config);
^
...
The websocket thing was a local problem of mine here, BTW, an old dependency in my build.zig.zon. I have removed it. Title seems misleading now.