Skip to content

Floating point exception caused by patternLen=0 triggering division by zero error. #171

@dgruano

Description

@dgruano

tldr; check the backtrace of the exception

I have been fighting for a couple of days trying to use snap v2.0.5 to align my reads to a Trinity transcriptome assembly, getting a "Floating Point Exception" during alignment. The triggering command is:

snap-aligner paired \ 
Trinity-GG R1.fq R2.fq \ 
-o Trinity-GG.bam -s 0 1000 -H 300000 -h 2000 \
-d 30 -t 16 -b -M -D 5 -om 5 -omax 10 -hdp

Note that the arguments used here are copied from the last version of Transrate, a quality control tool for de-novo transcriptome assembly using snap 1.0dev.96. The command with the same dataset worked with snap 1.0dev.96. If any of these arguments is not a good choice now for v2.0.5, that may be the culprit.

This happened with several of my FASTQ file pairs, so I took one and ran the same command with a subsample. After running the command three times and checking the outputs of the -hdp flag (many lines saying reporter:counter:SNAP,readsAligned,10000), I noticed the error came always at the same number of lines: maybe a particular read was the cause.

Quick inspection of the fastq files did not suggest any particular problem: all reads have the same length, all quality strings have the same length too.

I recompiled snap with -g -O0 flags and used gdb to debug the problem. Here is my log:

Thread 7 "snap-aligner" received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0x2aab4595b700 (LWP 45069)]
0x00005555555c4c54 in AffineGapVectorizedWithCigar::computeGlobalScore (
    this=this@entry=0x555556b11ce0, 
    text=text@entry=0x2aaab957b4dd 'T' <repeats 19 times>, "ATTTTTTA", 'T' <repeats 12 times>, "A", 'T' <repeats 24 times>, "CCTTTTGTATTAACTTTTATTTACCTGTTAATGAAATCATCAAAATACAATGAGTAGGCACCTTCTATGTACATCTGTCCTAGTGCTTTTGAGTGTTAATCTAAACTCATACATCAACAAACATTCTAGCCGGACA"..., 
    textLen=textLen@entry=127, pattern=0x2aab4594858e "", quality=0x2aab45948d5e "", 
    patternLen=patternLen@entry=0, w=3, cigarBuf=0x2aab45946bf0 "t}\224E\253*", 
    cigarBufLen=3996, useM=true, format=BAM_CIGAR_OPS, o_cigarBufUsed=0x2aab45947bdc, 
    o_netDel=0x2aab45947cbc, o_tailIns=0x2aab45947d74) at SNAPLib/AffineGapVectorized.cpp:351
351             __m128i v_globalAlignmentScore = _mm_load_si128(Hminus1ptr + ((patternLen - 1) % numVec));
(gdb) Quit
(gdb) set logging on
Warning: 'set logging on', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled on'.

Copying output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) bt
#0  0x00005555555c4c54 in AffineGapVectorizedWithCigar::computeGlobalScore (this=this@entry=0x555556b11ce0, text=text@entry=0x2aaab957b4dd 'T' <repeats 19 times>, "ATTTTTTA", 'T' <repeats 12 times>, "A", 'T' <repeats 24 times>, "CCTTTTGTATTAACTTTTATTTACCTGTTAATGAAATCATCAAAATACAATGAGTAGGCACCTTCTATGTACATCTGTCCTAGTGCTTTTGAGTGTTAATCTAAACTCATACATCAACAAACATTCTAGCCGGACA"..., textLen=textLen@entry=127, pattern=0x2aab4594858e "", quality=0x2aab45948d5e "", patternLen=patternLen@entry=0, w=3, cigarBuf=0x2aab45946bf0 "t}\224E\253*", cigarBufLen=3996, useM=true, format=BAM_CIGAR_OPS, o_cigarBufUsed=0x2aab45947bdc, o_netDel=0x2aab45947cbc, o_tailIns=0x2aab45947d74) at SNAPLib/AffineGapVectorized.cpp:351
#1  0x00005555555c63a7 in AffineGapVectorizedWithCigar::computeGlobalScoreNormalized (this=this@entry=0x555556b11ce0, text=text@entry=0x2aaab957b4dd 'T' <repeats 19 times>, "ATTTTTTA", 'T' <repeats 12 times>, "A", 'T' <repeats 24 times>, "CCTTTTGTATTAACTTTTATTTACCTGTTAATGAAATCATCAAAATACAATGAGTAGGCACCTTCTATGTACATCTGTCCTAGTGCTTTTGAGTGTTAATCTAAACTCATACATCAACAAACATTCTAGCCGGACA"..., textLen=127, pattern=pattern@entry=0x2aab4594858e "", quality=quality@entry=0x2aab45948d5e "", patternLen=0, k=<optimized out>, cigarBuf=<optimized out>, cigarBufLen=<optimized out>, useM=true, format=<optimized out>, o_cigarBufUsed=<optimized out>, o_addFrontClipping=<optimized out>, o_netDel=<optimized out>, o_tailIns=<optimized out>) at SNAPLib/AffineGapVectorized.cpp:1078
#2  0x00005555555baa82 in SAMFormat::computeCigar (cigarFormat=cigarFormat@entry=BAM_CIGAR_OPS, genome=0x555555618c90, ag=ag@entry=0x555556b11ce0, cigarBuf=cigarBuf@entry=0x2aab4594a054 "`\005", cigarBufLen=cigarBufLen@entry=3996, data=data@entry=0x2aab4594858e "", quality=0x2aab45948d5e "", dataLength=0, score=3, basesClippedBefore=150, extraBasesClippedBefore=0, basesClippedAfter=0, o_extraBasesClippedAfter=0x2aab45947d78, genomeLocation=203077013, useM=true, o_editDistance=0x2aab4594803c, o_cigarBufUsed=0x2aab45947d70, o_addFrontClipping=0x2aab45948050, o_backClippingMissedByLV=0x2aab45947d74) at SNAPLib/SAM.cpp:2529
#3  0x00005555555a20d3 in BAMFormat::computeCigarOps (genome=<optimized out>, ag=ag@entry=0x555556b11ce0, cigarBuf=cigarBuf@entry=0x2aab4594a050 "\004\004", cigarBufLen=cigarBufLen@entry=4000, data=0x2aab4594858e "", quality=<optimized out>, dataLength=0, score=3, basesClippedBefore=150, extraBasesClippedBefore=0, basesClippedAfter=0, frontHardClipping=0, backHardClipping=0, genomeLocation=203077013, isRC=true, useM=true, o_editDistance=0x2aab4594803c, o_addFrontClipping=0x2aab45948050, o_refSpan=0x2aab45948044) at SNAPLib/Bam.cpp:2151
#4  0x00005555555a2938 in BAMFormat::writePairs (this=0x5555556021a0, context=..., lv=0x555556ac9ce0, ag=0x555556b11ce0, useAffineGap=true, buffer=<optimized out>, bufferSpace=16777216, spaceUsed=0x2aab4594b1d0, qnameLen=0x2aab4594b1b0, reads=0x2aab4595aed0, locations=0x2aab4594b1c0, result=0x2aaaaac4f008, isSecondary=false, emitInternalScore=false, internalScoreTag=0x555556d3dfe9 "", attachAlignmen--Type <RET> for more, q to quit, c to continue without paging--
tTime=false, writeOrder=0x2aab4594b178, cumulativePositiveAddFrontClipping=0x2aab4594b170, secondReadLocationChanged=0x2aab4594b15e, outOfSpace=0x2aab4594b15f) at SNAPLib/Read.h:527
#5  0x0000555555567c8e in SimpleReadWriter::writePairs (this=0x555556ac9cc0, context=..., reads=0x2aab4595aed0, result=0x2aaaaac4f008, nResults=<optimized out>, singleResults=0x2aab4595adb0, nSingleResults=<optimized out>, firstIsPrimary=true, useAffineGap=true) at SNAPLib/ReadWriter.cpp:468
#6  0x00005555555ae912 in PairedAlignerContext::runIterationThreadImpl (this=<optimized out>, reads=reads@entry=0x2aab4595aed0) at SNAPLib/PairedAligner.cpp:875
#7  0x00005555555af154 in PairedAlignerContext::runIterationThread (this=<optimized out>) at SNAPLib/PairedAligner.cpp:471
#8  0x000055555555e7a7 in AlignerContext::runThread (this=this@entry=0x2aab434e4018) at SNAPLib/AlignerContext.cpp:233
#9  0x00005555555af182 in ParallelTask<PairedAlignerContext>::threadWorker (threadArg=0x2aab434e4018) at SNAPLib/ParallelTask.h:192
#10 0x00005555555c241a in (anonymous namespace)::runThread (infoVoidPtr=0x555556aaddb0) at SNAPLib/Compat.cpp:1565
#11 0x00002aaaab3cde25 in start_thread () from /usr/lib64/libpthread.so.0
#12 0x00002aaaab6da34d in clone () from /usr/lib64/libc.so.6

It seems that patternLen==0 is making numVec==0

int numVec = (patternLen + VEC_SIZE - 1) / VEC_SIZE; // Number of vector segments

causing later a division by zero error in:

__m128i v_globalAlignmentScore = _mm_load_si128(Hminus1ptr + ((patternLen - 1) % numVec));

I don't know the codebase enough, so I'm not sure how to trace back where the culprit comes from. The parameters I chose for my index or alignmen? Any default values that changed from version 1.0dev.96?

I'm happy to provide any additional info that might be helpful to troubleshoot this.

Cheers,

Dani

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions