You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS Version: Ubuntu 24.04
rviz version: ros2 jazzy
Compiler name and version number: Ubuntu clang version 18.1.3
Source or binary build?
source build
build options: --mixin asan-gcc
Description
In the implementation of rviz_rendering::BillboardLine, the addPoint() method does not properly handle cases where the number of added points exceeds the limit set by setMaxPointsPerLine(). The current implementation only uses assert() to check for boundary violations, which is not effective in Release builds, as assertions are typically disabled.
As a result, in production builds, the function allows adding more points than allowed, potentially leading to undefined behavior. For example, this has resulted in an AddressSanitizer out-of-memory (OOM) error during testing when a large number of points were unintentionally added.
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from BillboardLineTestFixture
[ RUN ] BillboardLineTestFixture.addPoint_checks_for_max_points_per_line_boundary
[rviz_rendering:debug] Available Renderers(1): OpenGL Rendering Subsystem, at /home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/src/rviz_rendering/render_system.cpp:289
[rviz_rendering:info] Stereo is NOT SUPPORTED, at /home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/src/rviz_rendering/render_system.cpp:531
[rviz_rendering:info] OpenGl version: 4.3 (GLSL 4.3), at /home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/src/rviz_rendering/render_system.cpp:272
/home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/test/rviz_rendering/objects/billboard_line_test.cpp:73: Failure
Expected: grid_cell.addPoint(Ogre::Vector3(2, 2, 0)) throws an exception of type std::out_of_range.
Actual: it throws nothing.
[ FAILED ] BillboardLineTestFixture.addPoint_checks_for_max_points_per_line_boundary (1887 ms)
[----------] 1 test from BillboardLineTestFixture (1887 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1887 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] BillboardLineTestFixture.addPoint_checks_for_max_points_per_line_boundary
1 FAILED TEST
Expected behavior
When the number of added points exceeds the max_points_per_line limit, the addPoint() method should throw a std::out_of_range (or similar) exception to clearly indicate a boundary violation. This ensures proper usage of the API and helps maintain system stability at runtime.
Actual behavior
The current implementation relies solely on assert() for boundary checking. In Release mode, these assertions are removed by the compiler, so the check is bypassed, allowing unchecked addition of elements. This can lead to memory overuse, crashes, or undefined behavior.
This behavior also causes the unit test addPoint_checks_for_max_points_per_line_boundary to fail, as the test expects a std::out_of_range exception, but none is thrown.
Operating System:
Linux shangzh-VMware-Virtual-Platform 6.11.0-19-generic #19~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 17 11:51:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
ROS version or commit hash:
ros2 jazzy
RMW implementation (if applicable):
No response
RMW Configuration (if applicable):
No response
Client library (if applicable):
rviz
'ros2 doctor --report' output
ros2 doc --report
Steps to reproduce issue
Environment
OS Version: Ubuntu 24.04
rviz version: ros2 jazzy
Compiler name and version number: Ubuntu clang version 18.1.3
Source or binary build?
source build
build options: --mixin asan-gcc
Description
In the implementation of rviz_rendering::BillboardLine, the addPoint() method does not properly handle cases where the number of added points exceeds the limit set by setMaxPointsPerLine(). The current implementation only uses assert() to check for boundary violations, which is not effective in Release builds, as assertions are typically disabled.
As a result, in production builds, the function allows adding more points than allowed, potentially leading to undefined behavior. For example, this has resulted in an AddressSanitizer out-of-memory (OOM) error during testing when a large number of points were unintentionally added.
Test Case
Output
Expected behavior
When the number of added points exceeds the max_points_per_line limit, the addPoint() method should throw a std::out_of_range (or similar) exception to clearly indicate a boundary violation. This ensures proper usage of the API and helps maintain system stability at runtime.
Actual behavior
The current implementation relies solely on assert() for boundary checking. In Release mode, these assertions are removed by the compiler, so the check is bypassed, allowing unchecked addition of elements. This can lead to memory overuse, crashes, or undefined behavior.
This behavior also causes the unit test addPoint_checks_for_max_points_per_line_boundary to fail, as the test expects a std::out_of_range exception, but none is thrown.
Additional information
Suggested Fix
The text was updated successfully, but these errors were encountered: