Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Cross thread heap allocation/deallocation

moi_c_
初学者
810 次查看

Hi,

We are using intel inspector XE 2016 on a game made on Unreal Engine 4 to find memory leaks. However it seems to report a lot of false-positive pairs of "missing allocation" and "memory leak". We suppose that all allocations in one thread but free'd in another thread are causing such false positive reports. Is there a solution/option to tell intel inspector that such reports are linked? We can't find our real memory leak as we are flooded in a lot of those reports.

Thanks.

0 项奖励
1 回复
Peter_W_Intel
员工
810 次查看

It seems there is no additional (necessary) option to inform Inspector to avoid false-positive report between threads, e.g. memory leaks, if you try to allocate memory in one thread and free it in other thread, Inspector reported there is no problem found. Here is a simplest test case.

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>

 

define NUM_THREADS 2

char *g_s20=NULL;

void * funcA(void* args)
{
char *s20;

   s20=(char *)malloc(20); // use s20 in this function
   if (s20) g_s20=s20;

//   printf("g_s20 = %lx\n", g_s20);

}

void * funcB(void* args)
{
   if (g_s20) free(g_s20);
}

int main()
{
        int i;
        pthread_t h[NUM_THREADS];

        pthread_create(&h[0], 0, funcA, NULL);
        sleep(3); // ensure that funcA runs first.
        pthread_create(&h[1], 0, funcB, NULL);

        for (i = 0; i < NUM_THREADS; ++i)
            pthread_join (h, 0);

        return 0;
}

$icc -g threads_2.cpp -o threads_2 -lpthread

$inspxe-cl -c mi3 ./threads_2
  
0 new problem(s) found 

$ inspxe-cl -version
Intel(R) Inspector XE 2016 (build 423441) Command Line tool
Copyright (C) 2009-2015 Intel Corporation. All rights reserved.

 

 

 

 

 

0 项奖励
回复