Skip to content

SIGSEGV on OCaml 5 due to missing SA_ONSTACK #981

@talex5

Description

@talex5

ocaml/ocaml#11497 says:

First commit makes sure that signal handlers are run on the alternate signal stack. This is required since fiber stacks are generally too small to run signal handlers on.

Test case:

open Lwt.Infix

let main () =
  for _ = 1 to 10000 do
    match Lwt_unix.fork () with
    | 0 -> Unix._exit 1
    | _child -> ()
  done

let main () =
  Lwt_main.run begin
    Lwt.pause () >>= fun () ->
    main ();
    Lwt.return_unit
  end

let () =
  Effect.Deep.match_with main ()
    { retc = ignore;
      exnc = raise;
      effc = (fun _ -> None);
    };
  Gc.full_major ()

Crashes with various errors, e.g.

$ ./_build/default/bin/main.exe 
corrupted size vs. prev_size
fish: “./_build/default/bin/main.exe” terminated by signal SIGABRT (Abort)

(originally reported as ocaml-multicore/lwt_eio#15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions