Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Steph
Beginner
49 Views

task_scheduler_init raises "Freeing mismatched memory" in Rational Purify

Hello,

I'm performing an analysis of my application with Rational Purify. As this application uses TBB, I have, somewhere in my code:

[cpp]void SomeClass::someMethod([...])
{
// Init TBB
tbb::task_scheduler_init tbbInit;
[...]
}[/cpp]

Purify raises the following error:

FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
Address 0x0bc14f28 points into a malloc'd block in heap 0x0bc10000
Location of free attempt
!>(void *)
tbb::task_scheduler_init::~task_scheduler_init(void) [task_scheduler_init.h:81]
SomeClass::someMethod([...])
Allocation location
malloc
tbb::task_scheduler_init::task_scheduler_init(int) [task_scheduler_init.h:75]
SomeClass::someMethod([...])

Quoting the documentation :

An FMM message indicates that your program is deallocating memory using a function from a different family than the one used to allocate the memory.

An FMM error can occur when you use new[] to allocate memory and delete to free the memory. You should use delete[] instead, otherwise the destructor associated with the memory cannot be run. Purify reports an FMM message when your program allocates memory from one family of APIs and then deallocates the memory from a mismatching family. Purify checks these families:

new/delete
new[]/delete[]
malloc/free
calloc/free
realloc/free
XtMalloc/XtFree

Is this Purify getting confused and raising a false positive ? Everything seems to be working fine.

I'm using TBB 2.0_020.

Thanks for your help,

Stphane

0 Kudos
1 Reply
Alexey_K_Intel3
Employee
49 Views

It seems to be a false positive. In the constructor and the destructor of task_scheduler_init, there is no memory allocation. There are some allocations down along the call chain into some functions calledfromthe methods initialize() and terminate() which called by the constructor and destructor; but the methods are out-of-line, and so I would expect to see at least initialize()/terminate() in the stack.
Reply