-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
ARM32 (and possibly some others) might take locks in Interlocked FCalls #97452
Comments
Do |
They also emit helper calls, they don't issue a warning though. I wouldn't rely on it being fine however as their docs say:
which makes it seem like there should be a warning in such case. |
It is reasonable to assume that the helper calls that __sync intrinsics compile into do not use locks. The helper calls can be used e.g. to select the most efficient implementation for given hardware. Per LLVM documentation, |
This doesn't seem to be guaranteed in GCC:
|
It may not be guaranteed, but it is reasonable to assume that it is the case. Also, our officially supported build is clang/llvm. There is very little testing of gcc based builds. It is likely that gcc based builds have number of issues, so one more potential gcc-specific issue is not really a problem. |
It seems however that with GCC all atomics are lock free with the exception of 64bit integers on RISC-V 32bit. |
Makes PAL use intrinsics that are guaranteed to not lock with Clang and with other compilers (probably only GCC) checks the C11 `lock free atomics` defines as there seems to be no better way to verify safety there. Fixes dotnet#97452.
While working on #92974, I've realised that on some platforms without builtin atomics for all types, compilers might use a locking based implementation for them.
Checking the C11 defines, it seems like at least ARM32 is affected with Clang, but other platforms might be affected with GCC too.
Looking at the exact codegen, ARM32 and ARM 8.0 without atomics seem to use helper calls for Interlocked, only arm32 gives warnings about locking though.
The code should be fixed to avoid potential issues with this, I see 4 possible solutions:
Relying on the compiler to be lock free on any platform that uses helper calls for atomics seems unreliable as AFAIR those are free to implement them using locks.
cc @jkotas
The text was updated successfully, but these errors were encountered: