Skip to content

Shared encoder report buffers lack synchronisation between the refresh and clear paths #80

Description

@kelchm

LegacyLedEncoder fills a single pooled report buffer from two threads — the LED refresh task and Clear(), called from SimHub's manager thread — with no lock. This is a latent hazard rather than an observed corruption: Clear() waits up to two seconds on the refresh task first, so overlap requires that wait to time out. But nothing guarantees exclusion, and the failure mode is a torn frame.

DisplayEncoder locks this exact pattern deliberately, with a comment noting that the transport lock alone still allows torn frames. The col03 LedEncoder has the same unguarded pattern, so a fix should cover both encoders rather than only the legacy one.

Fix: hold the lock across both report construction and transport submission — locking only the fill still allows a second thread to overwrite the buffer before the first thread's write is issued.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions