http.zig icon indicating copy to clipboard operation
http.zig copied to clipboard

raceconditions

Open adrian4096 opened this issue 9 months ago • 3 comments

I ran into

thread 546199 panic: switch on corrupt value
Unwind error at address `:0x10c36e3` (error.AddressOutOfRange), trace may be incomplete

/home/adrian/.cache/zig/p/httpz-0.0.0-PNVzrGu3BgAIRvYiWsbvVbzUyZg1-rzoT71hVSeLCHz7/src/worker.zig:564:49: 0x125efa3 in run (httpz.zig)
                        .recv => |conn| switch (conn.protocol) {
                                                ^
/home/adrian/projects/tar/zig-linux/lib/std/Thread.zig:488:13: 0x1236ab8 in callFn__anon_33979 (std.zig)
            @call(.auto, f, args);
            ^
/home/adrian/projects/tar/zig-linux/lib/std/Thread.zig:757:30: 0x12127cd in entryFn (std.zig)
                return callFn(f, args_ptr.*);
                             ^
aborting due to recursive panic

while creating 100 connections to a slow endpoint (1.65s avg. lat.)

with for x in {0..100}; do curl http://localhost:1024/api/1 --output /dev/null & done

After that i compiled with threadsan and came across a lot of raceconditions. I think most of theese should be fixed asap as they seem to be causing real problems.

https://pastebin.com/SbDL8Z1a

adrian4096 avatar May 12 '25 13:05 adrian4096

I can replicate getting a bunch of tsan errors with zig build test -Dtsan, I'm willing to take a look to try to resolve (some of?) these.

ezzieyguywuf avatar Jun 14 '25 12:06 ezzieyguywuf

See #140 for some small changes that address the ThreadSanitizer-discovered races.

ezzieyguywuf avatar Jun 14 '25 22:06 ezzieyguywuf

Note: the above report is for an old version. I suggest the issue remain open until the underlying issue is fixed.

adrian4096 avatar Oct 19 '25 18:10 adrian4096