-
Notifications
You must be signed in to change notification settings - Fork 756
fix(behavior_path_planner): prevent segfault in updateBoundary with index validation #10848
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
base: main
Are you sure you want to change the base?
fix(behavior_path_planner): prevent segfault in updateBoundary with index validation #10848
Conversation
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10848 +/- ##
==========================================
+ Coverage 15.72% 19.52% +3.79%
==========================================
Files 1342 1352 +10
Lines 100478 101205 +727
Branches 32571 33009 +438
==========================================
+ Hits 15804 19761 +3957
- Misses 72494 72835 +341
+ Partials 12180 8609 -3571
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This PR addresses a critical segmentation fault that occurs in the
behavior_path_planner
, specifically within the static obstacle avoidance module. The crash happens during the process of modifying the drivable area boundary when multiple static obstacles are present, causing thecomponent_container_mt
process to die.Stack Trace of the Crash
The crash is identified by the following stack trace, which points to an issue within the
updateBoundary
function.Root Cause Analysis
The root cause of the segmentation fault lies in the
updateBoundary
function located indrivable_area_expansion/static_drivable_area.cpp
.This function modifies the drivable area's boundary (
updated_bound
) by iterating through a list of obstacle polygons and removing sections of the boundary vector usingstd::vector::erase()
.The core of the problem is as follows:
bound_seg_idx
) that were calculated based on the original boundary's state before any modifications.updated_bound.erase()
is called, which shrinks the size of theupdated_bound
vector.updated_bound
vector.erase()
with iterators derived from these out-of-bounds indices results in undefined behavior, leading to the observed segmentation fault.Solution
To resolve this issue, this PR introduces a guard clause to validate the indices right before calling
updated_bound.erase()
.This check ensures that both the start and end indices for the erase operation are within the valid range of the
updated_bound
vector's current size. If the indices are invalid, the operation for that particular polygon is skipped, and an error is logged. This prevents the crash while maintaining the integrity of the drivable area generation process.Related links
Parent Issue:
How was this PR tested?
Notes for reviewers
None.
Interface changes
None.
Effects on system behavior
None.