demo: fix stack corruption in ping_pong demo#96
Open
corytodd wants to merge 1 commit intomicro-ROS:kiltedfrom
Open
demo: fix stack corruption in ping_pong demo#96corytodd wants to merge 1 commit intomicro-ROS:kiltedfrom
corytodd wants to merge 1 commit intomicro-ROS:kiltedfrom
Conversation
While running the ping_pong demo I noticed a crash: ping_pong_1-1 | [ros2run]: Aborted ping_pong_1-1 | [INFO] [1775242528.757714440] []: Created a timer with period 2000 ms. ping_pong_1-1 | ping_pong_2-1 | realloc(): invalid old size ping_pong_1-1 | mremap_chunk(): invalid pointer ping_pong_2-1 | [ros2run]: Aborted ping_pong_1-1 | [ros2run]: Aborted This is caused by stack memory being passed to realloc() at https://github.com/ros2/rosidl/blob/8cdfe315157f8bffa9b73b6750c52f44325a7847/rosidl_runtime_c/src/string_functions.c#L110 Use ros string allocators to handle this safely. The outcoming_ping is sprintf'd so we must preallocate. Signed-off-by: Cory Todd <[email protected]>
c246021 to
272850d
Compare
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.
While running the ping_pong demo I noticed a crash:
ping_pong_1-1 | [ros2run]: Aborted
ping_pong_1-1 | [INFO] [1775242528.757714440] []: Created a timer with period 2000 ms. ping_pong_1-1 |
ping_pong_2-1 | realloc(): invalid old size
ping_pong_1-1 | mremap_chunk(): invalid pointer
ping_pong_2-1 | [ros2run]: Aborted
ping_pong_1-1 | [ros2run]: Aborted
This is caused by stack memory being passed to realloc() at https://github.com/ros2/rosidl/blob/8cdfe315157f8bffa9b73b6750c52f44325a7847/rosidl_runtime_c/src/string_functions.c#L110
Use ros string allocators to handle this safely. The outcoming_ping is sprintf'd so we must preallocate.
After patching my tree I see the expected output
Fixes #95
Signed-off-by: Cory Todd [email protected]