Open mbaldessari opened 8 years ago
If I break from the caller:
(gdb) break libAACenc/src/psy_configuration.cpp:516 if pePerWindow < 0
Thread 14 "ghb" hit Breakpoint 1, FDKaacEnc_initMinSnr (sfbMinSnrLdData=<optimized out>, blockType=2, sfbActive=12, sfbOffset=0x7fffa80eea80, numLines=128,
samplerate=48000, bitrate=80000) at libAACenc/src/psy_configuration.cpp:516
516 pePart_const = fDivNorm(pePerWindow, barcFactor, &qdiv); qpeprt_const = qperwin - qbfac + DFRACT_BITS-1-qdiv;
(gdb) p pePerWindow
$1 = -2147483648
(gdb) p blockType
$2 = 2
(gdb) p barcFactor
$4 = 1030750208
(gdb) p numLines
$5 = 128
(gdb) p bitrate
$6 = 80000
(gdb) p samplerate
$7 = 48000
My first hunch is that pePerWindow wrapped around when we did fMult(pePerWindow, ONEP5) in libAACenc/src/psy_configuration.cpp
Can you provide the source audio track that reproduces this crash? Even though the backtraces pinpoints where it finally crashed, it's pretty hard to know for sure how to fix it correctly without being able to reproduce it myself (especially since I haven't written this lib myself, I just handle it).
Usually this kind of issues can be reproduced with a short snippet of audio (like a second or so, around the segment that triggers it). You can also provide the sample privately to me at martin@martin.st.
Sigh, I did not get around to work on a proper reproducer track and I had to return the DVD. I will share the tweak I used, maybe someone else will hit this one in the future and can finalize the investigation:
- pePerWindow = fMult(pePerWindow, ONEP5);
+ if (pePerWindow > 0 && pePerWindow > 2147483647 / ONEP5) {
+ pePerWindow = 2147483646;
+ } else {
+ pePerWindow = fMult(pePerWindow, ONEP5);
+ }
Version affected: 0.1.5
Encoder build: gcc -g -Wall -Wextra -pedantic -I./libSYS/include/ -lfdk-aac -o aac-enc wavreader.c aac-enc.c
Encoder test: gdb --args ./aac-enc -t 29 -s 1 out002-shpo.wav out002.aac
Result:
(gdb) run
Starting program: .../libfdk-aac/SOURCES/libfdk-aac/./aac-enc -t 29 -s 1 out002-short.wav out002-short.aac
aac-enc: libFDK/src/fixpoint_math.cpp:439: FIXP_DBL invSqrtNorm2(FIXP_DBL, INT*): Assertion `val > (FIXP_DBL)( ( (0.0) >= 0) ? ((( (double)(0.0) * (((INT64(1)<<(32-1)))) + 0.5 ) >= (double)(((signed)0x7FFFFFFF)) ) ? (INT)(((signed)0x7FFFFFFF)) : (INT)( (double)(0.0) * (double)(((INT64(1)<<(32-1)))) + 0.5)) : ((( (double)(0.0) * (((INT64(1)<<(32-1)))) - 0.5) <= (double)(((signed)0x80000000)) ) ? (INT)(((signed)0x80000000)) : (INT)( (double)(0.0) * (double)(((INT64(1)<<(32-1)))) - 0.5)) )' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff77991d7 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.4.x86_64
(gdb) bt
#0 0x00007ffff77991d7 in raise () from /lib64/libc.so.6
#1 0x00007ffff779a8c8 in abort () from /lib64/libc.so.6
#2 0x00007ffff7792146 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007ffff77921f2 in __assert_fail () from /lib64/libc.so.6
#4 0x00007ffff7ba53bc in invSqrtNorm2 (op=op@entry=-26926470, shift=shift@entry=0x7fffffff7a34) at libFDK/src/fixpoint_math.cpp:439
#5 0x00007ffff7ba53e9 in sqrtFixp (op=-26926470) at libFDK/src/fixpoint_math.cpp:473
#6 0x00007ffff7b969c8 in spectralChange (start=0, result_e=<synthetic pointer>, stop=16, YBufferWriteOffset=<optimized out>, border=8, nSfb=14, EnergyTotal=287, scaleEnergies=0x7caf7299, Energies=0x7fffffff7ac0)
at libSBRenc/src/tran_det.cpp:215
#7 FDKsbrEnc_frameSplitter (Energies=Energies@entry=0x612f10, scaleEnergies=scaleEnergies@entry=0x613010, h_sbrTransientDetector=h_sbrTransientDetector@entry=0x6129d8, freqBandTable=<optimized out>,
tran_vector=tran_vector@entry=0x7fffffff8e84 "", YBufferWriteOffset=<optimized out>, YBufferSzShift=1, nSfb=14, timeStep=2, no_cols=32, tonality=tonality@entry=0x614450) at libSBRenc/src/tran_det.cpp:430
#8 0x00007ffff7b90bdc in FDKsbrEnc_extractSbrEnvelope1 (h_con=h_con@entry=0x611950, sbrHeaderData=sbrHeaderData@entry=0x6119c0, sbrBitstreamData=sbrBitstreamData@entry=0x611a04, hEnvChan=hEnvChan@entry=0x612410,
hCmonData=hCmonData@entry=0x611a20, eData=eData@entry=0x7fffffff8c60, fData=fData@entry=0x7fffffff89b0) at libSBRenc/src/env_est.cpp:1096
#9 0x00007ffff7b8a13f in FDKsbrEnc_EnvEncodeFrame (hEnvEncoder=hEnvEncoder@entry=0x6086c0, iElement=iElement@entry=0, samples=0x6050be, timeInStride=timeInStride@entry=2, sbrDataBits=sbrDataBits@entry=0x604cd8,
sbrData=sbrData@entry=0x6044d8 "", clearOutput=clearOutput@entry=0) at libSBRenc/src/sbr_encoder.cpp:1151
#10 0x00007ffff7b8a70d in sbrEncoder_EncodeFrame (hSbrEncoder=0x6086c0, samples=0x604d20, timeInStride=2, sbrDataBits=<optimized out>, sbrData=<optimized out>) at libSBRenc/src/sbr_encoder.cpp:2325
#11 0x00007ffff7b490c4 in aacEncEncode (hAacEncoder=0x604280, inBufDesc=0x7fffffff9200, outBufDesc=0x7fffffff9230, inargs=0x7fffffffe2a0, outargs=0x7fffffffe290) at libAACenc/src/aacenc_lib.cpp:1587
#12 0x0000000000401cea in main (argc=7, argv=0x7fffffffe488) at aac-enc.c:222
(gdb)
Audio file: https://www.dropbox.com/s/d8oxm7ji9da2cec/out002-short.wav?dl=0
@soutys Sorry for the late reply: It seems like this particular issue already has been fixed in the latest master branch, in commit 5eb6f0db8cc1ecc00af2ef534078e4c65fdf978f. This isn't included in any release yet though (there'll probably be a bunch of more minor fixes coming up, so I won't be making a new release now right away).
@mstorsjo :+1:
This happens 100% when ripping a specific dvd with handbreak. If I do: (gdb) break libFDK/src/fixpoint_math.cpp:542 if L_num < 0
I see the following parameters being passed: Thread 16 "ghb" hit Breakpoint 1, fDivNorm (L_num=-2147483648, L_denum=1030750208, result_e=0x7fffaf15e174) at libFDK/src/fixpoint_math.cpp:542