Open masaori335 opened 1 year ago
We should use std::atomic
generally, because it's standard. The current atomic support dates from before any of this was standard.
Just to record this: in discussing this in our ASF PR/issue meeting, we suggest that this be addressed piecemeal as patches are done involving the old ink_atomic
code.
This issue has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.
Last few days, I've been running ThreadSanitizer. Some reports has the same pattern of data race, atomic write v.s. normal read.
The ink_atomic operations are used for writing variables but not for reading variables. It looks like this happens to almost all of the variables that are touched by ink_atomic operations. We need to change these variables with std::atomic to make reading safe.
Also, replacing with std::atomic provides an advantage. We can control memory order. This is not available with ink_atomic because it's using legacy gcc buit-in __sync functions, I think.
e.g.
Actually, Phil tried to replace ink_atomic with std::atomic by PR #2633 5 years ago.