NCAR / lrose-core

Core C/C++ code for LROSE.
https://www.eol.ucar.edu/content/lidar-radar-open-software-environment
Other
92 stars 51 forks source link

Fix hawkeye rhi segfault #129

Closed isabels closed 1 year ago

isabels commented 1 year ago

The last ray of some leosphere RHIs goes (barely) past 180 degrees. In the example file I'm looking at, the last elevation value is 179.948, and ray_angle_res is set to 1 (degree). In Hawkeye/RhiWidget::_storeRayLoc, the ray that causes the segfault has _startElev of 179.448 and _endElev of 180.448, leading to startIndex of 3594 and endIndex of 3605. Calling RhiWidget::_clearRayOverlap with this endIndex value causes the segfault, when looping through indices between startIndex and endIndex (once the index is >= 3600) and trying to access the _rayLoc vector with the given index. As far as I can tell the size of the _rayLoc vector is set in the RhiWidget constructor to RAY_LOC_N, which is 3600, so attempts to access indices past that causes the segfault.

This fix works for me, but maybe it would be better to address RHI data that goes past 180 elevation somewhere upstream of this?

For what it's worth, setting the rhi_override_rendering_beam_width parameter in the params file to false, and then setting the rhi_rendering_beam_width parameter (I tried setting it to 2, 1, .5, .1) didn't seem to have an effect when I was debugging this problem (any value I tried still resulted in a segfault). After limiting endIndex to below 3600, I've reverted to setting rhi_override_rendering_beam_width back to false, and things seem to be working.