Skip to content

FRLG DigitReader: lock the digit template cache - #1646

Merged
Gin890 merged 1 commit into
mainfrom
claude/frlg-digit-cache-race
Oct 21, 2026
Merged

Gin890 merged 1 commit into
mainfrom
claude/frlg-digit-cache-race

Conversation

@Gin890

@Gin890 Gin890 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a lock to the cache of digit templates in the FRLG digit reader. Without the lock, two threads can write to the cache at the same time and crash the program.

The unit tests run in parallel, so the FRLG stats reader tests read digits on many threads at once. If two threads fill the empty cache at the same time, the map becomes corrupt. This caused the rare segfault in these tests on macOS CI. For example, the crash occurred on main (run) and on PokemonAutomation/Arduino-Source#1637 (run).

No tests added or changed. The current FRLG stats reader tests use this code on many threads. With the fix, they pass on macOS CI (Mac, Mac Intel).

🤖 Generated with Claude Code

Several threads can read digits at the same time, and two of them could
insert into the cache map at once. That corrupts the map and crashes. This is
the rare segfault in the PokemonFRLG::StatsReader unit tests on macOS CI,
seen on main and on PR 1637.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gin890
Gin890 merged commit 13f8ea9 into main Oct 21, 2026
9 checks passed
@Gin890
Gin890 deleted the claude/frlg-digit-cache-race branch October 21, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants