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.

AM5728: GateMP_enter Segmentation Fault

Part Number: AM5728

I attempted to add GateMP functionality to the IPC BIg Data Example and get a segment fault on the first GateMP_enter() call.  Any suggestions are appreciated.   Apparently I don't have permission to post code so I've included it inline.  I apologize that it's hard to read.

/*
* ======== App_exec ========
*/
Int App_exec(Void)
{
Int status;
App_Msg * msg;
UInt32 *bigDataLocalPtr;
Int i,j;
UInt16 regionId1=1;
SharedRegion_Entry *pSrEntry;
void *sharedRegionAllocPtr=NULL;
Int pool_id;
CMEM_AllocParams cmemAttrs;
HeapMem_Handle sr1Heap;
UInt16 regionId;
UInt32 errorCount=0;
Int retVal;
bigDataLocalDesc_t bigDataLocalDesc;
SharedRegion_Config sharedRegionConfig;
SharedRegion_Entry srEntry;
HeapMem_Config HeapMemConfig;
HeapMem_Params heapMem_params;
Memory_Stats stats;
HeapMem_ExtendedStats extStats;

GateMP_Params gparams;
GateMP_Handle gateHandle;
IArg gateKey;

printf("--> App_exec-4:\n");

/* CMEM: contiguous memory manager for HLOS */
/* initialised here */
status = CMEM_init();

if (status < 0) {
printf("CMEM_init failed\n");
goto leave;
}
else {
printf("CMEM_init success\n");
}

pool_id = CMEM_getPool(BIG_DATA_POOL_SIZE);
if (pool_id < 0) {
printf("CMEM_getPool failed\n");
goto leave;
}
printf("CMEM_getPool success\n");

cmemAttrs.type = CMEM_HEAP;
cmemAttrs.flags = CMEM_CACHED;
cmemAttrs.alignment = 0;
sharedRegionAllocPtr = CMEM_allocPool(pool_id, &cmemAttrs);
if (sharedRegionAllocPtr == NULL) {
printf("CMEM_allocPool failed\n");
goto leave;
}
printf("CMEM_allocPool success: Allocated buffer %p\n", sharedRegionAllocPtr);

/* Create shared region */
SharedRegion_getConfig (&sharedRegionConfig);
status = SharedRegion_setup (&sharedRegionConfig);
if (status < 0) {
printf("SharedRegion_setup failed\n");
goto leave;
}
printf("SharedRegion_setup success\n");

/* Configure srEntry */
srEntry.base = sharedRegionAllocPtr;
srEntry.len = BIG_DATA_POOL_SIZE;
srEntry.ownerProcId = MultiProc_self();
/* Make sure this is enabled if using Cached memory */
srEntry.isValid = TRUE;
srEntry.cacheEnable = TRUE;
srEntry.createHeap = FALSE;
srEntry.cacheLineSize = 128;
srEntry.name = "SR1";

status = SharedRegion_setEntry (regionId1, &srEntry);

pSrEntry = SharedRegion_getEntryPtr(regionId1);
printf("App_taskFxn: SR_1, base 0x%x, len=%x\n", (UInt32)pSrEntry->base, pSrEntry->len);

regionId = regionId1;

/* Setup HeapMem module */
HeapMem_getConfig (&HeapMemConfig);
status = HeapMem_setup (&HeapMemConfig);
if (status < 0) {
printf("HeapMem_setup failed\n");
goto leave;
}
printf("HeapMem_setup success\n");

/* Create HeapMP at run-time:
This heap is intended to be used for big data ipc */
HeapMem_Params_init(&heapMem_params);
heapMem_params.name = "sr1HeapMem";
heapMem_params.sharedAddr = pSrEntry->base;
heapMem_params.sharedBufSize = ROUNDUP(pSrEntry->len, pSrEntry->cacheLineSize);
heapMem_params.gate = NULL;
sr1Heap = HeapMem_create(&heapMem_params);
if (!sr1Heap) {
printf("sr1Heap creation failed\n");
status = -1;
goto leave;
}
printf("HeapMem_create success\n");
HeapMem_getStats((HeapMem_Handle)sr1Heap, &stats);
printf("App_taskFxn: SR_1 heap, totalSize=%d,totalFreeSize=%d,largestFreeSize=%d\n", stats.totalSize, stats.totalFreeSize, stats.largestFreeSize);
HeapMem_getExtendedStats((HeapMem_Handle)sr1Heap, &extStats);
printf("App_taskFxn: SR_1 heap, buf=0x%p,size=%d\n", extStats.buf, extStats.size);


//==========================================
// Create GateMP object
//==========================================
GateMP_Params_init(&gparams);
gparams.localProtect = GateMP_LocalProtect_THREAD;
gparams.remoteProtect = GateMP_RemoteProtect_SYSTEM;
gparams.name = "myGate";
gparams.regionId = regionId1;

gateHandle = GateMP_create(&gparams);
printf ("GateMP created \n");

gateKey = GateMP_enter (gateHandle);
printf ("GateMP entered \n");

  • Can you share the log of the segmentation fault?

    Did it show you the address which generated the fault?

  • Below is the console output.  I have a core dump file but I haven't figured out how to view it or attach it here.  I can decompress it but haven't found the magic tool to view the contents.

    ./app_host DSP1

    --> main:

    [   51.435527] omap-iommu 41501000.mmu: 41501000.mmu: version 3.0

    [   51.441526] omap-iommu 41502000.mmu: 41502000.mmu: version 3.0

    --> Main_main:

    --> App_create:

         - remoteProcId, msgqName: 4, DSP1:MsgQ:01

    MessageQ_open status = 0

    App_create: Host is ready

    <-- App_create:

    --> App_exec-4:

    CMEM_init success

    CMEM_getPool success

    CMEM_allocPool success: Allocated buffer 0xaa5b9000

    SharedRegion_setup success

    App_taskFxn: SR_1, base 0xaa5b9000, len=1000000

    HeapMem_setup success

    HeapMem_create success

    App_taskFxn: SR_1 heap, totalSize=16777216,totalFreeSize=16777216,largestFreeSize=16777216

    App_taskFxn: SR_1 heap, buf=0x0xaa5b9080,size=16777216

    GateMP created

    Segmentation fault (core dumped)

    root@mitysom-am57x:/home/kerr/simple_buffer_example/release#

  • Below is the console output.  I have a core dump file but I haven't figured out how to view it or attach it here.  I can decompress it but haven't found the magic tool to view the contents.

    ./app_host DSP1

    --> main:

    [   51.435527] omap-iommu 41501000.mmu: 41501000.mmu: version 3.0

    [   51.441526] omap-iommu 41502000.mmu: 41502000.mmu: version 3.0

    --> Main_main:

    --> App_create:

         - remoteProcId, msgqName: 4, DSP1:MsgQ:01

    MessageQ_open status = 0

    App_create: Host is ready

    <-- App_create:

    --> App_exec-4:

    CMEM_init success

    CMEM_getPool success

    CMEM_allocPool success: Allocated buffer 0xaa5b9000

    SharedRegion_setup success

    App_taskFxn: SR_1, base 0xaa5b9000, len=1000000

    HeapMem_setup success

    HeapMem_create success

    App_taskFxn: SR_1 heap, totalSize=16777216,totalFreeSize=16777216,largestFreeSize=16777216

    App_taskFxn: SR_1 heap, buf=0x0xaa5b9080,size=16777216

    GateMP created

    Segmentation fault (core dumped)

    root@mitysom-am57x:/home/kerr/simple_buffer_example/release#

    Some more information from the coredump file:

    $ gdb app_host coreDump
    GNU gdb (GDB) 8.2
    Copyright (C) 2018 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <gnu.org/.../gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Type "show copying" and "show warranty" for details.
    This GDB was configured as "arm-linux-gnueabi".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <www.gnu.org/.../>.
    Find the GDB manual and other documentation resources online at:
    <www.gnu.org/.../>.

    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from app_host...done.
    [New LWP 1134]
    [New LWP 1135]
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/libthread_db.so.1".
    Core was generated by `./app_host DSP1'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0 0xb6db13f8 in GateMP_enter () from /usr/lib/libtiipc.so.1
    [Current thread is 1 (Thread 0xb6f9b010 (LWP 1134))]