-
Notifications
You must be signed in to change notification settings - Fork 60
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 in concurrent uses of Re.exec
on one pre-compiled Re.re
#287
Comments
Cc @vouillon in case you didn’t get notified and you find this of interest. Looking at this from 20,000 feet, it looks like Re has been designed to be safe for concurrent use with systhreads, but is not currently domain-safe. |
|
I see. So making it thread-safe would at best take some hours of work. A possible temporary workaround, obviously unsatisfactory on many levels, would be to sequence all calls into the library by protecting them with a global mutex. |
Is the whole library thread-unsafe or is it only specific functions like |
Constructing |
This is news to me, I thought only Re.Str was not thread safe, and the rest of Re was. If the entire 're' is not thread safe currently, it would be good to document this so that users of the library can add appropriate mutexes. (Although we've been using Although it looks like |
Maybe we could add a way to fully compile a regular expression immediately, rather than lazily. Then, it would be thread-safe to match against this regular expression. |
Using TSan with OCaml 5.2 on a code that use re.1.11.0, I'm getting the following error:
The code in opam that uses Re is the following: https://github.com/ocaml/opam/blob/391333d35bcdc8b55df709b876b8bafcf75f3452/src/core/opamUrl.ml#L46-L74 and can be summarized into:
which then trigger the data race on this piece of mutable state:
ocaml-re/lib/core.ml
Line 162 in 2dd3851
ocaml-re/lib/core.ml
Line 166 in 2dd3851
The text was updated successfully, but these errors were encountered: