Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compressed_count = 0 causes panic #63

Open
YorickdeJong opened this issue Feb 1, 2024 · 2 comments
Open

compressed_count = 0 causes panic #63

YorickdeJong opened this issue Feb 1, 2024 · 2 comments

Comments

@YorickdeJong
Copy link

Hi,

I tried to run the bevy example in the library. I'm using macOS 13.3 and ran the following command:

cargo run --example bevy ~/Downloads/TornadoLoopingVDB/TornadoLooping/TornadoVDB/tornado_0000.vdb

This produces the following error:

thread 'Compute Task Pool (5)' panicked at /Users/yorickdejong/vdb-rs/src/reader.rs:240:17:
assertion `left == right` failed
 left: 0
right: 30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy::setup`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

It seems that the compressed count is 0, instead of 30:

    fn read_compressed_data<T: Pod>(
       reader: &mut R,
       _archive: &ArchiveHeader,
       gd: &GridDescriptor,
       count: usize,
   ) -> Result<Vec<T>, ParseError> {
       Ok(if gd.compression.contains(Compression::BLOSC) {
           let num_compressed_bytes = reader.read_i64::<LittleEndian>()?;
           let compressed_count = num_compressed_bytes / std::mem::size_of::<T>() as i64;

           trace!("Reading blosc data, {} bytes", num_compressed_bytes);
           if num_compressed_bytes <= 0 {
               let mut data = vec![T::zeroed(); (-compressed_count) as usize];
               reader.read_exact(cast_slice_mut(&mut data))?;
               assert_eq!(-compressed_count as usize, count);
               data

The vdb file can be downloaded from this link (it's the tornado): https://jangafx.com/software/embergen/download/free-vdb-animations/

@Jasper-Bekkers
Copy link
Member

This is supposed to mimic the code in https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb%2Fopenvdb%2Fio%2FCompression.cc pretty much exactly, if it doesn't then that's a bug.

Feel free to contribute a patch by opening a pull request!

@YorickdeJong
Copy link
Author

Hi @Jasper-Bekkers,

Thanks, will open a pull request when I'm done with the patch

Best,
Yorick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants