Skip to content

Align to float: Memory leak in ivas-float-update

Basic info

Bug description

When comparing ivas-float-update with float main via the float MR pipeline (ivas-codec-pc/ivas-codec!2393 (closed)), an asan error was triggered for split rendering testcases:

 Direct leak of 440 byte(s) in 1 object(s) allocated from:
        #0 0x49c48d in __interceptor_malloc (/home/gitlab-runner/builds/xPotPWfvP/0/rep/ivas-codec-pc/ivas-codec/IVAS_dec+0x49c48d)
        #1 0x4f3ce5 in ivas_create_handle_isar /home/gitlab-runner/builds/xPotPWfvP/0/rep/ivas-codec-pc/ivas-codec/ivas-basop/lib_dec/lib_dec.c:5358:65
        #2 0x4f3ac2 in IVAS_DEC_Configure /home/gitlab-runner/builds/xPotPWfvP/0/rep/ivas-codec-pc/ivas-codec/ivas-basop/lib_dec/lib_dec.c:572:24
        #3 0x4d0b1a in main /home/gitlab-runner/builds/xPotPWfvP/0/rep/ivas-codec-pc/ivas-codec/ivas-basop/apps/decoder.c:451:20
        #4 0x7f48cba52d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    
    SUMMARY: AddressSanitizer: 440 byte(s) leaked in 1 allocation(s).[gw1] linux -- Python 3.10.12 /usr/bin/python3

When comparing the code, there seems to be something not aligned in ivas_destroy_handle_isar.

(float) Main:

        ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL );

        if ( ( *hSplitBinRend )->hCldfbDataOut != NULL )
        {
            free( ( *hSplitBinRend )->hCldfbDataOut );
            ( *hSplitBinRend )->hCldfbDataOut = NULL;
        }

        free( ( *hSplitBinRend ) );
        ( *hSplitBinRend ) = NULL;
    }

    return;
}

ivas-float-update:

        ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL );

        if ( ( *hSplitBinRend )->hCldfbDataOut != NULL )
        {
            free( ( *hSplitBinRend )->hCldfbDataOut );
            ( *hSplitBinRend )->hCldfbDataOut = NULL;
#ifdef FIX_1319_STACK_SBA_DECODER

            free( ( *hSplitBinRend ) );
            ( *hSplitBinRend ) = NULL;
#endif
        }
    }

    return;
}

I did not test yet if this resolves the problem, but also BASOP main has the last free outside the if, so this seems like an obvious misalignment to me.

As float and BASOP main are both fine, there is no actual need to fix this, but it would make testing ivas-float-update against float main easier.

Pipeline here: https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/jobs/628906

Ways to reproduce