Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-race/rare crash with with IO #751

Open
avsm opened this issue Aug 27, 2024 · 3 comments
Open

data-race/rare crash with with IO #751

avsm opened this issue Aug 27, 2024 · 3 comments

Comments

@avsm
Copy link
Contributor

avsm commented Aug 27, 2024

Still trying to track down exactly what is causing this, but it triggers now with a small testcase in 5.2.0 and 5.3.0+trunk on x86_64 with the following program:

let () =
  Eio_main.run @@ fun env ->
  Eio.Switch.run @@ fun sw ->
  let pool = Eio.Executor_pool.create
      ~sw (Eio.Stdenv.domain_mgr env)
      ~domain_count:(Domain.recommended_domain_count () - 1)
  in
  let cwd = Eio.Stdenv.cwd env in
  let temp_files = List.init 1000 (fun _ ->
    let f = Filename.temp_file ~temp_dir:"." "stresstest" "" in
    let p = Eio.Path.(cwd / (Filename.basename f)) in
    Eio.Path.with_open_out ~create:`Never p (fun f ->
      let _ = Eio.File.pwrite_all f ~file_offset:(Optint.Int63.of_int 2000) [Cstruct.create 4096] in
      ()
    );
    p
  ) in
  let process m () =
    for _ = 0 to 1000 do
      let _ = String.make 10000 'a' in
      ignore(Eio.Path.load m)
    done
  in
  Eio.Fiber.List.iter ~max_fibers:100 (fun msg ->
    Eio.Executor_pool.submit_exn pool ~weight:0.5 (process msg)
  ) temp_files;
  List.iter Eio.Path.unlink temp_files

built with:

(executable
 (public_name test)
 (name test)
 (flags (:standard -g -runtime-variant d))
 (libraries eio_main))

It triggers the following data race reliably on Linux:

==================
WARNING: ThreadSanitizer: data race (pid=912737)
  Write of size 8 at 0x7f8561e08d08 by thread T16 (mutexes: write M0):
    #0 camlEio__core__Switch.dec_fibers_1051 lib_eio/core/switch.ml:71 (test.exe+0x1978e0) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #1 camlStdlib__Fun.finally_no_exn_330 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:30 (test.exe+0x247652) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:35 (test.exe+0x2475ae) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #3 caml_runstack <null> (test.exe+0x2f2d91) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #5 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #6 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #8 camlStdlib__Domain.body_741 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:266 (test.exe+0x2258ef) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #9 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #10 caml_callback_exn runtime/callback.c:205 (test.exe+0x2a1973) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #11 caml_callback_res runtime/callback.c:320 (test.exe+0x2a29b4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #12 domain_thread_func runtime/domain.c:1245 (test.exe+0x2a79a5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

  Previous atomic read of size 8 at 0x7f8561e08d08 by thread T40587 (mutexes: write M1, write M2):
    #0 mark_stack_push_block runtime/major_gc.c:871 (test.exe+0x2c815b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #1 caml_darken runtime/major_gc.c:1208 (test.exe+0x2ca02e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 caml_darken runtime/major_gc.c:1186 (test.exe+0x2ca02e)
    #3 scan_stack_frames runtime/fiber.c:280 (test.exe+0x2b1756) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 caml_scan_stack runtime/fiber.c:301 (test.exe+0x2b1756)
    #5 caml_darken_cont runtime/major_gc.c:1177 (test.exe+0x2c9d9f) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #6 do_some_marking runtime/major_gc.c:1009 (test.exe+0x2cafa7) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 mark runtime/major_gc.c:1124 (test.exe+0x2cb199) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #8 major_collection_slice runtime/major_gc.c:1704 (test.exe+0x2cbcb7) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #9 caml_major_collection_slice runtime/major_gc.c:1884 (test.exe+0x2ccec4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #10 caml_poll_gc_work runtime/domain.c:1874 (test.exe+0x2a8990) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #11 stw_handler runtime/domain.c:1502 (test.exe+0x2a8d81) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #12 handle_incoming runtime/domain.c:351 (test.exe+0x2a8d81)
    #13 caml_handle_incoming_interrupts runtime/domain.c:364 (test.exe+0x2a9648) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #14 caml_try_run_on_all_domains_with_spin_work runtime/domain.c:1606 (test.exe+0x2a9648)
    #15 caml_try_run_on_all_domains runtime/domain.c:1717 (test.exe+0x2a97f3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #16 major_collection_slice runtime/major_gc.c:1866 (test.exe+0x2cc892) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #17 caml_major_collection_slice runtime/major_gc.c:1884 (test.exe+0x2ccec4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #18 caml_poll_gc_work runtime/domain.c:1874 (test.exe+0x2a8990) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #19 caml_handle_gc_interrupt runtime/domain.c:1901 (test.exe+0x2aa01f) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #20 caml_do_pending_actions_res runtime/signals.c:338 (test.exe+0x2e5410) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #21 caml_alloc_small_dispatch runtime/minor_gc.c:896 (test.exe+0x2da4b4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #22 caml_garbage_collection runtime/signals_nat.c:86 (test.exe+0x2f7140) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #23 caml_call_gc <null> (test.exe+0x2f219f) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #24 camlLwt_dllist.add_r_311 src/lwt_dllist.ml:69 (test.exe+0x1c84c4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #25 camlEio__core__Switch.on_release_full_1241 lib_eio/core/switch.ml:184 (test.exe+0x198c58) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #26 camlEio_unix__Fd.of_unix_650 lib_eio/core/switch.ml:199 (test.exe+0x14c731) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #27 camlEio_posix__Low_level.with_state_1607 lib_eio_posix/low_level.ml:284 (test.exe+0x11d49d) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #28 camlEio_unix__Thread_pool.fun_749 lib_eio/unix/thread_pool.ml:71 (test.exe+0x14a677) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #29 camlThread.fun_769 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/otherlibs/systhreads/thread.ml:48 (test.exe+0x153700) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #30 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #31 caml_callback_exn runtime/callback.c:205 (test.exe+0x2a1973) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #32 caml_thread_start /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/otherlibs/systhreads/st_stubs.c:648 (test.exe+0x280703) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

  Mutex M0 (0x72b4000008e0) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1315 (libtsan.so.2+0x58bfd) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 caml_plat_mutex_init runtime/platform.c:59 (test.exe+0x2dc362) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 caml_init_domains runtime/domain.c:974 (test.exe+0x2a7634) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #3 caml_init_gc runtime/gc_ctrl.c:348 (test.exe+0x2b6ab5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 caml_startup_common runtime/startup_nat.c:106 (test.exe+0x2f1b37) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #5 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1b37)
    #6 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)
    #8 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)
    #9 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

  Mutex M1 (0x72b400000d00) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1315 (libtsan.so.2+0x58bfd) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 caml_plat_mutex_init runtime/platform.c:59 (test.exe+0x2dc362) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 caml_init_domains runtime/domain.c:974 (test.exe+0x2a7634) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #3 caml_init_gc runtime/gc_ctrl.c:348 (test.exe+0x2b6ab5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 caml_startup_common runtime/startup_nat.c:106 (test.exe+0x2f1b37) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #5 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1b37)
    #6 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)
    #8 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)
    #9 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

  Mutex M2 (0x720c00039030) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1315 (libtsan.so.2+0x58bfd) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 sync_mutex_create runtime/sync_posix.h:44 (test.exe+0x2e84aa) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 caml_ml_mutex_new runtime/sync.c:77 (test.exe+0x2e84aa)
    #3 caml_c_call <null> (test.exe+0x2f2439) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 camlEio__core__Switch.create_1177 lib_eio/core/switch.ml:127 (test.exe+0x198298) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #5 camlEio__core__Switch.fun_1376 lib_eio/core/switch.ml:152 (test.exe+0x19858b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #6 camlEio__core__Cancel.with_cc_1067 lib_eio/core/cancel.ml:118 (test.exe+0x194b3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 camlDune__exe__Test.process_822 bin/test.ml:21 (test.exe+0x115090) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #8 camlEio__Executor_pool.fun_814 lib_eio/executor_pool.ml:31 (test.exe+0x189be6) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #9 camlEio__core__Fiber.fun_1441 lib_eio/core/fiber.ml:21 (test.exe+0x19f2e6) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #10 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #11 caml_runstack <null> (test.exe+0x2f2d91) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #12 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #13 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #14 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #15 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #16 camlStdlib__Domain.body_741 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:266 (test.exe+0x2258ef) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #17 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #18 caml_callback_exn runtime/callback.c:205 (test.exe+0x2a1973) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #19 caml_callback_res runtime/callback.c:320 (test.exe+0x2a29b4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #20 domain_thread_func runtime/domain.c:1245 (test.exe+0x2a79a5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

  Thread T16 (tid=912754, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5a267) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 caml_domain_spawn runtime/domain.c:1294 (test.exe+0x2a9cbe) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 caml_c_call <null> (test.exe+0x2f2439) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #3 camlStdlib__Domain.spawn_736 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:284 (test.exe+0x225806) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 camlEio_posix__Domain_mgr.fun_1449 lib_eio_posix/domain_mgr.ml:117 (test.exe+0x128f6e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #5 camlEio_posix__Sched.fun_1761 lib_eio_posix/sched.ml:355 (test.exe+0x119f4c) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #6 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #8 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #9 camlDune__exe__Test.entry bin/test.ml:2 (test.exe+0x115211) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #10 caml_program <null> (test.exe+0x111e6e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #11 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #12 caml_startup_common runtime/startup_nat.c:127 (test.exe+0x2f1c58) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #13 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1c58)
    #14 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #15 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)
    #16 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)
    #17 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

  Thread T40587 (tid=953475, finished) created by thread T24 at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5a267) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 st_thread_create /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/otherlibs/systhreads/st_pthreads.h:50 (test.exe+0x280885) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #2 caml_thread_new /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/otherlibs/systhreads/st_stubs.c:707 (test.exe+0x280885)
    #3 caml_c_call <null> (test.exe+0x2f2439) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #4 camlThread.create_288 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/otherlibs/systhreads/thread.ml:45 (test.exe+0x153679) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #5 camlEio_unix__Thread_pool.make_thread_481 lib_eio/unix/thread_pool.ml:64 (test.exe+0x14a542) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #6 camlEio_unix__Thread_pool.submit_579 lib_eio/unix/thread_pool.ml:119 (test.exe+0x14ac39) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #7 camlEio_posix__Sched.fun_1791 lib_eio_posix/sched.ml:372 (test.exe+0x11a217) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #8 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #9 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #10 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #11 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #12 camlStdlib__Domain.body_741 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:266 (test.exe+0x2258ef) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #13 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #14 caml_callback_exn runtime/callback.c:205 (test.exe+0x2a1973) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #15 caml_callback_res runtime/callback.c:320 (test.exe+0x2a29b4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)
    #16 domain_thread_func runtime/domain.c:1245 (test.exe+0x2a79a5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)

SUMMARY: ThreadSanitizer: data race lib_eio/core/switch.ml:71 in camlEio__core__Switch.dec_fibers_1051
==================
==================                                                                                                                                                                                                                
WARNING: ThreadSanitizer: data race (pid=912737)                                                                                                                                                                                  
  Atomic read of size 8 at 0x7f8560b79f48 by thread T12 (mutexes: write M0):                                                                                                                                                      
    #0 mark_stack_push_block runtime/major_gc.c:871 (test.exe+0x2c815b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                       
    #1 caml_darken runtime/major_gc.c:1208 (test.exe+0x2ca02e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                
    #2 caml_darken runtime/major_gc.c:1186 (test.exe+0x2ca02e)                                                                                                                                                                    
    #3 scan_stack_frames runtime/fiber.c:280 (test.exe+0x2b1756) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                              
    #4 caml_scan_stack runtime/fiber.c:301 (test.exe+0x2b1756)                                                                                                                                                                    
    #5 caml_darken_cont runtime/major_gc.c:1177 (test.exe+0x2c9d9f) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                           
    #6 do_some_marking runtime/major_gc.c:1009 (test.exe+0x2cafa7) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                            
    #7 mark runtime/major_gc.c:1124 (test.exe+0x2cb199) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                       
    #8 major_collection_slice runtime/major_gc.c:1704 (test.exe+0x2cbcb7) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                     
    #9 caml_major_collection_slice runtime/major_gc.c:1884 (test.exe+0x2ccec4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                
    #10 caml_poll_gc_work runtime/domain.c:1874 (test.exe+0x2a8990) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                           
    #11 caml_handle_gc_interrupt runtime/domain.c:1901 (test.exe+0x2aa01f) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                    
    #12 caml_check_urgent_gc runtime/minor_gc.c:950 (test.exe+0x2da709) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                       
    #13 caml_alloc_string runtime/alloc.c:186 (test.exe+0x295bf4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                             
    #14 caml_create_bytes runtime/str.c:78 (test.exe+0x2e729b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                
    #15 caml_c_call <null> (test.exe+0x2f2439) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                                
    #16 camlCstruct.copy_to_string_1171 lib/cstruct.ml:207 (test.exe+0x1cd138) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                
    #17 camlEio__Path.fun_2315 lib_eio/path.ml:143 (test.exe+0x17ffba) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                        
    #18 camlEio__core__Switch.run_internal_1180 lib_eio/core/switch.ml:133 (test.exe+0x198393) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                
    #19 camlEio__core__Cancel.with_cc_1067 lib_eio/core/cancel.ml:118 (test.exe+0x194b3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                     
    #20 camlDune__exe__Test.process_822 bin/test.ml:21 (test.exe+0x115090) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                    
    #21 camlEio__Executor_pool.fun_814 lib_eio/executor_pool.ml:31 (test.exe+0x189be6) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                        
    #22 camlEio__core__Fiber.fun_1441 lib_eio/core/fiber.ml:21 (test.exe+0x19f2e6) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                            
    #23 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                            
    #24 caml_runstack <null> (test.exe+0x2f2d91) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                              
    #25 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                            
    #26 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                          
    #27 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                   
    #28 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                            
    #29 camlStdlib__Domain.body_741 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:266 (test.exe+0x2258ef) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                        
    #30 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                         
    #31 caml_callback_exn runtime/callback.c:205 (test.exe+0x2a1973) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                          
    #32 caml_callback_res runtime/callback.c:320 (test.exe+0x2a29b4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                          
    #33 domain_thread_func runtime/domain.c:1245 (test.exe+0x2a79a5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                          
                                                                                                                                                                                                                                  
  Previous write of size 8 at 0x7f8560b79f48 by thread T28 (mutexes: write M1):                                                                                                                                                   
    #0 camlEio__core__Switch.dec_fibers_1051 lib_eio/core/switch.ml:71 (test.exe+0x1978e0) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                    
    #1 camlStdlib__Fun.finally_no_exn_330 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:30 (test.exe+0x247652) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                      
    #2 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:35 (test.exe+0x2475ae) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                             
    #3 caml_runstack <null> (test.exe+0x2f2d91) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                               
    #4 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                             
    #5 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                           
    #6 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                    
    #7 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                             
    #8 camlStdlib__Domain.body_741 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:266 (test.exe+0x2258ef) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                         
    #9 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                          
    #10 caml_callback_exn runtime/callback.c:205 (test.exe+0x2a1973) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                          
    #11 caml_callback_res runtime/callback.c:320 (test.exe+0x2a29b4) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                          
    #12 domain_thread_func runtime/domain.c:1245 (test.exe+0x2a79a5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                          

  Mutex M0 (0x72b4000006d0) created at:                                                                          
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1315 (libtsan.so.2+0x58bfd) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)                                                           
    #1 caml_plat_mutex_init runtime/platform.c:59 (test.exe+0x2dc362) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                         
    #2 caml_init_domains runtime/domain.c:974 (test.exe+0x2a7634) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                             
    #3 caml_init_gc runtime/gc_ctrl.c:348 (test.exe+0x2b6ab5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                 
    #4 caml_startup_common runtime/startup_nat.c:106 (test.exe+0x2f1b37) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                      
    #5 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1b37)                                          
    #6 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                         
    #7 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)                                                
    #8 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)                                                   
    #9 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                             

  Mutex M1 (0x72b400000f10) created at:                                                                          
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1315 (libtsan.so.2+0x58bfd) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)                                                           
    #1 caml_plat_mutex_init runtime/platform.c:59 (test.exe+0x2dc362) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                         
    #2 caml_init_domains runtime/domain.c:974 (test.exe+0x2a7634) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                             
    #3 caml_init_gc runtime/gc_ctrl.c:348 (test.exe+0x2b6ab5) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                 
    #4 caml_startup_common runtime/startup_nat.c:106 (test.exe+0x2f1b37) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                      
    #5 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1b37)                                          
    #6 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                         
    #7 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)                                                
    #8 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)                                                   
    #9 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                             

  Thread T12 (tid=912750, running) created by main thread at:                                                    
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5a267) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)                                                               
    #1 caml_domain_spawn runtime/domain.c:1294 (test.exe+0x2a9cbe) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                            
    #2 caml_c_call <null> (test.exe+0x2f2439) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                                 
    #3 camlStdlib__Domain.spawn_736 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:284 (test.exe+0x225806) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                        
    #4 camlEio_posix__Domain_mgr.fun_1449 lib_eio_posix/domain_mgr.ml:117 (test.exe+0x128f6e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                 
    #5 camlEio_posix__Sched.fun_1761 lib_eio_posix/sched.ml:355 (test.exe+0x119f4c) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                           
    #6 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                             
    #7 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                           
    #8 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                    
    #9 camlDune__exe__Test.entry bin/test.ml:2 (test.exe+0x115211) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                            
    #10 caml_program <null> (test.exe+0x111e6e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                               
    #11 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                         
    #12 caml_startup_common runtime/startup_nat.c:127 (test.exe+0x2f1c58) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                     
    #13 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1c58)                                         
    #14 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                        
    #15 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)                                               
    #16 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)                                                  
    #17 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                            

  Thread T28 (tid=912766, running) created by main thread at:                                                    
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5a267) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)                                                               
    #1 caml_domain_spawn runtime/domain.c:1294 (test.exe+0x2a9cbe) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                            
    #2 caml_c_call <null> (test.exe+0x2f2439) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                                 
    #3 camlStdlib__Domain.spawn_736 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/domain.ml:284 (test.exe+0x225806) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                        
    #4 camlEio_posix__Domain_mgr.fun_1449 lib_eio_posix/domain_mgr.ml:117 (test.exe+0x128f6e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                 
    #5 camlEio_posix__Sched.fun_1761 lib_eio_posix/sched.ml:355 (test.exe+0x119f4c) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                           
    #6 camlStdlib__Fun.protect_326 /home/avsm/.opam/5.3.0+tsan/.opam-switch/build/ocaml-variants.5.3.0+trunk/stdlib/fun.ml:34 (test.exe+0x24753a) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                             
    #7 camlEio_posix__Sched.run_1355 lib_eio_posix/sched.ml:381 (test.exe+0x119644) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                           
    #8 camlEio_posix__Sched.with_sched_1218 lib_eio_posix/sched.ml:258 (test.exe+0x118959) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                    
    #9 camlDune__exe__Test.entry bin/test.ml:2 (test.exe+0x115211) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                            
    #10 caml_program <null> (test.exe+0x111e6e) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                               
    #11 caml_start_program <null> (test.exe+0x2f25b3) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                         
    #12 caml_startup_common runtime/startup_nat.c:127 (test.exe+0x2f1c58) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                     
    #13 caml_startup_common runtime/startup_nat.c:86 (test.exe+0x2f1c58)                                         
    #14 caml_startup_exn runtime/startup_nat.c:134 (test.exe+0x2f1d3b) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                        
    #15 caml_startup runtime/startup_nat.c:139 (test.exe+0x2f1d3b)                                               
    #16 caml_main runtime/startup_nat.c:146 (test.exe+0x2f1d3b)                                                  
    #17 main runtime/main.c:37 (test.exe+0x111239) (BuildId: 228a6c9ad794879ebbb16feade2d642f12a5cf5c)                                                                                                                            

SUMMARY: ThreadSanitizer: data race runtime/major_gc.c:871 in mark_stack_push_block                                                                                                                                               
==================                                      

It happens with both the uring and posix backend

@talex5
Copy link
Collaborator

talex5 commented Aug 27, 2024

The fact that it's racing with a read by the GC suggests these tsan reports are both false positives. I would expect it's perfectly reasonable for one domain to be examining the block's fields during marking in a major slice while another one is updating the count.

@OlivierNicole might know for sure.

Does it actually crash, or just give warnings from tsan? (on my machine, I only see the warnings)

@avsm
Copy link
Contributor Author

avsm commented Aug 27, 2024

I'm trying to reproduce the crash but have only gotten it once on the bigger program from which I extracted this testcase

ThreadSanitizer:DEADLYSIGNAL                                                                                                                                 
==800191==ERROR: ThreadSanitizer: SEGV on unknown address 0x557e838d93a4 (pc 0x557e83a6f782 bp 0x722c0001ff80 sp 0x7f5624dff160 T800204)
==800191==The signal is caused by a WRITE memory access.                                                                                                     
    #0 oldify_one runtime/minor_gc.c:252 (main.exe+0x413782) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)         
    #1 caml_empty_minor_heap_promote runtime/minor_gc.c:561 (main.exe+0x41495a) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #2 caml_stw_empty_minor_heap_no_major_slice runtime/minor_gc.c:792 (main.exe+0x414fc0) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #3 caml_stw_empty_minor_heap runtime/minor_gc.c:823 (main.exe+0x4152b6) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #4 stw_handler runtime/domain.c:1486 (main.exe+0x3eb508) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)         
    #5 handle_incoming runtime/domain.c:351 (main.exe+0x3eb508)                                                                                              
    #6 caml_handle_incoming_interrupts runtime/domain.c:364 (main.exe+0x3ec18b) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #7 caml_handle_gc_interrupt runtime/domain.c:1897 (main.exe+0x3ec18b)                                                                                    
    #8 caml_do_pending_actions_res runtime/signals.c:338 (main.exe+0x41e06c) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #9 caml_alloc_small_dispatch runtime/minor_gc.c:896 (main.exe+0x415514) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #10 caml_garbage_collection runtime/signals_nat.c:86 (main.exe+0x42dd78) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #11 caml_call_gc <null> (main.exe+0x42a165) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)                      
    #12 camlBase64_rfc2045.pp_base64_761 src/base64_rfc2045.ml:252 (main.exe+0x2ba8a6) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #13 camlMrmime__B64.parser_898 src/base64_rfc2045.ml:278 (main.exe+0x27d255) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d)
    #14 camlMrmime__B64.parser_898 lib/b64.ml:98 (main.exe+0x27d3a3) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d) 
    #15 camlMrmime__B64.parser_898 lib/b64.ml:98 (main.exe+0x27d3a3) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d) 
    #16 camlMrmime__B64.parser_898 lib/b64.ml:98 (main.exe+0x27d3a3) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d) 
    #17 camlMrmime__B64.parser_898 lib/b64.ml:98 (main.exe+0x27d3a3) (BuildId: 15be3c35d13b78db78a598b67ef2ce684d8ad79d) 

@talex5
Copy link
Collaborator

talex5 commented Aug 27, 2024

Here's a simpler way to trigger the tsan error (no IO, works on Linux and Posix backends):

open Eio.Std

let run_worker () =
  Switch.run ~name:"run_worker" @@ fun sw ->
  while true do
    Fiber.fork ~sw (fun () ->
        for _ = 0 to 1000 do
          ignore (String.make 10000 'a')
        done
      );
  done

let () =
  Eio_main.run @@ fun env ->
  Eio.Switch.run @@ fun sw ->
  let domain_mgr = Eio.Stdenv.domain_mgr env in
  for _ = 1 to 7 do
    Fiber.fork_daemon ~sw (fun () -> Eio.Domain_manager.run domain_mgr run_worker)
  done;
  for _ = 1 to 10000 do
    Fiber.fork ~sw (fun () ->
        for _ = 1 to 1000 do
          ignore (Sys.opaque_identity ())
        done
      )
  done

talex5 added a commit to talex5/eio that referenced this issue Sep 6, 2024
TSan warns that setting `statx_works` races with users of it. This isn't
really a problem, because we always set it to the same value, but it's
distracting when looking for other bugs.

Reported by Anil Madhavapeddy in ocaml-multicore#751.
talex5 added a commit to talex5/eio that referenced this issue Sep 6, 2024
TSan warns that setting `statx_works` races with users of it. This isn't
really a problem, because we always set it to the same value, but it's
distracting when looking for other bugs.

Reported by Anil Madhavapeddy in ocaml-multicore#751.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants