ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
747 stars 914 forks source link

rosbag reindex bugfix - seek to truncated position after broken chunk #2286

Closed emersonknapp closed 1 year ago

emersonknapp commented 1 year ago

Fixes #2282

The truncate operation left the current f.tell() read head at the pre-truncated position, so the chunk infos that are written on closing the file started writing at this pre-truncated position, leaving dangling broken chunk data in between the last good chunk and the first file-end chunkinfo.

emersonknapp commented 1 year ago

Added a regression test - verified that test fails without f.seek change, passes with it.

emersonknapp commented 1 year ago

@jacobperron @mjcarroll @sloretz a review would be much appreciated :) hopefully I have made it easy with the regression test.

This bug is a far corner case, but it's real: someone using a format-compliant parser that is reading records without using the index will find invalid records in the file, even after using the reindex command which purports to fix the file.

peci1 commented 1 year ago

Looks good to me, tests pass.