This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error Message when calling HeapMemMP_alloc()

 

I am working on a EVMC6472 and I am having a problem when I tried to allocate DDR2 memory using HeapMemMP_alloc(). If I were to make a limit amount of this function call in various cores, it will pass. However, once I called this function too many times.

I will get the following error in the console.

ti.sdo.ipc.heaps.HeapMemMP: line 442: assertion failure: A_internal: An internal error has occurred

xdc.runtime.Error.raise: terminating execution

 

The memory that I created for this Heap Memory handler (HeapMemMP_Handle) is big enough to fit in the memory that I tried to allocate. How can I determine what is causing this problem, is there any way to find out additional information about this error?

  • Hi Dominic,

    Which version of IPC are you using? Would I be able to rebuild your test case to reproduce the error? If so could you upload/e-mail me the test case (.c and .cfg files).  You can use the ROV tool (Tools -> ROV) and navigate to the view for the ti.sdo.ipc.heaps.HeapMemMP module to find out how much free memory the heap contains.  Using this tool could allow you to determine whether this error is only occurring when the heap runs out of memory.

    Regards,

    Shreyas

  • Hi Shreyas,

    I am using IPC version 1.20.00.23, and unfortunately I don't have a test case that I can email to you, but I can walk you through of what I did.

    In the configuration file, I have specified a shared memory region using DDR2 as the following in bold with starting address of  0xe0000000 and the size of 0x0C000000.

    /* Shared Memory base address and length */
    var SHAREDMEMDDR2           = 0xe0000000;
    var SHAREDMEMSIZEDDR2       = 0x0C000000;
     
    var SharedRegionDDR2 = xdc.useModule('ti.sdo.ipc.SharedRegion');
    SharedRegionDDR2.numEntries = 4;
    SharedRegionDDR2.translate = true;   
    SharedRegionDDR2.setEntryMeta(1,
        { base: SHAREDMEMDDR2,
          len:  SHAREDMEMSIZEDDR2,
          ownerProcId: 0,
          isValid: true,
          cacheLineSize: 128,
          createHeap: true,
          name: "DDR2_MEM",
        });   

    In Core 0 I have created the memory handler as the following in bold :

    #define DDR2_STARTING_ADDR          0xE0000000
    #define MAX_DDR2_SHARED_BUF_SIZE   0x0C000000
    #define DDR2_HEAP_NAME   "DDR2HeapBuf"

        HeapMemMP_Params              heapMemParams;
        HeapMemMP_Handle              gHeapMemDDR2Handle = NULL;
           
        // Create a heap in DDR2
        HeapMemMP_Params_init(&heapMemParams);
        heapMemParams.regionId       = 1;
        heapMemParams.name           = DDR2_HEAP_NAME;
        heapMemParams.sharedAddr     = (void*)DDR2_STARTING_ADDR;
        heapMemParams.sharedBufSize  = MAX_DDR2_SHARED_BUF_SIZE;

        gHeapMemDDR2Handle = HeapMemMP_create(&heapMemParams);

    In Core 1,2,3,4,5. I have been able to open the heap successfully using the #define DDR2_HEAP_NAME

    #define DDR2_HEAP_NAME   "DDR2HeapBuf"

          do
            {
                heapStatus = HeapMemMP_open(DDR2_HEAP_NAME, &gHeapMemDDR2Handle);
            } while( HeapMemMP_S_SUCCESS != heapStatus );    

     

    However, I didn't have much luck allocating different memory in core 1,2,3,4,5 using the provided API. If I call this API for a few times in every core, it seems to work fine. However, if I were to call it more than 8 times or more, it seems to pass on 1 core but fail on the other.

    int bufSize;

    int align;

    void* pBuf = NULL;

    *pBuf = HeapMemMP_alloc(&gHeapMemDDR2Handle, bufSize, align);

     

    Thanks much,

     

    Dominic

  • Dominic,

    I didn't find any problems with your code.  However, I have a couple of more questions:

    1) What value(s) of 'align' & 'bufSize' are you passing to HeapMemMP_alloc?

    2) If you have ROV running, could you open the ROV view for ti.sdo.ipc.heaps.HeapMemMP and post a screenshot of the 'Detailed' and 'FreeList' views after you get the Assert?  This would help me determine the integrity of the heap at that point.

    Thanks,

    Shreyas

  • Hi Shreyas,

    Since Dominic is taking days off for a couple weeks, I'll continue to discuss with your on this issue to get things going.

    I haven't got a chance to use the ROV tool yet, but I can provide answer for your question 1:

    We are calling HeapMemMP_alloc() multiple times (around 20 times, is there a limit for it?) at system initialization, as Dominic mentioned before, with bufSize set to different sizes (ranging from 75KB to 1200B), and align always set to sizeof(long long).

    Do you see any problem with them?

    Once I get a chance to try ROV, I will provide your the screen shot.

    Thanks,

    -- Louis

  • Hi Louis,

    I'll try to reproduce the problem given the information that both of you have provided so far.  Please provide the ROV screenshot if you get it running.

    Regards,

    Shreyas

     

  • Hi Louis/Dominic,

    Apologies for the delayed response to your problem.  After closely reviewing your code, I found a problem that might be causing your problem.  You have chosen to create a shared region #1 and place that shared region in DDR2 memory on C6472.  You have also set the createHeap flag to 'TRUE' for that shared region, thus instructing IPC to automatically create a HeapMemMP instance to manage the memory within the shared region. The range of memory managed by this heap will be from 0xe0000000 to 0xec000000 as configured in your SharedRegion configuration.

    Now, the problem arises because you are attempting to create a HeapMemMP again at runtime and place this HeapMemMP at the same exact location/range.  This HeapMemMP will stomp over the existing HeapMemMP already created by IPC to manage the SR.  The corruption of the existing HeapMemMP state in shared memory is probably causing the assert that you eventually run into at run-time.

    You have two options to get around your problem:

    1) Use the HeapMemMP instance that is created by IPC for your application's use.  You probably don't need to create your own heap because you presumably intend to allocate memory from the entire shared region range.  To get a handle to this heap (from any core--CORE0-CORE5) you can use the SharedRegion_getHeap API.

    2) If you really need to create your own HeapMemMP (i.e. to manage a _subset_ of memory belonging to Shared Region #1) you can create the HeapMemMP as follows:

        HeapMemMP_Params              heapMemParams;
        HeapMemMP_Handle              gHeapMemDDR2Handle = NULL;
           
        // Create a heap in SR1
        HeapMemMP_Params_init(&heapMemParams);
        heapMemParams.regionId       = 1;
        heapMemParams.name           = "myHeap";
        heapMemParams.sharedBufSize  = 0x1000;

        gHeapMemDDR2Handle = HeapMemMP_create(&heapMemParams);

    where 'sharedBufSize' < (size of the shared region).  Note that the 'sharedAddr' parameter is reserved for internal IPC use and should almost never be used directly in IPC applications.  Not specifying the 'sharedAddr' parameter instructs IPC to internally allocate memory for the heap given certain other parameters (i.e. sharedBufSize).

    Regards,

    Shreyas