-
Notifications
You must be signed in to change notification settings - Fork 11
Description
For example:
$ hurl.srv 127.0.0.1:8080
^C
# nothing happenshurl.srv only terminates after responding to a final request, say hurl http://localhost:8080/get. pkilling it does kill it instantly too.
Here's what I could gather with gdb:
$ egdb hurl.srv
# [...]
(gdb) run 127.0.0.1:8080
Starting program: /home/user/.opam/miou/bin/hurl.srv 127.0.0.1:8080
^C[New thread 460857 of process 5725]
[New thread 431086 of process 5725]
[New thread 184835 of process 5725]
Thread 2 received signal SIGINT, Interrupt.
[Switching to thread 460857 of process 5725]
futex () at /tmp/-:2
warning: 2 /tmp/-: No such file or directory
(gdb) info threads
Id Target Id Frame
1 thread 338321 of process 5725 _thread_sys_select () at /tmp/-:2
* 2 thread 460857 of process 5725 futex () at /tmp/-:2
3 thread 431086 of process 5725 futex () at /tmp/-:2
4 thread 184835 of process 5725 futex () at /tmp/-:2
(gdb) thread apply 1 bt
Thread 1 (thread 338321 of process 5725):
#0 _thread_sys_select () at /tmp/-:2
#1 0xc4987c91079e9fd8 in ?? ()
#2 0x000004def4d99ce2 in _libc_select_cancel (nfds=8, readfds=0x78483c5bd4a0, writefds=0x78483c5bd520, exceptfds=0x4def4d8fb2b <_thread_sys_select+27>, timeout=0x0) at /usr/src/lib/libc/sys/w_select.c:28
#3 0x000004dc1c6cc29d in caml_unix_select (readfds=5356133755072, writefds=1, exceptfds=1, timeout=<optimized out>) at select_unix.c:91
#4 <signal handler called>
#5 0x000004dc1c5874ab in camlMiou_unix.select_1434 ()
#6 0x000004dc1c5931de in camlMiou.unblock_awaits_with_system_events_2039 ()
#7 0x000004dc1c593583 in camlMiou.run_2061 ()
#8 0x000004dc1c598ec5 in camlMiou.run_inner_5845 ()
#9 0x000004dc1c5ed488 in camlCmdliner_term.fun_662 ()
#10 0x000004dc1c5f19f9 in camlCmdliner_eval.run_parser_589 ()
#11 0x000004dc1c5f2bed in camlCmdliner_eval.eval_value_inner_1728 ()
#12 0x000004dc1c5f33d0 in camlCmdliner_eval.eval_1479 ()
#13 0x000004dc1c43f99e in camlDune__exe__Srv.entry ()
#14 0x000004dc1c437487 in caml_startup.code_begin ()
#15 <signal handler called>
#16 0x000004dc1c7121cc in caml_startup_common (argv=0x78483c5bd7c8, pooling=<optimized out>) at runtime/startup_nat.c:127
#17 0x000004dc1c71227d in caml_startup_exn (argv=0x8) at runtime/startup_nat.c:134
#18 caml_startup (argv=0x8) at runtime/startup_nat.c:139
#19 caml_main (argv=0x8) at runtime/startup_nat.c:146
#20 0x000004dc1c6f4f90 in main (argc=<optimized out>, argv=0x78483c5bd4a0) at runtime/main.c:37Setting a breakpoint on _thread_sys_select shows that it's called multiple times during startup, not switching the current thread, but the last call (the one actually waiting on requests) does the switch to another thread (Id 2 in the gdb trace). I get the same behavior with select (what Miou_unix is currently based on),poll/ppoll and my WIP kqueue implementation.
The OpenBSD pthreads(3) man page mentions:
Signals handlers are normally run on the stack of the currently executing thread.
I've tried doing the same thing on another machine under Linux, and when breaking during select the current thread is still the one running select (the gdb trace shows __pselect6), not a futex thread.
I'm not sure if that's a problem on our side or on OpenBSD's, I'm not even sure to understand everything going on here, but here it is.