Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Fixed corrupted messages when reopening a rosbag with a different file (#1176) - #1192

Merged
dirk-thomas merged 2 commits into
ros:lunar-develfrom
racko:fix_rosbag_close
Oct 23, 2017
Merged

dirk-thomas merged 2 commits into
ros:lunar-develfrom
racko:fix_rosbag_close

Conversation

@racko

@racko racko commented Oct 17, 2017

Copy link
Copy Markdown
Contributor
  • Cleaned up more state in Bag::close() and ChunkedFile::close()
  • It was not investigated how exactly the bug worked

I kept #1188 as-is to demonstrate the failing test. (I think I remember that the CI only builds the latest commit in a pull-request, right?)

Comment thread tools/rosbag_storage/src/bag.cpp Outdated
chunk_open_ = false;
curr_chunk_data_pos_ = 0;
current_buffer_ = 0;
decompressed_chunk_ = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be easier now that #1189 has been merged. Please update the patch to call the new init method instead.

* Bag::decompressed_chunk_ was not reset in close(). decompressed_chunk_
stores the offset (within the file) of the compressed chunk whose
decompressed content is currently stored in decompress_buffer_. Since it
wasn't reset in close(), if the offset is the same as that of the first
chunk in the file opened next, Bag::decompressChunk() assumed that
it had already decompressed that chunk in the new file and just returned.
As a result, some member functions of Bag worked on the decompressed
chunk of the old bag.
* Cleaned up more state in Bag::close() and ChunkedFile::close()
@racko

racko commented Oct 21, 2017

Copy link
Copy Markdown
Contributor Author

Done. I also analyzed the bug a bit more and found the following cause, which I added to the commit message:

* Bag::decompressed_chunk_ was not reset in close(). decompressed_chunk_
stores the offset (within the file) of the compressed chunk whose
decompressed content is currently stored in decompress_buffer_. Since it
wasn't reset in close(), if the offset is the same as that of the first
chunk in the file opened next, Bag::decompressChunk() assumed that
it had already decompressed that chunk in the new file and just returned.
As a result, some member functions of Bag worked on the decompressed
chunk of the old bag.

@dirk-thomas

Copy link
Copy Markdown
Member

Thank you for the patch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants