Skip to content

introduce rclc_get_zero_initialized_lifecycle_node().#443

Merged
JanStaschulat merged 1 commit intorollingfrom
fujitatomoya/issues/441
Feb 18, 2026
Merged

introduce rclc_get_zero_initialized_lifecycle_node().#443
JanStaschulat merged 1 commit intorollingfrom
fujitatomoya/issues/441

Conversation

@fujitatomoya
Copy link
Contributor

Description

should closes #441

Is this user-facing behavior change?

No, but it is suggested to use new function to avoid the possible issues.

Did you use Generative AI?

Yes, Copilot Claude Sonnet 4.5

Additional Information

No

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a public helper API to obtain a zero-initialized rclc_lifecycle_node_t, and updates examples/tests/docs to use it to avoid crashes when stack memory is not implicitly zeroed (as described in #441).

Changes:

  • Add rclc_get_zero_initialized_lifecycle_node() to provide a safe zero-initialized lifecycle node struct.
  • Update lifecycle tests and the example lifecycle node to use the new initializer.
  • Update the rclc_lifecycle README to show the new initialization pattern.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rclc_lifecycle/test/test_lifecycle.cpp Switches stack lifecycle node variables to use the new zero-initializer.
rclc_lifecycle/src/rclc_lifecycle/rclc_lifecycle.c Adds the rclc_get_zero_initialized_lifecycle_node() implementation.
rclc_lifecycle/include/rclc_lifecycle/rclc_lifecycle.h Exposes the new API and documents it.
rclc_lifecycle/README.md Updates the lifecycle node creation snippet to use the new initializer.
rclc_examples/src/example_lifecycle_node.c Updates the example to use the new initializer.
Comments suppressed due to low confidence (1)

rclc_lifecycle/README.md:39

  • The README example calls rclc_make_node_a_lifecycle_node() with fewer parameters than the current API requires (the function now takes a clock pointer and an enable_communication_interface flag). Since this PR touches this example block, it should be updated to match the actual function signature so users can copy/paste it successfully.
rclc_lifecycle_node_t lifecycle_node = rclc_get_zero_initialized_lifecycle_node();
rcl_ret_t rc = rclc_make_node_a_lifecycle_node(
  &lifecycle_node,
  &my_node,
  &state_machine_,
  &allocator);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fujitatomoya
Copy link
Contributor Author

Pulls: #443
Gist: https://gist.githubusercontent.com/fujitatomoya/2548525f32056f759c5762c9c9c8e0a1/raw/bec82eb74dea43adc845b7e815b74507bf4b1fc5/ros2.repos
BUILD args: --packages-above-and-dependencies rclc_examples rclc_lifecycle
TEST args: --packages-above rclc_examples rclc_lifecycle
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18205

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Copy link
Member

@asymingt asymingt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix. I cherry-picked this commit onto a local 6.2.0 tree and it worked well. However, if I try and check out the rolling branch then I get this:

INFO: Analyzed target @@rclc_lifecycle+//:rclc_lifecycle (4 packages loaded, 35 targets configured, 90 aspect applications).
ERROR: /usr/local/google/home/simmers/.cache/bazel/_bazel_simmers/94e00a9629417b25b0ad167b80dd4e2e/external/rclc_lifecycle+/BUILD.bazel:33:11: Compiling src/rclc_lifecycle/rclc_lifecycle.c failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from cc_library rule target @@rclc_lifecycle+//:rclc_lifecycle) external/toolchains_llvm++llvm+llvm_toolchain/bin/cc_wrapper.sh -U_FORTIFY_SOURCE '--target=x86_64-unknown-linux-gnu' -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -fcolor-diagnostics ... (remaining 424 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/rclc_lifecycle+/src/rclc_lifecycle/rclc_lifecycle.c:92:5: error: too many arguments to function call, expected 9, have 10
   82 |   rcl_ret_t rcl_ret = rcl_lifecycle_state_machine_init(
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   83 |     state_machine,
   84 |     node,
   85 |     clock,
   86 |     ROSIDL_GET_MSG_TYPE_SUPPORT(lifecycle_msgs, msg, TransitionEvent),
   87 |     ROSIDL_GET_SRV_TYPE_SUPPORT(lifecycle_msgs, srv, ChangeState),
   88 |     ROSIDL_GET_SRV_TYPE_SUPPORT(lifecycle_msgs, srv, GetState),
   89 |     ROSIDL_GET_SRV_TYPE_SUPPORT(lifecycle_msgs, srv, GetAvailableStates),
   90 |     ROSIDL_GET_SRV_TYPE_SUPPORT(lifecycle_msgs, srv, GetAvailableTransitions),
   91 |     ROSIDL_GET_SRV_TYPE_SUPPORT(lifecycle_msgs, srv, GetAvailableTransitions),
   92 |     &state_machine_options);
      |     ^~~~~~~~~~~~~~~~~~~~~~
external/rcl_lifecycle+/include/rcl_lifecycle/rcl_lifecycle.h:244:1: note: 'rcl_lifecycle_state_machine_init' declared here
  244 | rcl_lifecycle_state_machine_init(
      | ^
  245 |   rcl_lifecycle_state_machine_t * state_machine,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  246 |   rcl_node_t * node_handle,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~
  247 |   const rosidl_message_type_support_t * ts_pub_notify,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248 |   const rosidl_service_type_support_t * ts_srv_change_state,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  249 |   const rosidl_service_type_support_t * ts_srv_get_state,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  250 |   const rosidl_service_type_support_t * ts_srv_get_available_states,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  251 |   const rosidl_service_type_support_t * ts_srv_get_available_transitions,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  252 |   const rosidl_service_type_support_t * ts_srv_get_transition_graph,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  253 |   const rcl_lifecycle_state_machine_options_t * state_machine_options);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Target @@rclc_lifecycle+//:rclc_lifecycle failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.534s, Critical Path: 0.82s
INFO: 3 processes: 572 action cache hit, 3 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested

Looks like CI failure might be as a result of you needing to rebase on rolling. But we should definitely roo-cause this issue before merging.

@fujitatomoya
Copy link
Contributor Author

@asymingt your local rolling branch includes #435? that was required to build the rclc.

@fujitatomoya
Copy link
Contributor Author

  • Windows Build Status

@asymingt
Copy link
Member

@asymingt your local rolling branch includes #435? that was required to build the rclc.

No it didn't because I'm working from a snapshot of rolling from last year which presumably doesn't include the change to rcl. I was just concerned about the Jazzy and Kilted run failures on the pre-merge checks. Do you know why they are failing?

@fujitatomoya
Copy link
Contributor Author

fujitatomoya commented Feb 16, 2026

Jazzy and Kilted run failures on the pre-merge checks. Do you know why they are failing?

yeah 😓 i am also concerned about that, but i am not sure yet. that is another problem here...

i am just trying to fix the build and test failure with rolling branch, once rolling branch is fixed i will try to allocate some time for jazzy and kilted.

the thing is, rclc is not included in https://github.com/ros2/ros2/blob/rolling/ros2.repos. that means it is easy to break as mainline grows... having rclc mainline project would be hard to do it right away, it requires some processes to promote rclc to core repository. (https://docs.ros.org/en/rolling/The-ROS2-Project/Governance.html#repositories-managed-by-the-ros-pmc does not include rclc either, that means this is community support repository.) instead, what we can do here is that i think we probably add github workflow nightly and all downstream branches to make sure that can built and all tests pass.

@fujitatomoya
Copy link
Contributor Author

@JanStaschulat @Carlosespicur @EugenioCollado can you review and merge this since you are maintainers?

Copy link
Contributor

@JanStaschulat JanStaschulat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for providing a zero-initialized lifecycle_node.
The pull request on Rolling is green, that's than fine for me to merge.
Would be great, if you could look into the failing build for the other distro's.

@JanStaschulat JanStaschulat merged commit f496dc8 into rolling Feb 18, 2026
10 of 12 checks passed
@JanStaschulat JanStaschulat deleted the fujitatomoya/issues/441 branch February 18, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segfault in lifecycle_test due to memory not being zero-initialized

4 participants