Closed wkalt closed 1 year ago
I believe I have found the issue. I've opened #2286 as a draft, pending the addition of a regression test to validate the fix.
Your Go test program produces no errors given the same operation, with that above fix. If you are able, please verify the branch to help me make sure it's fixing the issue completely!
The rosbag reindex command is documented as "repairing broken bag files", but when run on a broken bag file it will output a bag that is indexed, but illegal per the ROS bag spec.
This script can be used to demonstrate the issue: https://gist.github.com/wkalt/836cd80f1c6a9b0e87e5e24771c7b8e0
Steps to reproduce:
The resulting bag violates the spec in that it is not a sequence of back to back
<header length><header><data length><data>
records, with each header containing an "op" key, as the bag spec mandates. However, ROS tooling accepts the bag due to reliance on the message index, which is well-formed. The index simply does not point at the junk data present in the file, which occurs after the final chunk and its message indexes.This causes problems for tooling that does not use the index and instead performs a linear scan. It is possible this issue does not present if you are lucky enough to truncate the file on a message boundary.