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

AC_Avoidance: correct use of uninitialised value when retrying fence … #26035

Closed
wants to merge 1 commit into from

Conversation

peterbarker
Copy link
Contributor

…creation

this shortcut (fences haven't changed, so don't bother retrying) wasn't setting the passing-in error ID, leading to use of unininitialised stack data.

So remember the error ID and return it in this case

…creation

this shortcut (fences haven't changed, so don't bother retrying) wasn't setting the passing-in error ID, leading to use of unininitialised stack data.

So remember the error ID and return it in this case
@@ -76,6 +76,10 @@ class AP_OADijkstra {
// create polygons inside the existing inclusion polygons
// returns true on success. returns false on failure and err_id is updated
bool create_inclusion_polygon_with_margin(float margin_cm, AP_OADijkstra_Error &err_id);
// create polygons inside the existing inclusion polygons
// returns true on success. returns false on failure and err_id is updated. This function is wrapped so we can remember the error ID.
bool _create_inclusion_polygon_with_margin(float margin_cm, AP_OADijkstra_Error &err_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identiacally-named functions like this a ripe for confusion

@peterbarker
Copy link
Contributor Author

peterbarker commented Jan 22, 2024 via email

bool AP_OADijkstra::create_inclusion_polygon_with_margin(float margin_cm, AP_OADijkstra_Error &err_id)
{
const bool ret = _create_inclusion_polygon_with_margin(margin_cm, err_id);
last_create_inclusion_polygon_with_margin_error_id = err_id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you pass this class variable in from the function that calls this? That is to say remove this:

AP_OADijkstra_Error error_id;

And use the class variable in its place. I don't think you would need any of the other changes?

@peterbarker peterbarker deleted the pr/oa-dijkstra-fix branch January 23, 2024 00:36
@rmackay9
Copy link
Contributor

rmackay9 commented Jan 23, 2024

@IamPete1,

My solution would be to add a _last_error_id variable and pass that back in this one case. The slightly annoying part of my suggestion is that it means we'd need to set this _last_error_id everywhere we set err_id... so if you think you have a better idea then looking forward to it.

@peterbarker
Copy link
Contributor Author

peterbarker commented Jan 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants