Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address sanitizer complains new-delete-type-mismatch over allocator_common #2045

Open
tsingakbar opened this issue Nov 8, 2022 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@tsingakbar
Copy link

tsingakbar commented Nov 8, 2022

Bug report

Required Info:

Steps to reproduce issue

build humble according to official guide enabling address sanitizer, like this:

colcon build --packages-up-to examples_rclcpp_minimal_publisher --cmake-args -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DCMAKE_C_FLAGS="-fno-omit-frame-pointer -fsanitize=address" -DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer -fsanitize=address"

Then launch the shipped example after source installed setup.bash:
RMW_IMPLEMENTATION=rmw_fastrtps_cpp ASAN_OPTIONS=detect_leaks=0 install/examples_rclcpp_minimal_publisher/lib/examples_rclcpp_minimal_publisher/publisher_lambda

Expected behavior

no address sanitizer problems.

Actual behavior

Then address sanitizer reports new-delete-type-mismatch, which is always related to https://github.com/ros2/rclcpp/blob/humble/rclcpp/include/rclcpp/allocator/allocator_common.hpp#L67 .

template<typename Alloc> void * retyped_allocate(size_t size, void * untyped_allocator);
template<typename T, typename Alloc> void retyped_deallocate(void * untyped_pointer, void * untyped_allocator);

Mostly retyped_allocate is called with a size greater than 1, but later calling retyped_deallocate will internally always use 1 as size to dealloc.

Additional information

@tsingakbar tsingakbar changed the title adress sanitizer complains new-delete-type-mismatch on allocator_common address sanitizer complains new-delete-type-mismatch on allocator_common Nov 8, 2022
@tsingakbar tsingakbar changed the title address sanitizer complains new-delete-type-mismatch on allocator_common address sanitizer complains new-delete-type-mismatch over allocator_common Nov 8, 2022
@fujitatomoya
Copy link
Collaborator

related to #1324, duplicate of #1925

@tylerjw
Copy link
Contributor

tylerjw commented Nov 12, 2022

Here is my attempt at rebasing the stale PR created to fix this bug. It would be wonderful to be able to use ASAN with ROS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants