Skip to content

Errors on particular BAM file #91

@cmdcolin

Description

@cmdcolin

I saw this on the full bam file but selecting a small subset appears to reproduce

❯❯❯ samtools view https://ftp-trace.ncbi.nlm.nih.gov/ReferenceSamples/giab/data_somatic/HG008/Liss_lab/analysis/NIH_HiFi_mm2_mapping/HG008-T_PacBio-HiFi-Revio_20240125_116x_GRCh38-GIABv3_mm2.bam chr1:1-100000 -o subset.bam
❯❯❯ samtools index subset.bam
❯❯❯ RUST_BACKTRACE=1 ./perbase-linux-amd64 base-depth subset.bam
[2025-09-16T18:43:07Z INFO  perbase::commands::base_depth] Running base-depth on: "subset.bam"
[2025-09-16T18:43:07Z INFO  perbase_lib::par_granges] Using 14 worker threads.
[2025-09-16T18:43:07Z INFO  perbase_lib::par_granges] Creating channel of length 21681324 (* 120 bytes to get mem)
[2025-09-16T18:43:08Z INFO  perbase_lib::par_granges] Reading from "subset.bam"
[2025-09-16T18:43:08Z INFO  perbase_lib::par_granges] Processing TID 0:0-248956422

thread '<unnamed>' panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rust-htslib-0.39.5/src/bam/record.rs:1540:6:
index out of bounds: the len is 0 but the index is 148
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
   4: perbase_lib::par_granges::ParGranges<R>::process::{{closure}}::{{closure}}::{{closure}}::{{closure}}
   5: rayon::iter::plumbing::bridge_producer_consumer::helper
   6: rayon_core::join::join_context::{{closure}}
   7: rayon::iter::plumbing::bridge_producer_consumer::helper
   8: rayon_core::join::join_context::{{closure}}
   9: rayon::iter::plumbing::bridge_producer_consumer::helper
  10: rayon_core::join::join_context::{{closure}}
  11: rayon::iter::plumbing::bridge_producer_consumer::helper
  12: rayon_core::join::join_context::{{closure}}
  13: rayon_core::thread_pool::ThreadPool::install::{{closure}}
  14: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute
  15: rayon_core::registry::WorkerThread::wait_until_cold
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
❯❯❯ ./perbase-linux-amd64 --version
perbase 1.1.0

here is backtrace full

 RUST_BACKTRACE=full ./perbase-linux-amd64 base-depth subset.bam
[2025-09-16T18:44:16Z INFO  perbase::commands::base_depth] Running base-depth on: "subset.bam"
[2025-09-16T18:44:16Z INFO  perbase_lib::par_granges] Using 14 worker threads.
[2025-09-16T18:44:16Z INFO  perbase_lib::par_granges] Creating channel of length 21681324 (* 120 bytes to get mem)
[2025-09-16T18:44:17Z INFO  perbase_lib::par_granges] Reading from "subset.bam"
[2025-09-16T18:44:17Z INFO  perbase_lib::par_granges] Processing TID 0:0-248956422

thread '<unnamed>' panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rust-htslib-0.39.5/src/bam/record.rs:1540:6:
index out of bounds: the len is 0 but the index is 148
stack backtrace:
   0:     0x555d93ee4c26 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h46a716bba2450163
   1:     0x555d93e2fbb3 - core::fmt::write::h275e5980d7008551
   2:     0x555d93ee46ef - std::io::Write::write_fmt::h561a66a0340b6995
   3:     0x555d93ee4963 - std::sys::backtrace::BacktraceLock::print::hafb9d5969adc39a0
   4:     0x555d93ee43ce - std::panicking::rust_panic_with_hook::h409da73ddef13937
   5:     0x555d93f175d8 - std::panicking::begin_panic_handler::{{closure}}::h159b61b27f96a9c2
   6:     0x555d93f17539 - std::sys::backtrace::__rust_end_short_backtrace::h5b56844d75e766fc
   7:     0x555d93f17b8c - __rustc[4794b31dd7191200]::rust_begin_unwind
   8:     0x555d93d357ff - core::panicking::panic_fmt::hc8737e8cca20a7c8
   9:     0x555d93d357d9 - core::panicking::panic_bounds_check::hda0827d94e974e71
  10:     0x555d93d552d8 - <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next::h1b63daffda1becfc
  11:     0x555d93d56115 - perbase_lib::par_granges::ParGranges<R>::process::{{closure}}::{{closure}}::{{closure}}::{{closure}}::h2f9776ee368b35b5
  12:     0x555d93d8f733 - rayon::iter::plumbing::bridge_producer_consumer::helper::he366852abe0f928e
  13:     0x555d93d4c8ef - rayon_core::join::join_context::{{closure}}::h173a48138f4b378e
  14:     0x555d93d8fb5b - rayon::iter::plumbing::bridge_producer_consumer::helper::he366852abe0f928e
  15:     0x555d93d4c8ef - rayon_core::join::join_context::{{closure}}::h173a48138f4b378e
  16:     0x555d93d8fb5b - rayon::iter::plumbing::bridge_producer_consumer::helper::he366852abe0f928e
  17:     0x555d93d4c8ef - rayon_core::join::join_context::{{closure}}::h173a48138f4b378e
  18:     0x555d93d8fb5b - rayon::iter::plumbing::bridge_producer_consumer::helper::he366852abe0f928e
  19:     0x555d93d4e398 - rayon_core::join::join_context::{{closure}}::h4b3a052ea4f34d43
  20:     0x555d93d47b61 - rayon_core::thread_pool::ThreadPool::install::{{closure}}::h2e89851a859aea23
  21:     0x555d93d99134 - <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute::h8ae08bd33531c99d
  22:     0x555d93d37f7a - rayon_core::registry::WorkerThread::wait_until_cold::he08018336a945cd2
  23:     0x555d93e50345 - std::sys::backtrace::__rust_begin_short_backtrace::h8b80dd194ccddbdf
  24:     0x555d93e52987 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h9309d2923e070db7
  25:     0x555d93f17e8b - std::sys::pal::unix::thread::Thread::new::thread_start::h1822d22fde68314f
  26:     0x7941ac4a27f1 - start_thread
                               at ./nptl/pthread_create.c:448:8
  27:     0x7941ac533c9c - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  28:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions