Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ritwik_D_1
Beginner
41 Views

Redefining MALLOC_ASSERT()

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
41 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

Ritwik_D_1
Beginner
41 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!

 

JWong19
Beginner
41 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.

Reply