UBSAN in jbm_pcmdsp_apa_fx.c
Basic info
Bug description
After activating UBSAN for jbm_pcmdsp_apa_fx.c, we can see three different errors there in the pipeline (see https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/jobs/600315 ). These may be valid cases or remainder from EVS. They should be studies regardless as it is known that there may still be issues in the BASOP implementation of the IVAS time scaling. See below stack traces of the three:
lib_dec/jbm_pcmdsp_apa_fx.c:1395:21: runtime error: implicit conversion from type 'unsigned int' of value 2147483648 (32-bit, unsigned) to type 'Word32' (aka 'int') changed the value to -2147483648 (32-bit, signed)
#0 0xbbd164 in logarithmic_search_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1395:21
#1 0xbbcccb in find_synch_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1522:5
#2 0xbb8d08 in extend_frm_ivas_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:2390:31
#3 0xbb0b45 in apa_exec_ivas_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1053:17
#4 0x45c11d in IVAS_DEC_GetSamplesDecoder /builds/rep/sa4/audio/ivas-basop/lib_dec/lib_dec_fx.c:3536:17
#5 0x45f866 in IVAS_DEC_VoIP_GetSamples /builds/rep/sa4/audio/ivas-basop/lib_dec/lib_dec_fx.c:4385:21
#6 0x43a390 in decodeVoIP /builds/rep/sa4/audio/ivas-basop/apps/decoder.c:2966:28
#7 0x42bbd3 in main /builds/rep/sa4/audio/ivas-basop/apps/decoder.c:635:17
#8 0x7f73bb7fad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#9 0x7f73bb7fae3f in __libc_start_main csu/../csu/libc-start.c:392:3
#10 0x4045e4 in _start (/builds/rep/sa4/audio/ivas-basop/IVAS_dec+0x4045e4)
SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change lib_dec/jbm_pcmdsp_apa_fx.c:1395:21 in
-------------------------------------------------------------------------------------------------------------------------------
lib_dec/jbm_pcmdsp_apa_fx.c:1540:22: runtime error: implicit conversion from type 'Word16' (aka 'short') of value -462 (16-bit, signed) to type 'UWord16' (aka 'unsigned short') changed the value to 65074 (16-bit, unsigned)
#0 0xbbd00b in find_synch_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1540:22
#1 0xbb8d08 in extend_frm_ivas_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:2390:31
#2 0xbb0b45 in apa_exec_ivas_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1053:17
#3 0x45c11d in IVAS_DEC_GetSamplesDecoder /builds/rep/sa4/audio/ivas-basop/lib_dec/lib_dec_fx.c:3536:17
#4 0x45f866 in IVAS_DEC_VoIP_GetSamples /builds/rep/sa4/audio/ivas-basop/lib_dec/lib_dec_fx.c:4385:21
#5 0x43a390 in decodeVoIP /builds/rep/sa4/audio/ivas-basop/apps/decoder.c:2966:28
#6 0x42bbd3 in main /builds/rep/sa4/audio/ivas-basop/apps/decoder.c:635:17
#7 0x7f73bb7fad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#8 0x7f73bb7fae3f in __libc_start_main csu/../csu/libc-start.c:392:3
#9 0x4045e4 in _start (/builds/rep/sa4/audio/ivas-basop/IVAS_dec+0x4045e4)
SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change lib_dec/jbm_pcmdsp_apa_fx.c:1540:22 in
-------------------------------------------------------------------------------------------------------------------------------
lib_dec/jbm_pcmdsp_apa_fx.c:1520:18: runtime error: implicit conversion from type 'UWord16' (aka 'unsigned short') of value 65074 (16-bit, unsigned) to type 'Word16' (aka 'short') changed the value to -462 (16-bit, signed)
#0 0xbbca2e in find_synch_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1520:18
#1 0xbb8d08 in extend_frm_ivas_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:2390:31
#2 0xbb0b45 in apa_exec_ivas_fx /builds/rep/sa4/audio/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:1053:17
#3 0x45c11d in IVAS_DEC_GetSamplesDecoder /builds/rep/sa4/audio/ivas-basop/lib_dec/lib_dec_fx.c:3536:17
#4 0x45f866 in IVAS_DEC_VoIP_GetSamples /builds/rep/sa4/audio/ivas-basop/lib_dec/lib_dec_fx.c:4385:21
#5 0x43a390 in decodeVoIP /builds/rep/sa4/audio/ivas-basop/apps/decoder.c:2966:28
#6 0x42bbd3 in main /builds/rep/sa4/audio/ivas-basop/apps/decoder.c:635:17
#7 0x7f73bb7fad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#8 0x7f73bb7fae3f in __libc_start_main csu/../csu/libc-start.c:392:3
#9 0x4045e4 in _start (/builds/rep/sa4/audio/ivas-basop/IVAS_dec+0x4045e4)
SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change lib_dec/jbm_pcmdsp_apa_fx.c:1520:18 in
Ways to reproduce
Multiple cases but, e.g., with below command-line.
./IVAS_cod -sba 1 13200 48 ./scripts/testv/ltv48_FOA.wav test.bit
./scripts/tools/Linux/networkSimulator_g192 scripts/dly_error_profiles/dly_error_profile_5.dat test.bit test_netsim.bit test.netsimtrace 2 0
./IVAS_dec -fr 20 -no_delay_cmp -Tracefile test.dectrace -VOIP BINAURAL 48 test_netsim.bit test_out.wav
You also need to build with UBSAN options which is something like
export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1,print_stacktrace=1"
python3 scripts/basop_create_ignorelist_for_ubsan.py
make clean
make -j CLANG=3 IGNORELIST=1