FIX_1585_ASAN_FORMAT_SW_ALT / Format switching memory changes cause MSAN/ASAN errors in decoder usage
If `IVAS_DEC_Close()` is called immediately after `IVAS_DEC_Open()` (e.g. adding it in decoder.c), this triggers ASAN/MSAN errors: MSAN ``` ==1527753==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x55728efa019c in ivas_destroy_dec /local/tmu/git/ivas-codec/lib_dec/ivas_init_dec.c:2980:14 #1 0x55728ec1de5f in IVAS_DEC_Close /local/tmu/git/ivas-codec/lib_dec/lib_dec.c:506:9 #2 0x55728ec0e1cb in main /local/tmu/git/ivas-codec/apps/decoder.c:274:5 #3 0x7f5c9e96c249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #4 0x7f5c9e96c304 in __libc_start_main csu/../csu/libc-start.c:360:3 #5 0x55728eb785f0 in _start (/local/tmu/git/ivas-codec/IVAS_dec+0x395f0) SUMMARY: MemorySanitizer: use-of-uninitialized-value /local/tmu/git/ivas-codec/lib_dec/ivas_init_dec.c:2980:14 in ivas_destroy_dec Exiting ``` ASAN ``` ================================================================================================== AddressSanitizer:DEADLYSIGNAL ================================================================= ==1542102==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x55691b5089a2 bp 0x000000000000 sp 0x7fff07175350 T0) ==1542102==The signal is caused by a READ memory access. ==1542102==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used. #0 0x55691b5089a2 in atomic_compare_exchange_strong<__sanitizer::atomic_uint8_t> /local/mnt/workspace/bcain/llvm_rel/final/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_atomic_clang.h:81:10 #1 0x55691b5089a2 in AtomicallySetQuarantineFlagIfAllocated /local/mnt/workspace/bcain/llvm_rel/final/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp:668:10 #2 0x55691b5089a2 in __asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) /local/mnt/workspace/bcain/llvm_rel/final/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp:724:10 #3 0x55691b59f42b in free /local/mnt/workspace/bcain/llvm_rel/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:53:3 #4 0x55691b7cee50 in ivas_destroy_dec /local/tmu/git/ivas-codec/lib_dec/ivas_init_dec.c:2982:13 #5 0x55691b5e658d in IVAS_DEC_Close /local/tmu/git/ivas-codec/lib_dec/lib_dec.c:506:9 #6 0x55691b5dce5d in main /local/tmu/git/ivas-codec/apps/decoder.c:274:5 #7 0x7f71d3628249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #8 0x7f71d3628304 in __libc_start_main csu/../csu/libc-start.c:360:3 #9 0x55691b506640 in _start (/local/tmu/git/ivas-codec/IVAS_dec+0x83640) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /local/tmu/git/ivas-codec/lib_dec/ivas_init_dec.c:2982:13 in ivas_destroy_dec ==1542102==ABORTING ``` `st_ivas->mem_hp20_out` is not initialized until the first good frame, causing this error. This should already be initialized during `IVAS_DEC_Open()`.
issue