Code RoomRace condition in concurrent cache
HardPrep Room Coding #4193

Race condition in concurrent cache

Vibe & agenticConcurrencySenior–Staff~18 min

An AI agent wrote this C++ for a game server's hit-registration cache, claiming it "safely memoizes per-frame so concurrent worker threads share results":

Workers call `getHit` from multiple threads. The agent's single-threaded test passes. What's wrong, and how do you verify it before it ships into a 128-tick server?

Implement
check_lock_discipline(operations: list[str]) → list[str]
Examples
in[["t1|find|7","t2|find|7","t1|insert|7","t2|insert|7"]]out["unsynchronized_find:t1:7","unsynchronized_find:t2:7","unsynchronized_insert:t1:7","unsynchronized_insert:t2:7"]
in[["t1|lock","t1|find|7","t1|insert|7","t1|unlock","t2|lock","t2|find|7","t2|unlock"]]out[]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 18 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.