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

Running concurrent pack operations using same archive results in archive corruption #17

Open
tasleson opened this issue Jun 17, 2024 · 0 comments

Comments

@tasleson
Copy link
Contributor

If you run a couple pack operations at the same time they will both seem to finish without error, but if you try to run an additional pack operation by itself you will get an error like:

$ target/release/blk-archive pack -a corrupt/ ~/Downloads/Fedora-Workstation-Live-x86_64-40-1.14.iso
Packing /home/tasleson/Downloads/Fedora-Workstation-Live-x86_64-40-1.14.iso ... [                                        ] Remaining 0s                                                                       thread 'main' panicked at src/slab.rs:427:9:
assertion `left == right` failed
  left: 104990166636822547
 right: 2330139156611598972
stack backtrace:
   0: rust_begin_unwind
             at /builddir/build/BUILD/rustc-1.78.0-src/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/panicking.rs:72:14
   2: core::panicking::assert_failed_inner
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/panicking.rs:343:17
   3: core::panicking::assert_failed
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/panicking.rs:298:5
   4: blk_archive::slab::SlabFile::read_
             at /home/tasleson/projects/blk-archive/src/slab.rs:427:9
   5: blk_archive::slab::SlabFile::read
             at /home/tasleson/projects/blk-archive/src/slab.rs:456:33
   6: blk_archive::pack::DedupHandler::get_hash_index::{{closure}}
             at /home/tasleson/projects/blk-archive/src/pack.rs:107:23
   7: lru::LruCache<K,V,S>::try_get_or_insert
             at /home/tasleson/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lru-0.10.1/src/lib.rs:550:19
   8: blk_archive::pack::DedupHandler::get_hash_index
             at /home/tasleson/projects/blk-archive/src/pack.rs:105:9
   9: <blk_archive::pack::DedupHandler as blk_archive::iovec::IoVecHandler>::handle_data
             at /home/tasleson/projects/blk-archive/src/pack.rs:310:34
  10: <blk_archive::content_sensitive_splitter::ContentSensitiveSplitter as blk_archive::splitter::Splitter>::next_data
             at /home/tasleson/projects/blk-archive/src/content_sensitive_splitter.rs:191:17
  11: blk_archive::pack::Packer::pack
             at /home/tasleson/projects/blk-archive/src/pack.rs:468:21
  12: blk_archive::pack::run
             at /home/tasleson/projects/blk-archive/src/pack.rs:762:5
  13: blk_archive::main_
             at /home/tasleson/projects/blk-archive/src/main.rs:200:13
  14: blk_archive::main
             at /home/tasleson/projects/blk-archive/src/main.rs:221:22
  15: core::ops::function::FnOnce::call_once
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at src/slab.rs:175:36:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }
stack backtrace:
   0: rust_begin_unwind
             at /builddir/build/BUILD/rustc-1.78.0-src/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/result.rs:1654:5
   3: core::result::Result<T,E>::unwrap
             at /builddir/build/BUILD/rustc-1.78.0-src/library/core/src/result.rs:1077:23
   4: blk_archive::slab::write_slab
             at /home/tasleson/projects/blk-archive/src/slab.rs:175:22
   5: blk_archive::slab::writer_
             at /home/tasleson/projects/blk-archive/src/slab.rs:205:13
   6: blk_archive::slab::writer
             at /home/tasleson/projects/blk-archive/src/slab.rs:223:5
   7: blk_archive::slab::SlabFile::open_for_write::{{closure}}
             at /home/tasleson/projects/blk-archive/src/slab.rs:358:35

blk-archive/src/slab.rs

Lines 419 to 427 in ebd88d7

pub fn read_(&mut self, slab: u32) -> Result<Vec<u8>> {
let mut shared = self.shared.lock().unwrap();
let offset = shared.offsets.offsets[slab as usize];
shared.data.seek(SeekFrom::Start(offset))?;
let magic = shared.data.read_u64::<LittleEndian>()?;
let len = shared.data.read_u64::<LittleEndian>()?;
assert_eq!(magic, SLAB_MAGIC);

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

1 participant