Open vzaliva opened 1 week ago
I suspect the issue is around formatter_of_out_channel
use which should be replaced with synchronized_formatter_of_out_channel
Thanks for the report, however it looks like Format.synchronized_formatter_of_out_channel
is marked as "unstable" (and possibly only available in 5.x, but the latter can be worked around with conditional compilation). That's a rather regrettable state of affairs.
But Format.formatter_of_out_channel
is only used in to_channel
, the user can use pp
with their own formatter (so possibly the synchornized one). Does that solve your the thread safety issue?
It would be nice to have a repro-case but I understand that building reliable thread-safety repro cases is pretty difficult.
Currently, yojson is not safe to use within domains, causing random
Stdlib.Queue.Empty
exceptions. The reason is that it is usingFormat
, which uses a shared state by default.The format issue was addressed in part by https://github.com/ocaml/ocaml/issues/10453, but it requires code changes.