samtools / htscodecs

Custom compression for CRAM and others.
Other
30 stars 18 forks source link

rans_compress on empty input #99

Closed shubhamchandak94 closed 1 year ago

shubhamchandak94 commented 1 year ago

I ran rans_compress (https://github.com/samtools/htscodecs#static-rans-4x8-introduced-in-cram-v30) on an empty input, and it crashed with signal: 8, SIGFPE: erroneous arithmetic operation. Is this expected or is it a problem with my setup? Thanks!

This is the trace:

==32342== Process terminating with default action of signal 8 (SIGFPE)
==32342==  Integer divide by zero at address 0x1003E0DA15
==32342==    at 0x130649: rans_compress_O0 (rANS_static.c:99)
jkbonfield commented 1 year ago

On Fri, Sep 29, 2023 at 07:35:48PM -0700, Shubham Chandak wrote:

I ran rans_compress on an empty input, and it crashed with signal: 8, SIGFPE: erroneous arithmetic operation. Is this expected or is it a problem with my setup? Thanks!

No, it's not expected and it's not a problem with your setup. It's just getting a divide by zero error. It ought to check for size zero.

==32342== Process terminating with default action of signal 8 (SIGFPE) ==32342== Integer divide by zero at address 0x1003E0DA15 ==32342== at 0x130649: rans_compress_O0 (rANS_static.c:99)

Thanks for bug report. I'll check the other functions too.

James

-- James Bonfield @.***) The Sanger Institute, Hinxton, Cambs, CB10 1SA

-- The Wellcome Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is Wellcome Sanger Institute, Wellcome Genome Campus, Hinxton, CB10 1SA.

jkbonfield commented 1 year ago

Hello Shubham,

Thanks for all your testing and bug reporting. We've now got some fuzzers doing round trips on the inputs for rANS and arithmetic coding, but I need to add these round-trip fuzzing for fqzcomp and name tokeniser too. It's a bit more fiddly because of needing to construct meta-data as well.

Anyway, a new point release just went in - 1.5.2.

Regards,

James

-- James Bonfield @.***) The Sanger Institute, Hinxton, Cambs, CB10 1SA

-- The Wellcome Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is Wellcome Sanger Institute, Wellcome Genome Campus, Hinxton, CB10 1SA.

jkbonfield commented 1 year ago

Fixed in #101. I forgot to add an appropriate "Fixes" line to the commit.

shubhamchandak94 commented 1 year ago

Thanks for the update James! Fuzzer will definitely help.