[ANN] Lwt.6.0.0~alpha (direct-style)

Is the release of Lwt-6 a suitable opportunity to drop the Lwt_process module, as I don’t think it gives Lwt a good look?

That is because that module can no longer be safely used, as Lwt implicitly starts Thread.t threads when encountering blocking calls, and Lwt_unix.set_default_async_method is no longer able to change this in recent versions of Lwt. The problem is that Lwt_process calls up Unix.fork (via Lwt_unix.fork) and also Unix.exec*, none of which is thread safe.

About Unix.fork the OCaml documentation says “[Unix.fork] fails if the OCaml process is multi-core (any domain has been spawned). In addition, if any thread from the Thread module has been spawned, then the child process might be in a corrupted state.”

About the Unix.exec* functions, those can allocate memory with malloc and so are not async-signal-safe and so not thread/domain safe (Unix.create_process_env might not be multi-thread safe · Issue #12395 · ocaml/ocaml · GitHub).

There are also some things in Lwt_unix which are unsafe and could be removed for similar reasons, such as Lwt_unix.fork and Lwt_unix.system.

1 Like