ARMmbed / ARMmbed/DAPLink

Circular buffer write race condition

Open
#841 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
2.8k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
1

Description

It looks like there is a problem in `circ_buf_write()` in how it doesn't wrap the whole call in interrupt masking and instead relies on `circ_buf_push()` protecting each byte insert, with only one check for MIN() and no for loop exit on overflow. In practise this may be mitigated by having everything serialised on the main thread.

`circ_buf_write()` is also very inefficient by pushing a single byte at a time.

Contributor guide

Open the contributing guide

Research direction

Start by locating circ_buf_write() and circ_buf_push() in the firmware source. Trace how interrupt masking, MIN(), and overflow handling interact during writes, then examine whether the byte-at-a-time behavior contributes to the reported inefficiency. Done means the race and overflow behavior are addressed without relying on main-thread serialization, with relevant firmware tests or validation run if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.