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

ThreadSanitizer detects races due to non-atomic loads #1

Open
nemequ opened this issue Oct 5, 2015 · 1 comment
Open

ThreadSanitizer detects races due to non-atomic loads #1

nemequ opened this issue Oct 5, 2015 · 1 comment

Comments

@nemequ
Copy link

nemequ commented Oct 5, 2015

ThreadSanitizer freaks out when running lzham, which is unfortunate because it makes it difficult to run software which uses lzham through it. I'd really like to run my unit tests with tsan in CI.

The issue is that lzham uses atomic operations to store some values, but assumes that loads are atomic. IMHO lzham should be using C11-style atomics when available, including atomic_load (or maybe atomic_load_explicit).

stdatomic.h is available with gcc >= 4.9, or there are similar builtins for 4.8. Not sure about clang. I think just checking for stdatomic.h in cmake (and using it if it is available, of course) should be enough, though; no need to deal with all the corner cases.

@richgel999
Copy link
Owner

Hi nemequ,
Thanks for pointing this out. I can switch the lib to use these macros. I'm going to be porting LZHAM to a lot more platforms very soon, so this sounds like the right thing to do.

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