introduce rclc_get_zero_initialized_lifecycle_node().#443
introduce rclc_get_zero_initialized_lifecycle_node().#443JanStaschulat merged 1 commit intorollingfrom
Conversation
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
There was a problem hiding this comment.
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_lifecycleREADME 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 anenable_communication_interfaceflag). 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.
|
Pulls: #443 |
There was a problem hiding this comment.
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.
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? |
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, |
|
@JanStaschulat @Carlosespicur @EugenioCollado can you review and merge this since you are maintainers? |
JanStaschulat
left a comment
There was a problem hiding this comment.
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.
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