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

thread-safety #183

Open
vzaliva opened this issue Jun 23, 2024 · 2 comments
Open

thread-safety #183

vzaliva opened this issue Jun 23, 2024 · 2 comments

Comments

@vzaliva
Copy link

vzaliva commented Jun 23, 2024

Currently, yojson is not safe to use within domains, causing random Stdlib.Queue.Empty exceptions. The reason is that it is using Format, which uses a shared state by default.

The format issue was addressed in part by ocaml/ocaml#10453, but it requires code changes.

@vzaliva
Copy link
Author

vzaliva commented Jun 23, 2024

I suspect the issue is around formatter_of_out_channel use which should be replaced with synchronized_formatter_of_out_channel

@Leonidas-from-XIV
Copy link
Member

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.

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