Skip to content

USAN: various "nan is outside the range of representable values of type 'short'" errors in OSBA ISM2+planarFOA decoding/rendering with frameloss/JBM

Basic info

Bug description

Clang USAN sanitizer reports multiple errors.

For binaural outputs, this is reported:

lib_dec/ivas_masa_dec.c:1755:60: runtime error: -nan is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_dec/ivas_masa_dec.c:1755:60 in 
lib_dec/ivas_masa_dec.c:1756:62: runtime error: -nan is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_dec/ivas_masa_dec.c:1756:62 in 
lib_com/tools.c:431:20: runtime error: nan is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_com/tools.c:431:20 in 

For channel-based, Ambisonics and EXT output, this is reported:

lib_rend/ivas_dirac_rend.c:1794:22: runtime error: -nan is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_rend/ivas_dirac_rend.c:1794:22 in 
lib_rend/ivas_dirac_rend.c:1795:24: runtime error: -nan is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_rend/ivas_dirac_rend.c:1795:24 in 

For mono, stereo output, this is reported:

lib_com/tools.c:431:20: runtime error: -nan is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_com/tools.c:431:20 in 

These errors likely have a common origin as both the line in ivas_masa_dec.c

        hSpatParamRendCom->azimuth[dirac_write_idx][bin] = (int16_t) roundf( azi / PI_OVER_180 );

and the line in ivas_dirac_rend.c

        azimuth[k] = (int16_t) ( max( -180.0f, min( 180.0f, atan2f( y, x ) / EVS_PI * 180.0f ) ) + 0.5f );

both seem to do the same thing (setting the azimuth angle, the MASA code does similar computations in the lines before).

The error for mono and stereo is from mvr2s.

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

Ways to reproduce

Using the scripts:

dly_profile.dat

python3 scripts/IvasBuildAndRunChecks.py --checks CLANG3 -m OSBA_ISM2_PlanarFOA_b48_fb_cbr -p /path/to/my/local/ci_linux_ltv_local.json --usan_supp_file scripts/ubsan.supp -J dly_profile.dat
Edited by Jan Kiene