Repository navigation
Closed
Description
Has anybody seen this one before?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/opam/.opam/4.03.0/bin/coclobas-ketrew start-server -C /tmp/cocloketrew/co'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000007b5321 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:196
196 src/core/lwt.ml: No such file or directory.
[Current thread is 1 (Thread 0x7f1d11448740 (LWP 3780))]
(gdb) bt
#0 0x00000000007b5321 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:196
#1 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#2 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#3 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#4 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#5 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#6 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#7 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#8 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#9 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#10 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#11 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#12 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#13 0x00000000007b5357 in camlLwt__run_waiters_rec_1372 () at src/core/lwt.ml:201
#14 0x00000000007b567c in camlLwt__safe_run_waiters_1433 () at src/core/lwt.ml:305
#15 0x00000000007e110c in camlArray__iter_1247 () at array.ml:80
#16 0x0000000000863a0e in caml_start_program ()
#17 0x000000000085f089 in caml_callback ()
#18 0x00007f1d10b84d73 in ev_invoke_pending () from /usr/lib/x86_64-linux-gnu/libev.so.4
#19 0x000000000083ec34 in lwt_libev_loop (val_loop=<optimized out>, val_block=<optimized out>) at src/unix/lwt_libev_stubs.c:100
#20 0x000000000072d5d9 in camlLwt_engine__fun_2546 () at src/unix/lwt_engine.ml:151
#21 0x000000000072f998 in camlLwt_main__run_1327 () at src/unix/lwt_main.ml:41
#22 0x00000000005dd90d in camlKetrew__Command_line__run_main_17268 () at command_line.ml:818
#23 0x000000000054d86e in camlCocloketrew__entry () at src/test/cocloketrew.ml:4
#24 0x0000000000548339 in caml_program ()
#25 0x0000000000863a0e in caml_start_program ()
#26 0x000000000084af0d in caml_main ()
#27 0x0000000000546f4c in main ()
It's in a pretty big program that does a lot of things, so not sure whethe the backtrace means anything at all.
Metadata
Metadata
Assignees
Labels
No labels
Activity
mfp commentedon Feb 8, 2017
smondet commentedon Feb 8, 2017
@mfp yes, too many :)
Many are linked-in but should not be actually in use though (sqlite3, openssl, gnutls → this instance is using —heavily— Postgresql, and no SSL/TLS on the ocaml side):
mfp commentedon Feb 8, 2017
smondet commentedon Feb 8, 2017
@mfp of course, cannot reproduce when running with more logging :)
Will update if I get more info.
Thanks though!
copy commentedon May 13, 2017
I'm also running into this (or a very similar issue) and I hope I can provide some useful infos:
aantron commentedon May 13, 2017
Oof. Looking for it...
aantron commentedon May 13, 2017
@copy, in your case, can you reproduce this reliably or somewhat reliably? It would help me to be able to investigate it locally.
mfp commentedon May 13, 2017
That
Assert_failureis similar to #349. Just noting the connection at this point (accidental pun not averted), because we never really determined the reason.aantron commentedon May 13, 2017
Yes, both of these are due to a promise actually being resolved, when
lwt.mlexpects it to still be pending. If that's a fault inlwt.ml(and not some kind of preemptive threading race condition), it represents a pretty serious logical error, and I'd love to fix it/for us to fix it.And 🤣
edit: cc @domsj
edit2: I guess there is one more way to trigger these assertion failures besides the promise being resolved, but it's also another kind of error involving internal logical assumptions
lwt.mlmakes about promise state.copy commentedon May 13, 2017
Somewhat, it happens when stress-testing my program, so it does indeed seem to be similar to #349. My program doesn't do a lot of different lwt-related operations, mostly logging and receiving/sending a lot of websocket frames.
mfp commentedon May 13, 2017
Since we're a bit shooting in the dark, might as well try this: could you disassemble the region around the segfault, so that we can pinpoint the exact instruction?
I'd add that even though the stacktrace is very short and directly negates it, the way the segfaults happen is reminiscent of those you sometimes get when the stack overflows (and indeed, it was said in #349 that switching to tail-recursive functions elsewhere did help).
Now, there are only 2 "direct" memory accesses in
repr_rec(and then those implicit to allocate, plus stack handling for the non-tail-recursive call and the write barrier when updatingt.state). Knowing which one is failing might shed some light upon this.copy commentedon May 13, 2017
raxis 0x2001 at this point.copy commentedon May 13, 2017
Could it be a bug in my program then? I do call
Websocket_lwt.Connected_client.recvrecursively like this:mfp commentedon May 13, 2017
so we can forget about the stack, it really is bombing when reading
t.stateto pattern match inmfp commentedon May 13, 2017
Are you using flambda? Maybe (wild guess) the internal use of
%identityviolates one of its assumptions wrt. (im)mutable values and so on (RAX=tis the OCaml integer0x1000and not a pointer to the OCaml heap).1 remaining item
copy commentedon May 14, 2017
Reran with #354.
aantron commentedon May 14, 2017
Whoa, thanks!
copy commentedon Jun 12, 2017
Good news! I've been able to reproduce this issue with a minimal test case. This is based on an echo server for ocaml-websocket and a stress test written in c++ from uWebSockets.
For the server:
websocketandwebsocket-lwtfrom this repositoryjbuilder build test/bench_server.exe && ./_build/default/test/bench_server.exeFor the stress test:
g++ -std=c++11 -O3 throughput.cpp -s -o throughput -luv./throughput 1000 20 10 3000Mostly the segmentation fault appears within 3 minutes. Sometimes I don't get it and need to rerun the server and the test.
This is on OCaml 4.04.1 with lwt 3.0.0.
aantron commentedon Jun 12, 2017
Great! I still didn't get a chance to look at the VM, due primarily to other work in my queue – so this is very nice to have. I'll follow these instructions later today to see if I can reproduce the problem locally.
cc @AlexOnWork
EDIT also cc @domsj
copy commentedon Jun 25, 2017
Another update: Reading about [1] this morning, I immediately thought about this issue, as my CPU was also affected. I reproduced the fault after 5 minutes of running the stress test, then applied the microcode upgrade. I haven't been able to reproduce the issue after several hours of stress testing now.
If you're affected by this fault, try the mitigations described in [1]. You can check if your CPU is affected by this bug using this perl script.
[1] https://lists.debian.org/debian-devel/2017/06/msg00308.html
aantron commentedon Jun 25, 2017
cc @AlexOnWork, @domsj, @smondet about the hyperthreading bug:
any chance you have one of the processors listed in the link from @copy above?
I just started setting up to reproduce this on Linux in DO a few hours ago, using the latest instructions (after failing to reproduce on my MacBook). I'm going to pause that. The perl script says the DO droplet is likely not affected.
Please let me know if you observe the bug again.
Also, @copy, could you test with the new
lwt.mlon your machine, now that it has the microcode upgrade?smondet commentedon Jun 25, 2017
@aantron sorry I don't know the architecture this happened in a docker image on a cloud node (hence the
/home/opam/paths ;) ).domsj commentedon Jun 26, 2017
Hi, my processor is indeed affected.
So combined with the fact that my colleagues did not have this problem, I think we can conclude that this probably causes/caused the problems I was seeing.
I'll wait a bit more for ubuntu to include the updated microcodes package and then I'll test again
domsj commentedon Jun 26, 2017
Updated my laptop with the instructions from https://launchpad.net/~nschloe/+archive/ubuntu/intel-microcode-backports
Started the stress test that could previously reproduce my issue & left it running for a few hours and it ran without problems (usually it takes less than 30 minutes), so quite confident my issue was caused by the cpu bug
aantron commentedon Jun 27, 2017
Ok, I think we can close this issue as resolved. Thanks to all involved for debugging, running stress tests, and paying attention to mailing lists. I guess this also includes the compiler team for their work towards finding the bug :)
aantron commentedon Jun 28, 2017
We also have this blog/report. Found the link on Reddit:
Skylake bug: a detective story
aantron commentedon Jul 3, 2017
...also How I found a bug in Intel Skylake processors from Xavier Leroy.