Skip to content

segfault when reading gsf file with no cartesian coordinates #1531

@rotu

Description

@rotu

Describe the bug
mbinfo fails if the file contains only per-detection polar coordinates (TRAVEL_TIME_ARRAY, BEAM_ANGLE_ARRAY, BEAM_ANGLE_FORWARD_ARRAY) and not Cartesian coordinates (DEPTH_ARRAY, ACROSS_TRACK_ARRAY, ALONG_TRACK_ARRAY).

Opening the attached file with mbinfo crashes with a segfault. Note the segfault is observed with verbosity level -VVVV.

To Reproduce

mbinfo -F 121 -I 737_Public2.gsf -VVVV

737_Public.gsf.zip

Expected behavior

mbinfo should not crash. It should either tolerate only angular data or complain with a more semantic error.

**Screenshots / shell **

dbg4 New record read by MBIO function <mbr_rt_gsfgenmb>
dbg4 New record kind:
dbg4 error: 0
dbg4 kind: 1
dbg4 dataID->recordID: 2

dbg4 New ping read by MBIO function <mbr_rt_gsfgenmb>
dbg4 New ping values:
dbg4 kind: 1
dbg4 time sec: 1717278119
dbg4 time nsec: 766000128
dbg4 longitude: -123.718127
dbg4 latitude: 48.935412
dbg4 speed: 99.000000
dbg4 heading: 145.160000
dbg4 beams: 7
Segmentation fault (core dumped)

Computing context (please complete the following information):

  • OS: Docker on WSL on Windows
  • MB-System version: 5.8.2beta06

Additional context
This code appears to be responsible. Note the access to depth, across_track, along_track without checking that these are populated:

for (int i = 0; i < mb_ping->number_beams; i++)
fprintf(stderr, "dbg4 beam:%d flag:%d bath:%f acrosstrack:%f alongtrack:%f\n", i, mb_ping->beam_flags[i],
mb_ping->depth[i], mb_ping->across_track[i], mb_ping->along_track[i]);
if (mb_ping->mc_amplitude != NULL)
for (int i = 0; i < mb_ping->number_beams; i++)
fprintf(stderr, "dbg4 beam:%d amp:%f acrosstrack:%f alongtrack:%f\n", i, mb_ping->mc_amplitude[i],
mb_ping->across_track[i], mb_ping->along_track[i]);
if (mb_ping->mr_amplitude != NULL)
for (int i = 0; i < mb_ping->number_beams; i++)
fprintf(stderr, "dbg4 beam:%d amp:%f acrosstrack:%f alongtrack:%f\n", i, mb_ping->mr_amplitude[i],
mb_ping->across_track[i], mb_ping->along_track[i]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions