Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2479 Discussions

task_scheduler_init raises "Freeing mismatched memory" in Rational Purify

Steph
Beginner
351 Views

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-Kukanov
Employee
351 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.
0 Kudos
Reply