ocamlfuse
ocamlfuse copied to clipboard
Mainloop crashes when started in background if compiler version >= 5
The process crashes with SIGABRT
after fork
that is called by fuse_setup
(here) when it calls fuse_exited
(because it is blocking).
Steps to reproduce:
make
make example
mkdir /tmp/ocamlfuse/
_build/default/example/hello.exe /tmp/ocamlfuse/
core dumps. Stack trace:
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=139902335400832) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=139902335400832) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=139902335400832, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007f3d8cc42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007f3d8cc287f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x000055de73d225b2 in caml_fatal_error (msg=msg@entry=0x55de73d33ba7 "Fatal error during %s: %s\n") at runtime/misc.c:122
#6 0x000055de73d23005 in caml_plat_fatal_error (action=action@entry=0x55de73d34bfb "unlock", err=<optimized out>) at runtime/platform.c:41
#7 0x000055de73d0db91 in check_err (err=<optimized out>, action=0x55de73d34bfb "unlock") at runtime/caml/platform.h:143
#8 caml_plat_unlock (m=<optimized out>) at runtime/caml/platform.h:176
#9 caml_release_domain_lock () at runtime/domain.c:1706
#10 0x000055de73cfadcb in st_bt_lock_release (m=0x55de73d9c348 <thread_table+8>)
at /home/alex/.opam/5.1.1/.opam-switch/build/ocaml-base-compiler.5.1.1/otherlibs/systhreads/st_pthreads.h:149
#11 st_masterlock_release (m=0x55de73d9c348 <thread_table+8>) at /home/alex/.opam/5.1.1/.opam-switch/build/ocaml-base-compiler.5.1.1/otherlibs/systhreads/st_pthreads.h:173
#12 0x000055de73d26976 in caml_enter_blocking_section () at runtime/signals.c:151
#13 0x000055de73cfa6c2 in camlidl_Fuse_bindings_fuse_exited (_v_f=<optimized out>) at Fuse_bindings_stubs.c:759
#14 <signal handler called>
#15 0x000055de73ca77a5 in camlFuse__Fuse_lib.fuse_loop_684 () at lib/Fuse_lib.ml:44
#16 <signal handler called>
#17 0x000055de73d0a57e in caml_callback2_exn (closure=<optimized out>, arg1=<optimized out>, arg2=<optimized out>, arg2@entry=3) at runtime/callback.c:225
#18 0x000055de73d0a8cd in caml_callback2 (closure=<optimized out>, arg1=<optimized out>, arg2=arg2@entry=3) at runtime/callback.c:298
#19 0x000055de73cf866b in mainloop (f=f@entry=0x55de74ed7850, multithreaded=1) at Fuse_util.c:664
#20 0x000055de73cf8763 in ml_fuse_main (argc=argc@entry=2, argv=argv@entry=0x55de74ed7470, op=0x55de73d9c1a0 <ops>) at Fuse_util.c:685
#21 0x000055de73cfa67b in camlidl_Fuse_bindings_ml_fuse_main (_v_argv=<optimized out>, _v_op=139902064778264) at Fuse_bindings_stubs.c:746
#22 <signal handler called>
#23 0x000055de73ca8809 in camlFuse.main_874 () at lib/Fuse.ml:157
#24 0x000055de73ca7241 in camlDune__exe__Hello.entry () at example/hello.ml:44
#25 0x000055de73ca443b in caml_program ()
#26 <signal handler called>
#27 0x000055de73d2d536 in caml_startup_common (pooling=<optimized out>, argv=0x7fffc58fead8) at runtime/startup_nat.c:132
#28 caml_startup_common (argv=0x7fffc58fead8, pooling=<optimized out>) at runtime/startup_nat.c:88
#29 0x000055de73d2d5af in caml_startup_exn (argv=<optimized out>) at runtime/startup_nat.c:139
#30 caml_startup (argv=<optimized out>) at runtime/startup_nat.c:144
#31 caml_main (argv=<optimized out>) at runtime/startup_nat.c:151
#32 0x000055de73ca4092 in main (argc=<optimized out>, argv=<optimized out>) at runtime/main.c:37
Strace output:
set_robust_list(0x7ff00ba2de60, 24) = 0
setsid() = 7478
chdir("/") = 0
openat(AT_FDCWD, "/dev/null", O_RDWR) = 6
dup2(6, 0) = 0
dup2(6, 1) = 1
dup2(6, 2) = 2
close(6) = 0
write(5, "\1", 1) = 1
close(4) = 0
close(5) = 0
rt_sigaction(SIGHUP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=0x7ff00bb31140, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7ff00b842520}, NULL, 8) = 0
rt_sigaction(SIGINT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x7ff00bb31140, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7ff00b842520}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=0x7ff00bb31140, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7ff00b842520}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7ff00b842520}, NULL, 8) = 0
write(2, "Fatal error: ", 13) = 13
write(2, "Fatal error during unlock: Opera"..., 51) = 51
write(2, "\n", 1) = 1
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
gettid() = 7478
getpid() = 7478
tgkill(7478, 7478, SIGABRT) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=7478, si_uid=0} ---
+++ killed by SIGABRT (core dumped) +++
This issue causes also the issue astrada/google-drive-ocamlfuse#840. And it can be solved as explained in the PR ocaml-multicore/ocaml-multicore#491, resetting the runtime locks after fork
.