Code RoomAsync send buffer lifetime
HardPrep Room Coding #4289

Async send buffer lifetime

Vibe & agenticConcurrencySenior–Staff~22 min

An AI wrote this C++ async-send code for a network engine: it queues a send and returns immediately. It works in single-threaded tests but crashes intermittently under load with corrupted bytes on the wire. Identify the memory/lifetime bug, the timing that triggers it, and the fix.

Implement
count_lifetime_violations(events: list[str]) → int
Examples
in[["alloc:1","submit:1","free:1","complete:1"]]out1
in[["alloc:1","submit:1","complete:1","free:1"]]out0
in[["alloc:1","submit:1","complete:1","free:1","alloc:2","submit:2","free:2"]]out1
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 22 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.