Code Room
Vibe codingHardvc-g350
Subject Ai code reviewLevel Senior–Staff~22 minCommon in Concurrency interviewsIndustries Telecom, Software development

Question

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.

cpp
void send_async(int fd, const std::string &payload) {    std::vector<char> buf(payload.begin(), payload.end());    io_uring_prep_send(get_sqe(ring), fd, buf.data(), buf.size(), 0);    submit(ring);                 // kernel sends asynchronously    // function returns; completion handled elsewhere}
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.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.