ittiam-systems / libmpegh

MPEG-H 3D Audio Low Complexity Profile Decoder. Encoder: https://github.com/ittiam-systems/libmpeghe
http://www.ittiam.com/
BSD 3-Clause Clear License
86 stars 19 forks source link

negative-size-param reported by asan when decoding a sample #46

Closed amiartus closed 1 year ago

amiartus commented 1 year ago

Hello,

Please have a look at following report by asan when playing a sample:

  1. amend CMakeLists.txt
    
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index a0226d5..7fe656c 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -7,6 +7,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    set(CMAKE_SUPPRESS_REGENERATION true)

+add_compile_options(-fsanitize=address) +add_link_options(-fsanitize=address) +

Add Library Target

add_library ( ia_mpeghd_lib


2. build and run with file [crash-2.txt](https://github.com/ittiam-systems/libmpegh/files/10706709/crash-2.txt)

`
./ia_mpeghd_testbench -ifile:/crash-2.txt -ofile:1.wav
`

Stack trace:

0 0x7fd3cc85e867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145

1 0x55a7982707c2 in malloc_global

2 0x55a7982a05ef in impeghd_alloc_and_assign_mem

3 0x55a7982a1cee in ia_mpegh_dec_create

4 0x55a79827101b in impeghd_main_process

5 0x55a798275ead in main

Vamsi100858 commented 1 year ago

Hi @miartad , Can you please let know the compiler used and platform (x86/x64/armv7) on which this crash is observed ? We tried with clang-8 and not able to observe the crash. Thanks

amiartus commented 1 year ago

Hi @Vamsi100858

I have tried with clang 15 and gcc 11, both show the error when sanitize address parameter is added to cmake.

~/projects/libmpegh/b$ /usr/bin/cc --version
cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
~/projects/libmpegh/b$ clang --version
Ubuntu clang version 15.0.6
~/projects/libmpegh/b$ ubuntu-report
This is the result of hardware and optional installer/upgrader that we collected:
{
  "Version": "22.04",
  "OEM": {
    "Vendor": "Dell Inc.",
    "Product": "Precision 14 5470",
    "Family": "Precision"
  },
  "BIOS": {
    "Vendor": "Dell Inc.",
    "Version": "1.4.2"
  },
  "Arch": "amd64",
amiartus commented 1 year ago

@Vamsi100858 were you able to reproduce the issue?

SakethSathuvalli commented 1 year ago

Hi @miartad - Yes we are able to reproduce the issue with clang-14 and on MSVS as well. The root cause for the issue is truncation error happening in floating point arithmetic of a module. An initial(/quick) fix that we see is going for a bigger container format (from FLOAT32 to FLOAT64) for few of the variables. However, We are looking for other optimal solutions for scenarios like this. This will take some time at our end.

Thanks for Your patience and also for bringing this issue to our notice.

SakethSathuvalli commented 1 year ago

Hi @miartad,

We have added a simple fix (of all the things that we tried internally) for this issue, since its been some time this issue is added here. Thanks for Your patience!

-- Saketh

amiartus commented 1 year ago

hi @SakethSathuvalli I checked the main branch and the issue is fixed there by a389d71182ef9c4d3c2d906684b5a0abce6d3748

fatal error: Ittiam mpegh_dec  core coder module :Initialization: : Initialization fatal error

the fix in #46 is not necessary to resolve this issue