Atomic load-check-store race condition
An AI wrote this Rust rate-limiter counter and claims it's lock-free and correct because it uses atomics. Review the atomic logic.
Under heavy concurrency it lets through more than `max`. Explain the race and fix it.
Implement
admit_waves(wave_sizes: list[int], max_permits: int, use_compare_and_swap: bool) → list[int]Examples
in
[[4,4,4],5,false]out[4,4,4]in
[[4,4,4],5,true]out[4,1,0]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 20 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.
Run or narrate your approach, then ask the coach.