Repository navigation
fix(serialization): contain fastcdr/std exceptions in serialize() [P1] - #4
Merged
Merged
Conversation
…extern "C" boundary
This was referenced Jun 3, 2026
benaliabderrahmane
force-pushed
the
fix/p1-1-serialize-exception-boundary
branch
from
June 3, 2026 14:16
090b0cf to
76e87a2
Compare
Owner
Author
|
Reviewed the diff, surrounding context, and CI. This is a correct, focused, portable P1 fix — recommend merge after a one-line PR-body correction; the negative test is a nice-to-have, not a blocker. What I checked:
Non-blocking:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Severity: P1 — found by a full multi-agent code audit of
rmw_unix_socket_cpp(method + findings inAUDIT_FINAL.md).Problem
serialize()had no exception guard, while its siblingdeserialize()wraps its fastcdr calls intry/catch. Inserialize():callbacks->get_serialized_size()can throwstd::overflow_error(bounded sequence / string overflow);ser.serialize_encapsulation()/callbacks->cdr_serialize()can throweprosima::fastcdr::exception::Exception(e.g.BadParamExceptionon astd::stringfield carrying an embedded\0).Every caller is
extern "C"(rmw_publish,rmw_serialize,rmw_send_request,rmw_send_response), so a thrown exception unwinds across the C ABI into rcl →std::terminate()(process abort).Fix
Wrap the body of
serialize()and returnfalseon failure, mirroringdeserialize():catch (const eprosima::fastcdr::exception::Exception &)— fastcdr'sExceptiondoes not derive fromstd::exception, so it needs its own clause;catch (const std::exception &)— coversget_serialized_size()'sstd::overflow_errorandbuffer.resize()'sstd::bad_alloc.All callers already do
if (!serialize(...)) return RMW_RET_ERROR;.File:
rmw_unix_socket_cpp/src/serialization.cppBuild: clean
colcon build(library), 0 warnings.