Fix matched polygon region approximation crash #1386
Merged
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.
Description
What is implemented or fixed? Mention the linked issue(s), if any.
Fixes Backend segmentation fault crash when working with high resolution region, cube and image #1383 and duplicate issue Segmentation fault backend crash with two cubes and high resolution region #1384
How does this PR solve the issue? Give a brief summary.
To approximate a polygon region in a matched region, the polygon is reinvented with many points between the original polygon points to prevent distortion in the conversion. But when the original polygon has a very short segment, the matched segment may not add any points and consists of just the starting point. The segmentation fault resulted due to invalid indexing which assumed at least two points when checking for "kinks" introduced in a matched horizontal segment. In this fix, these one-point segments are no longer checked. Added a RegionMatchedTest which causes a seg fault in dev but passes in this branch.
Are there any companion PRs (frontend, protobuf)?
No
Is there anything else that testers should know (e.g. exactly how to reproduce the issue)?
Try to get stats or spectral profile for a matched polygon with a very short segment between points, < 1/1000th of the original polygon length (the new backend test uses a polygon with only 5 points). The analysis should complete successfully and not crash the backend.
Checklist
no changelog update neededprotobuf updated to the latest dev commit/ no protobuf update neededprotobuf version bumped/ protobuf version not bumped