Skip to content

USAN: implicit conversion from type 'int' to type 'int16_t' changes value in gs_enc.c for OMASA

Basic info

Bug description

Clang USAN sanitizer test in pipeline found an error:

ib_enc/gs_enc.c:548:27: runtime error: implicit conversion from type 'int' of value 32770 (32-bit, signed) to type 'int16_t' (aka 'short') changed the value to -32766 (16-bit, signed)
SUMMARY: UndefinedBehaviorSanitizer: implicit-signed-integer-truncation lib_enc/gs_enc.c:548:27 in 

and

lib_dec/gs_dec.c:646:31: runtime error: implicit conversion from type 'int' of value 32770 (32-bit, signed) to type 'int16_t' (aka 'short') changed the value to -32766 (16-bit, signed)
SUMMARY: UndefinedBehaviorSanitizer: implicit-signed-integer-truncation lib_dec/gs_dec.c:646:31 in 

Link to test pipeline: https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/jobs/228452

Ways to reproduce

Using the scripts:

python3 scripts/IvasBuildAndRunChecks.py --checks CLANG3 -m MODE -p /path/to/my/local/ci_linux_ltv_local.json --usan_supp_file scripts/ubsan.supp

or directly:

make clean
make -j CLANG=3
./IVAS_cod -ism_masa 4 2 ltv48_OMASA_4ISM_2TC_ISM1.csv ltv48_OMASA_4ISM_2TC_ISM2.csv ltv48_OMASA_4ISM_2TC_ISM3.csv ltv48_OMASA_4ISM_2TC_ISM4.csv ltv48_OMASA_4ISM_2TC.met -max_band swb 128000 32 ltv32_OMASA_4ISM_2TC.wav bit
./IVAS_dec mono 32 bit out.wav