-
Notifications
You must be signed in to change notification settings - Fork 845
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
Avoid data race warning in SmilesParse.cpp #2946
Conversation
Avoid data race in SmilesParse.cpp for SMILES and SMARTS
Yeah, the yysmiles_debug is certainly not thread safe. I practice though I doubt one would ever get a data race. I'm tentatively ok with this solution, the only other one I can think of is to pass the SmilesParserParams object to all the functions, but this seems like a big rewrite. |
Agreed: I see that this is not thread safe - in the event that everyone was ever actually running the parser in debug and non-debug modes simultaneously in separate threads - but I don't see how the proposed solution helps with any possible race condition. If this is something we actually choose to worry about, we could add a mutex around |
Agreed that this PR doesn't fix the race, but it does make TSan happy in the case of not changing options :) |
LGTM |
Let’s at least add a doc note that params.debugParse Shouldn’t be used when multi threading. I can push a commit if you like. |
I think It’s fine to use it multithreaded, you just shouldn’t us different values on different threads |
I can adjust the comments I added here to make this clearer...just a sec. |
There you go; PTAL. |
Great. Thanks |
This PR avoids a data race identified by TSan in SmilesParse.cpp. I'm not sure it's the best solution---the race could still exist if multiple callers of
{Smarts,Smiles}ToMol
use different settings fordebugParse
---but it avoids the issue in the usual case of repeated calls to{Smarts,Smiles}ToMol
with the same params.