Skip to content

fix: synchronize sleep-spam tracking state#230

Open
hedssaz wants to merge 1 commit into
PlayCover:masterfrom
hedssaz:fix/thread-safe-sleep-spam-tracking
Open

fix: synchronize sleep-spam tracking state#230
hedssaz wants to merge 1 commit into
PlayCover:masterfrom
hedssaz:fix/thread-safe-sleep-spam-tracking

Conversation

@hedssaz

@hedssaz hedssaz commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • synchronize access to the shared sleep-spam tracking dictionaries
  • keep the counter update and threshold check in the same critical section

Root cause

pt_usleep can run concurrently on multiple game threads while blockSleepSpamming is enabled. The shared NSMutableDictionary instances were read and mutated without synchronization. Concurrent access could corrupt their internal storage during insertion or rehashing and crash the game from pt_usleep.

Impact

This preserves the existing sleep-spam detection behavior while preventing dictionary access races during game startup and runtime.

Testing

  • built the PlayTools Release scheme for a generic iOS device with code signing disabled
  • verified the synchronization fix in Arknights: Endfield on macOS 26 with sleep-spam blocking enabled

@hedssaz

hedssaz commented Jul 22, 2026

Copy link
Copy Markdown
Author

Stress-tested the synchronized tracking path with 256 concurrent pthreads over 20 rounds (517,120 calls), plus a Thread Sanitizer run with 64 threads over 10 rounds (64,640 calls): no crashes or data races were reported, and every thread remained below the threshold for calls 1–100 and crossed it exactly on call 101.

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.

1 participant