-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/tsrb is not thread safe #9882
Copy link
Copy link
Labels
Type: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)The issue reports a bug / The PR fixes a bug (including spelling errors)
Description
Description
The "Thread-safe ringbuffer" is not actually thread safe.
Thread safety in this module depends upon reads and writes to unsigned int being atomic. C99 makes no guarantees with respect to atomicity (and they are probably NOT atomic in 8-bit platforms).
To fix this, access to these variables should be wrapped in a save interrupt mask/restore interrupt mask block. Alternatively, for architectures that support it, an asm statement can be used to ensure a single-cycle uninterruptible operation.
Steps to reproduce the issue
- Grab a copy of the C99 standard.
- Verify that the safety of reads and writes in the presence of interrupts/signals is unspecified.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)The issue reports a bug / The PR fixes a bug (including spelling errors)