From 9d30e619a458293ec82aedc3365fbe0fcf2f5076 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 30 Nov 2026 10:21:35 -0600 Subject: [PATCH 1/2] Don't run the real rcl_parse_arguments in the failure test Signed-off-by: Michael Carroll --- rclcpp/test/rclcpp/test_utilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/test/rclcpp/test_utilities.cpp b/rclcpp/test/rclcpp/test_utilities.cpp index b64b0a31c6..40911f64cf 100644 --- a/rclcpp/test/rclcpp/test_utilities.cpp +++ b/rclcpp/test/rclcpp/test_utilities.cpp @@ -244,7 +244,7 @@ TEST(TestUtilities, remove_ros_arguments_rcl_parse_arguments_failed) { }; int argc = sizeof(argv) / sizeof(const char *); - auto mock = mocking_utils::inject_on_return( + auto mock = mocking_utils::patch_and_return( "lib:rclcpp", rcl_parse_arguments, RCL_RET_ERROR); RCLCPP_EXPECT_THROW_EQ( rclcpp::remove_ros_arguments(argc, argv), From 85232ee8dabef19badd04cfa9b2922148cf28f0f Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 30 Nov 2026 10:40:16 -0600 Subject: [PATCH 2/2] Don't shift past the width of a pointer in the mock GID Signed-off-by: Michael Carroll --- rclcpp/test/rclcpp/test_intra_process_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rclcpp/test/rclcpp/test_intra_process_manager.cpp b/rclcpp/test/rclcpp/test_intra_process_manager.cpp index 838b8298b8..5de17aa917 100644 --- a/rclcpp/test/rclcpp/test_intra_process_manager.cpp +++ b/rclcpp/test/rclcpp/test_intra_process_manager.cpp @@ -167,7 +167,10 @@ class PublisherBase gid_.implementation_identifier = "mock_rmw"; auto ptr_value = reinterpret_cast(this); for (size_t i = 0; i < RMW_GID_STORAGE_SIZE; ++i) { - gid_.data[i] = static_cast((ptr_value >> (i * 8)) & 0xFF); + // The GID is wider than a pointer, so zero the bytes past the end of it. Shifting a + // std::uintptr_t by its width or more is undefined behavior. + gid_.data[i] = (i < sizeof(ptr_value)) ? + static_cast((ptr_value >> (i * 8)) & 0xFF) : 0; } }