AnsweredAssumed Answered

Issue with heap_debug libraries and C++ (HeapFunctionMismatch)

Question asked by Rudstone on Jan 21, 2014
Latest reply on Jan 22, 2014 by AndyK2

I'd like to use the debug_heap libraries ( they have proved very handy debugging a port of an RTOS ) but there appears to be a big problem when using C++'s new and delete operators.


This can be easy reproduced as follows.


Create a new project (CCES project in C++)

set the option to "link against heap debugging libraries"

make the main application as follows


#include "stdio.h"

#include "heap_debug.h"


int main(void)



//    adi_core_1_enable();


    adi_heap_debug_disable( _HEAP_HPL_GEN );

    adi_heap_debug_enable( _HEAP_STDERR_DIAG );


    char *test;


    printf( "malloc'ing 16 bytes\n" );

    test = (char *)malloc( 16 );

    printf( "free'ing 16 bytes\n" );

    free( test );


    printf( "new'ing 16 bytes\n" );

    test = new char[16];

    printf( "delete'ing 16 bytes\n" );

    delete test;




        printf( "didn't get here\n" );



    return 0;



when running this application the console output should be as follows:


malloc'ing 16 bytes

free'ing 16 bytes

new'ing 16 bytes

delete'ing 16 bytes

Heap error in block 0xFF9039A4: allocation type mismatch

  Call stack: 0xFFA01CEC 0xFFA00128


A fatal error or exception has occurred.

  Description:   A heap operation which is incompatible with a previous operation has been detected.

  General Type:  LibraryError

  Specific Type: HeapFunctionMismatch

  General Code:  0x7

  Specific Code: 0x108

  Error Value:   0xff9039a4

  Error PC:      0xffa0226a


I have debugged this as far as I can but there is no source for the heap_debug libraries. The fault is raised in the function ___adi_heap_debug_free.

The heap debugs alloc_info block only differs in one location when using malloc and new ( 1 for malloc and 8 for new ).


would it be possible to get the source for the heap debug libraries, or a fix for this issue, or any useful information.



CCES version running on Windows 7 64 bit.

BF609 running on Avnet Finboard.

Emulating with ICE 100-B


Thanks in advance.