Repository navigation
fix(subscription): write rmw_take_sequence output at the taken cursor [P2] - #7
Conversation
db7a240 to
a77f254
Compare
|
Reviewed the fix end-to-end against One blocking item before merge:
Non-blocking notes:
Code is ready; please add the regression test before merge. |
…s and lost messages
a801a98 to
08678ae
Compare
Inject [good, corrupt, good] datagrams into a subscription socket (public rmw_serialize for the payload, raw sendto for delivery) and assert take_sequence yields two contiguous messages (size == *taken == 2) with no hole and nothing lost. Fails before the cursor fix (data[1] was a hole and the second good message, written at data[2], was dropped).
08678ae to
0b86dcb
Compare
Severity: P2 — found by a full multi-agent code audit (method + findings in
AUDIT_FINAL.md).Problem
rmw_take_sequence()wrote each message todata[i]indexed by the loop counter, but counted successes separately in*takenand did a barecontinueon a deserialize failure. If messagejfailed but a laterk > jsucceeded, the consumer readsdata[0 .. *taken-1], which (a) includes the never-writtendata[j](uninitialized caller storage surfaces as a "valid" message) and (b) excludes the validdata[k](already popped from the queue → permanently lost). It was also the only take path that didn't log the dropped datagram.Fix
Use a single write cursor: write each success to
data[*taken]then increment*taken; on failure, log (throttled) andcontinuewithout advancing the cursor. Output is contiguous[0 .. *taken-1]andsize == *taken.File:
rmw_unix_socket_cpp/src/rmw_subscription.cppBuild: clean.