karlseguin / http.zig

An HTTP/1.1 server for zig
MIT License
454 stars 31 forks source link

Websocket align fix #39

Closed travisstaloch closed 5 months ago

travisstaloch commented 5 months ago

here is the error from before the second commit

tmp/http.zig $ zig build test
.....warning: httpz: unhandled exception for request: /fail
Err: error.TestUnhandledError
..............expected 12, found 2

================================================================================
"websocket: upgrade" - TestExpectedEqual
================================================================================
/media/travis/data/Users/Travis/Documents/Code/zig/zig/download/0.12.0-dev.2540+776cd673f/files/lib/std/testing.zig:93:17: 0x10ca11b in expectEqualInner__anon_6808 (test)
                return error.TestExpectedEqual;
                ^
/tmp/http.zig/src/t.zig:12:5: 0x10ca18b in expectEqual__anon_6807 (test)
    try std.testing.expectEqual(@as(@TypeOf(actual), expected), actual);
    ^
/tmp/http.zig/src/httpz.zig:933:5: 0x10caa7c in test.websocket: upgrade (test)
    try t.expectEqual(12, n);
    ^
.............................................................
79 of 80 tests passed

Slowest 5 tests: 
  2962.55ms httpz: router groups
  5203.85ms httpz: writer re-use
  18999.85ms    response: write header_buffer_size
  26879.47ms    response: writer fuzz
  90680.77ms    response: json fuzz

test
└─ run test failure
error: the following command exited with error code 1:
/tmp/http.zig/zig-cache/o/cdf9fc59df35d7fc512a291787abaa57/test 
Build Summary: 1/3 steps succeeded; 1 failed (disable with --summary none)
test transitive failure
└─ run test failure
error: the following build command failed with exit code 1:
/tmp/http.zig/zig-cache/o/8376579579775ee1e93265025a03788b/build /media/travis/data/Users/Travis/Documents/Code/zig/zig/download/0.12.0-dev.2540+776cd673f/files/zig /tmp/http.zig /tmp/http.zig/zig-cache /home/travis/.cache/zig --seed 0x1d7a71c6 test
travisstaloch commented 5 months ago

here is the panic from before either of these commits:

/tmp/http.zig $ zig build test
...thread 430645 panic: incorrect alignment

====== expected this output: =========
HTTP/1.1 404 
Content-Length: 9

Not Found␃

======== instead found this: =========
␃

======================================
First difference occurs on line 1:
expected:
HTTP/1.1 404 
^ ('\x48')
found:

^ (end of string)

================================================================================
"httpz: no route" - TestExpectedEqual
================================================================================
/tmp/http.zig/src/worker.zig:238:61: 0x14a220d in processSignal (test)
                const conn: *Conn = @ptrFromInt(@as(*usize, @alignCast(@ptrCast(buf[data_start..data_end]))).*);
                                                            ^
/tmp/http.zig/src/worker.zig:132:47: 0x14118fa in run (test)
                        if (self.processSignal(signal)) {
                                              ^
/media/travis/data/Users/Travis/Documents/Code/zig/zig/download/0.12.0-dev.2540+776cd673f/files/lib/std/Thread.zig:411:13: 0x1385083 in callFn__anon_59407 (test)
            @call(.auto, f, args);
            ^
/media/travis/data/Users/Travis/Documents/Code/zig/zig/download/0.12.0-dev.2540+776cd673f/files/lib/std/Thread.zig:679:30: 0x12f26a2 in entryFn (test)
                return callFn(f, args_ptr.*);
                             ^
./nptl/pthread_create.c:442:8: 0x784f86494ac2 in start_thread (pthread_create.c)