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

Redefining MALLOC_ASSERT()

Ritwik_D_1
Beginner
322 Views

There are scenarios in which the MALLOC_ASSERT is hit in the scalable_allocator code. Now we have a custom mechanism for handling assertions in our code. Is there any way we can make MALLOC_ASSERT call our assertion mechanism? Does a simple #define MALLOC_ASSERT ... work in this case?

 

0 Kudos
3 Replies
Alexei_K_Intel
Employee
322 Views

Hi,

I think if you change the define of MALLOC_ASSERT in src/tbbmalloc/Customize.h and recompile tbbmalloc it will be enough. If you face some issues feel free to ask.

Just for curiosity, what scenarios cause MALLOC_ASSERT to be raised? Are the wrong arguments passed to tbbmalloc API?

Regards, Alex

0 Kudos
Ritwik_D_1
Beginner
322 Views

So there is no other way than recompiling the sources. I expected this but unfortunately it is not the solution I was looking for :)
​Anyways the asserts were caused because of a bug in my code. Thanks!

 

0 Kudos
JWong19
Beginner
322 Views

Assert code is usually associated with conditional jump (Jxx) instruction or CALL instruction. You may modify the operand (relative offset to target address of next instruction or memory pointer of target address) of the instruction for execution of your custom handler.

Alternately, you may set instruction breakpoint via debug register (up to 4 breakpoints only). Then modify the RIP/EIP register or the return address on the call stack (to skip the original assert handler) upon return from the handler of instruction breakpoint.

0 Kudos
Reply