You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran the endpoint example to play around with it for a while. I added a couple users. Deleted a few. Changed a few. However, When I tried to add another it crashed. Now sure why because I am just learning programming and am using zap as a learning tool due to my interest in REST servers.
Let me know if me creating this issue is not very useful or how I could present issue better.
`
username@msiL:~/zig/zap$ zig build run-endpoint
Listening on 0.0.0.0:3000
127.0.0.1 - - [Sun, 04 Aug 2024 18:07:44 GMT] "GET /users HTTP/1.1" 200 111b 228us
127.0.0.1 - - [Sun, 04 Aug 2024 18:07:52 GMT] "POST /users HTTP/1.1" 200 22b 153us
127.0.0.1 - - [Sun, 04 Aug 2024 18:07:52 GMT] "GET /users HTTP/1.1" 200 162b 201us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:13 GMT] "POST /users HTTP/1.1" 200 22b 548us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:13 GMT] "GET /users HTTP/1.1" 200 213b 878us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:22 GMT] "POST /users HTTP/1.1" 200 22b 159us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:22 GMT] "GET /users HTTP/1.1" 200 263b 208us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:32 GMT] "DELETE /users/1 HTTP/1.1" 200 22b 190us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:32 GMT] "GET /users HTTP/1.1" 200 212b 198us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:47 GMT] "PATCH /users/2 HTTP/1.1" 200 25b 544us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:47 GMT] "GET /users HTTP/1.1" 200 204b 895us
127.0.0.1 - - [Sun, 04 Aug 2024 18:09:01 GMT] "DELETE /users/2 HTTP/1.1" 200 22b 80us
127.0.0.1 - - [Sun, 04 Aug 2024 18:09:01 GMT] "GET /users HTTP/1.1" 200 153b 979us
127.0.0.1 - - [Sun, 04 Aug 2024 18:09:14 GMT] "POST /users HTTP/1.1" 200 22b 620us
thread 3348 panic: reached unreachable code
/home/username/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/std/debug.zig:412:14: 0x105b20c in assert (endpoint)
if (!ok) unreachable; // assertion failure
^
/home/username/zig/zap/examples/endpoint/users.zig:133:21: 0x10a8a3f in toJSON (endpoint)
std.debug.assert(self.count == l.items.len);
^
/home/username/zig/zap/examples/endpoint/userweb.zig:76:27: 0x10943c3 in listUsers (endpoint)
if (self._users.toJSON()) |json| {
^
/home/username/zig/zap/examples/endpoint/userweb.zig:62:34: 0x105e75c in getUser (endpoint)
return self.listUsers(r);
^
/home/username/zig/zap/src/endpoint.zig:64:36: 0x10940db in onRequest (endpoint)
.GET => self.settings.get.?(self, r),
^
/home/username/zig/zap/src/endpoint.zig:320:32: 0x105e4ad in onRequest (endpoint)
e.onRequest(r);
^
/home/username/zig/zap/src/zap.zig:251:27: 0x105815b in theOneAndOnlyRequestCallBack (endpoint)
on_request(req);
^
facil.io/lib/facil/http/http_internal.c:53:3: 0x117772b in http_on_request_handler______internal (/home/username/zig/zap/facil.io/lib/facil/http/http_internal.c)
settings->on_request(h);
^
facil.io/lib/facil/http/http1.c:553:3: 0x1185bf1 in http1_on_request (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
http_on_request_handler______internal(&http1_pr2handle(p), p->p.settings);
^
facil.io/lib/facil/http/parsers/http1_parser.h:859:9: 0x11851ea in http1_parse (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
if (((parser->state.reserved & HTTP1_P_FLAG_RESPONSE)
^
facil.io/lib/facil/http/http1.c:689:9: 0x1184ba3 in http1_consume_data (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
i = http1_parse(&p->parser, p->buf + (org_len - p->buf_len), p->buf_len);
^
facil.io/lib/facil/http/http1.c:735:3: 0x1184af9 in http1_on_data (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
http1_consume_data(uuid, p);
^
facil.io/lib/facil/fio.c:2213:3: 0x1143345 in deferred_on_data (/home/username/zig/zap/facil.io/lib/facil/fio.c)
pr->on_data((intptr_t)uuid, pr);
^
facil.io/lib/facil/fio.c:1011:3: 0x114255a in fio_defer_perform_single_task_for_queue (/home/username/zig/zap/facil.io/lib/facil/fio.c)
task.func(task.arg1, task.arg2);
^
facil.io/lib/facil/fio.c:1049:10: 0x11424e4 in fio_defer_perform (/home/username/zig/zap/facil.io/lib/facil/fio.c)
fio_defer_perform_single_task_for_queue(&task_queue_normal) == 0)
^
facil.io/lib/facil/fio.c:1089:5: 0x1168c65 in fio_defer_cycle (/home/username/zig/zap/facil.io/lib/facil/fio.c)
fio_defer_perform();
^
./nptl/pthread_create.c:447:8: 0x773ed849ca93 in start_thread (pthread_create.c)
../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0: 0x773ed8529c3b in __clone3 (../sysdeps/unix/sysv/linux/x86_64/clone3.S)
???:?:?: 0x0 in ??? (???)
run-endpoint
└─ run endpoint failure
error: the following command terminated unexpectedly:
/home/username/zig/zap/.zig-cache/o/97132c177edea0f3203d67a15e6ad752/endpoint
Build Summary: 3/5 steps succeeded; 1 failed (disable with --summary none)
run-endpoint transitive failure
└─ run endpoint failure
error: the following build command failed with exit code 1:
/home/username/zig/zap/.zig-cache/o/5ab078230cc4864cd7577ad1f2433f96/build /home/username/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig /home/username/zig/zap /home/username/zig/zap/.zig-cache /home/username/.cache/zig --seed 0x857b6bbc -Zc9dd418d7f8d2139 run-endpoint
`
The text was updated successfully, but these errors were encountered:
Hi, interesting. The error comes from this assert.
So maybe, the bookkeeping of self.count is not done correctly when inserting after a delete. It's an interesting bug to play around with. You see here that a count is being kept. It needs to be in sync with the hashmap. See also the potential race condition comments.
I hope that helps. It seems that your usage pattern :
I ran the endpoint example to play around with it for a while. I added a couple users. Deleted a few. Changed a few. However, When I tried to add another it crashed. Now sure why because I am just learning programming and am using zap as a learning tool due to my interest in REST servers.
Let me know if me creating this issue is not very useful or how I could present issue better.
`
username@msiL:~/zig/zap$ zig build run-endpoint
Listening on 0.0.0.0:3000
127.0.0.1 - - [Sun, 04 Aug 2024 18:07:44 GMT] "GET /users HTTP/1.1" 200 111b 228us
127.0.0.1 - - [Sun, 04 Aug 2024 18:07:52 GMT] "POST /users HTTP/1.1" 200 22b 153us
127.0.0.1 - - [Sun, 04 Aug 2024 18:07:52 GMT] "GET /users HTTP/1.1" 200 162b 201us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:13 GMT] "POST /users HTTP/1.1" 200 22b 548us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:13 GMT] "GET /users HTTP/1.1" 200 213b 878us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:22 GMT] "POST /users HTTP/1.1" 200 22b 159us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:22 GMT] "GET /users HTTP/1.1" 200 263b 208us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:32 GMT] "DELETE /users/1 HTTP/1.1" 200 22b 190us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:32 GMT] "GET /users HTTP/1.1" 200 212b 198us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:47 GMT] "PATCH /users/2 HTTP/1.1" 200 25b 544us
127.0.0.1 - - [Sun, 04 Aug 2024 18:08:47 GMT] "GET /users HTTP/1.1" 200 204b 895us
127.0.0.1 - - [Sun, 04 Aug 2024 18:09:01 GMT] "DELETE /users/2 HTTP/1.1" 200 22b 80us
127.0.0.1 - - [Sun, 04 Aug 2024 18:09:01 GMT] "GET /users HTTP/1.1" 200 153b 979us
127.0.0.1 - - [Sun, 04 Aug 2024 18:09:14 GMT] "POST /users HTTP/1.1" 200 22b 620us
thread 3348 panic: reached unreachable code
/home/username/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/std/debug.zig:412:14: 0x105b20c in assert (endpoint)
if (!ok) unreachable; // assertion failure
^
/home/username/zig/zap/examples/endpoint/users.zig:133:21: 0x10a8a3f in toJSON (endpoint)
std.debug.assert(self.count == l.items.len);
^
/home/username/zig/zap/examples/endpoint/userweb.zig:76:27: 0x10943c3 in listUsers (endpoint)
if (self._users.toJSON()) |json| {
^
/home/username/zig/zap/examples/endpoint/userweb.zig:62:34: 0x105e75c in getUser (endpoint)
return self.listUsers(r);
^
/home/username/zig/zap/src/endpoint.zig:64:36: 0x10940db in onRequest (endpoint)
.GET => self.settings.get.?(self, r),
^
/home/username/zig/zap/src/endpoint.zig:320:32: 0x105e4ad in onRequest (endpoint)
e.onRequest(r);
^
/home/username/zig/zap/src/zap.zig:251:27: 0x105815b in theOneAndOnlyRequestCallBack (endpoint)
on_request(req);
^
facil.io/lib/facil/http/http_internal.c:53:3: 0x117772b in http_on_request_handler______internal (/home/username/zig/zap/facil.io/lib/facil/http/http_internal.c)
settings->on_request(h);
^
facil.io/lib/facil/http/http1.c:553:3: 0x1185bf1 in http1_on_request (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
http_on_request_handler______internal(&http1_pr2handle(p), p->p.settings);
^
facil.io/lib/facil/http/parsers/http1_parser.h:859:9: 0x11851ea in http1_parse (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
if (((parser->state.reserved & HTTP1_P_FLAG_RESPONSE)
^
facil.io/lib/facil/http/http1.c:689:9: 0x1184ba3 in http1_consume_data (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
i = http1_parse(&p->parser, p->buf + (org_len - p->buf_len), p->buf_len);
^
facil.io/lib/facil/http/http1.c:735:3: 0x1184af9 in http1_on_data (/home/username/zig/zap/facil.io/lib/facil/http/http1.c)
http1_consume_data(uuid, p);
^
facil.io/lib/facil/fio.c:2213:3: 0x1143345 in deferred_on_data (/home/username/zig/zap/facil.io/lib/facil/fio.c)
pr->on_data((intptr_t)uuid, pr);
^
facil.io/lib/facil/fio.c:1011:3: 0x114255a in fio_defer_perform_single_task_for_queue (/home/username/zig/zap/facil.io/lib/facil/fio.c)
task.func(task.arg1, task.arg2);
^
facil.io/lib/facil/fio.c:1049:10: 0x11424e4 in fio_defer_perform (/home/username/zig/zap/facil.io/lib/facil/fio.c)
fio_defer_perform_single_task_for_queue(&task_queue_normal) == 0)
^
facil.io/lib/facil/fio.c:1089:5: 0x1168c65 in fio_defer_cycle (/home/username/zig/zap/facil.io/lib/facil/fio.c)
fio_defer_perform();
^
./nptl/pthread_create.c:447:8: 0x773ed849ca93 in start_thread (pthread_create.c)
../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0: 0x773ed8529c3b in __clone3 (../sysdeps/unix/sysv/linux/x86_64/clone3.S)
???:?:?: 0x0 in ??? (???)
run-endpoint
└─ run endpoint failure
error: the following command terminated unexpectedly:
/home/username/zig/zap/.zig-cache/o/97132c177edea0f3203d67a15e6ad752/endpoint
Build Summary: 3/5 steps succeeded; 1 failed (disable with --summary none)
run-endpoint transitive failure
└─ run endpoint failure
error: the following build command failed with exit code 1:
/home/username/zig/zap/.zig-cache/o/5ab078230cc4864cd7577ad1f2433f96/build /home/username/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig /home/username/zig/zap /home/username/zig/zap/.zig-cache /home/username/.cache/zig --seed 0x857b6bbc -Zc9dd418d7f8d2139 run-endpoint
`
The text was updated successfully, but these errors were encountered: