Skip to content

[Debug] Confine GDB breakpoint stops to the world thread#3

Open
r-log wants to merge 1 commit into
Krilliac:masterfrom
r-log:fix/gdb-breakpoint-world-thread
Open

[Debug] Confine GDB breakpoint stops to the world thread#3
r-log wants to merge 1 commit into
Krilliac:masterfrom
r-log:fix/gdb-breakpoint-world-thread

Conversation

@r-log

@r-log r-log commented Jul 4, 2026

Copy link
Copy Markdown

Follow-up to the review on mangoszero#406 — merge this into your master and it lands in the PR.

Confines the GDB breakpoint cooperative stop to the world thread, closing the two races from the review:

  • Stop loopWorldSocket (ACE net threads) and DatabaseMysql (DB worker) could drive EnterStop off the world thread, racing the unguarded RSP state so the world never actually pauses. Latch the world thread id on the first OnWorldUpdate tick (correct spot — Init() runs on main, before the world thread starts) and reject EnterBreak from any other thread; the hit is already counted.
  • Registry — those same sites reach GdbBp::Matches/Hit before the guard, racing g_entries (std::vector) against Arm/Disarm and bumping a non-atomic g_hits. Serialise g_entries with a mutex, make g_hits atomic, and fix the now-stale "needs no locking" comment.

4 files, +47/-6. Compiles clean on MSVC 2022 / Release (game.lib + mangosd.exe, 0 warnings / 0 errors). Not yet runtime-tested with a live debugger session — happy to smoke that and test on Linux once it's in.

Breakpoint call sites in WorldSocket (ACE network threads) and
DatabaseMysql (DB worker thread) could drive EnterStop off the world
thread, racing the unguarded RSP state and never actually pausing the
world. Latch the world thread id on the first OnWorldUpdate tick and
reject EnterBreak from any other thread (the hit is already counted).

The same foreign sites also reached GdbBp::Matches / Hit before that
guard, racing g_entries (std::vector) against Arm/Disarm on the world
thread and incrementing a non-atomic g_hits. Serialise g_entries with a
mutex and make g_hits atomic; correct the stale "needs no locking" note.
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