get error message: Segmentation fault
I have successfully compiling (make) using build-shared.sh, and also can run when I am using command: qjs basic.js But, when I try to visit using curl, I get this error message: curl http://localhost:8080/ curl: (52) Empty reply from server
and also in the terminal I get this message: Segmentation fault (core dumped)
And then the server is stop.
Is there any clue to solve this problem, as infomation: I am using Ubuntu Server 20.04.1. Thank you for the help.
Regards, jhsembiring
Hi @jhsembiring20,
thank you for your interest in the project. Unfortunately, at the moment I am not supporting it in the way it probably deserves. You are free to fork it and try to fix the bug. Good luck!
Nifty project. I like the idea of not using 2M LOC (node.js) for a tiny web server.
But I can't get the example/basic.js to work. I was about to open a new issue when I discovered the symptoms match this one pretty well.
I can appreciate that you're not available for support, but I want to save my state before I move on to something else.
🚩 Reproduction Steps
- Clone at a9ad3fd
- Fetch
regexparam.js,httpserver.h - Comment out line 650 of
httpserver.h(include common.h) - Build the shared object:
gcc -Wall -O2 -fPIC -DJS_SHARED_LIBRARY -DEPOLL -I../quickjs -shared -o quickwebserver.so c/quickwebserver.c - Run the example:
qjs ./example/basic.js; seeQWS server running at http://localhost:8080 - Open https://localhost:3000
- 💥 blammo
🧵 GDB Backtrace
$ gdb --args ../build/qjs example/basic.js
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
...
Reading symbols from ../build/qjs...
(gdb) run
Starting program: /home/connolly/projects/finquick/packages/fin-q/build/qjs example/basic.js
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7c93640 (LWP 2631486)]
Thread 2 "qjs" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7c93640 (LWP 2631486)]
__strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex.S:77
77 ../sysdeps/x86_64/multiarch/strlen-evex.S: No such file or directory.
(gdb) bt
#0 __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex.S:77
#1 0x00007ffff7fb3b51 in parseHttp () from ./quickwebserver.so
#2 0x00007ffff7fb3df4 in requestCallback () from ./quickwebserver.so
#3 0x00007ffff7fb1fcd in _hs_parse_buffer_and_exec_user_cb () from ./quickwebserver.so
#4 0x00007ffff7fb341c in _hs_read_socket_and_handle_return_code () from ./quickwebserver.so
#5 0x00007ffff7fb2cc3 in hs_server_run_event_loop () from ./quickwebserver.so
#6 0x00007ffff7fb2f68 in startServer () from ./quickwebserver.so
#7 0x00005555555afcaf in js_call_c_function (ctx=<optimized out>, func_obj=..., this_obj=..., argc=<optimized out>, argv=<optimized out>, flags=<optimized out>) at quickjs.c:16570
#8 0x0000555555574196 in JS_CallInternal (caller_ctx=0x0, func_obj=..., this_obj=..., new_target=..., argc=-268306016, argv=0x7ffff7c928a0, flags=0) at quickjs.c:16765
#9 0x0000555555573d9a in JS_CallInternal (caller_ctx=0x0, func_obj=..., this_obj=..., new_target=..., argc=-268306016, argv=0x7ffff7c92c90, flags=2) at quickjs.c:17141
#10 0x00005555555d62e7 in JS_Call (ctx=ctx@entry=0x7ffff00015c0, func_obj=..., this_obj=..., argc=argc@entry=1, argv=0x7ffff7c92c90) at quickjs.c:19342
#11 0x0000555555603dc3 in handle_posted_message (rt=<optimized out>, port=0x7ffff001f7d0, ctx=0x7ffff00015c0) at quickjs-libc.c:2389
#12 js_os_poll (ctx=0x7ffff00015c0) at quickjs-libc.c:2612
#13 0x0000555555604102 in js_std_loop (ctx=ctx@entry=0x7ffff00015c0) at quickjs-libc.c:4250
#14 0x0000555555604376 in worker_func (opaque=0x5555556db100) at quickjs-libc.c:3610
#15 0x00007ffff7d2bac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#16 0x00007ffff7dbd850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) q
🧪 Environment
- OS: Linux (x86_64)
- GCC: 11.4.0
- QuickJS: 2025-05-24 15:43 bb986e5
- quickwebserver: 2025-04-22 11:26 a9ad3fd