Repository navigation
FRLG DigitReader: lock the digit template cache - #1646
Merged
Merged
Conversation
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>
Mysticial
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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