Git Product home page Git Product logo

Comments (3)

jdimatteo avatar jdimatteo commented on August 30, 2024

I confirmed that this crash for smaller bins doesn't occur for other bams. There seems to be something special about this bam.

from pipeline.

jdimatteo avatar jdimatteo commented on August 30, 2024

I tracked this down to some internals of samtools while reading the region chr1:30000-60000. In function bam_read1 in bam.c, bam_read/bgzf_read is called to populate a block_len variable. The value is calculated to be about 1.4 billion, which is not a valid value. When the call to kroundup32 rounds it up to 2.8 billion it overflows (since it is a 32 bit signed integer) and it becomes -2147483648, then it is passed as an unsigned 64 bit size argument to realloc, which is interpreted as the absurdly large number 18446744071562067968. This of course fails, and returns a nullptr but samtools doesn't check for the error nullptr case. The block_len calculation of 1.4 billion in bgzf_read is the result of reading 4 bytes at a time from an apparently corrupt samtools structure.

If you run samtools view for this region a similar crash occurs:

jdm@tod:~/Gunk/tmp_large_alloc$ samtools view test.bam chr1:30000-60000
Segmentation fault (core dumped)

We are using samtools version 0.1.19-96b5f2294a from March 2013.

If we run this same command on a more recent samtools version 1.2-56-g5e6d7bd we get a more helpful error message:

samtools view ~/gunk/del_me/test.bam chr1:30000-60000
[main_samview] retrieval of region "chr1:30000-60000" failed due to truncated file or corrupt BAM index file

We might want to consider upgrading to the latest stable version of samtools, which would likely better handle this bam file. But I'm going to go ahead and close this defect since the input is bad and there is nothing straightforward to do to better handle this bad input.

from pipeline.

charlesylin avatar charlesylin commented on August 30, 2024

Thanks John!

-Charles

Charles Y. Lin, Ph.D.
Dana-Farber Cancer Institute
Department of Medical Oncology
[email protected]:[email protected]
http://bradnerlab.com

On Wed, May 27, 2015 at 1:51 AM, John DiMatteo [email protected]
wrote:

Closed #46 #46.


Reply to this email directly or view it on GitHub
#46 (comment).

from pipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.