-
Notifications
You must be signed in to change notification settings - Fork 204
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
Use appropriate atomic type for inter-thread sync #1034
Comments
Imported from trac issue 183. Created by jphickey on 2017-02-14T13:00:24, last modified: 2019-08-14T14:11:46 |
Trac comment by jphickey on 2017-02-14 13:43:06: Also need to make sure that we include the |
Trac comment by glimes on 2017-02-14 13:47:43: The case we hit in Biosentinel is in CFE, I'll go update the |
Issue described (using uint32 for CFE_ES_Global.SystemState) still exists as far as I can tell, but that's a cFE problem not applicable to any officially supported systems (only a system where a write to uint32 isn't atomic). Couldn't find a related cFE ticket other than #17, which doesn't directly address this issue. Moving to cFE. |
Interesting inconsistencies: cFE/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h Lines 237 to 247 in 6d80b60
yet: cFE/fsw/cfe-core/src/inc/cfe_es.h Line 578 in 6d80b60
Note unique either (CFE_ES_RunStatus_Enum_t defined but unused). Seems like then intension was to use these types in the APIs? |
The RV tool analysis reported several cases of reading/writing shared memory variables without a lock.
The intention behind the code was that the data type being read/written simultaneously here was atomic in nature, thus the parallel access would be safe, as it is not possible to catch an atomic value mid-update.
To be more portable the code should use the C99 type
sigatomic_t
to ensure that the data type is in fact atomic on the given platform. Currently it is usinguint32
which is not guaranteed to be atomic on all platforms.Calling this "minor" because the
uint32
type will be atomic on all the platforms that the code in question is actually used on. There is no bug currently here, this is just to prevent a future bug if this code is expanded to smaller CPUs (microcontrollers) whereuint32
is not atomic.The text was updated successfully, but these errors were encountered: