I am currently (don’t ask why :P) implementing my own versions of malloc() and free(), and have intentionally placed an assert(0) at the first line of free() for current debugging purposes.
A driver program is testing a random sequence of these malloc() and free() to test the correctness of my implementations.
When I run the driver, however, the shell prints out that “Assertion ‘0’ failed”, keeps running for a little bit longer, and then prints “Aborted”. Actually, it looks like it is able to even call malloc() several times between reporting the failure of the assertion and then finally reporting that the program has aborted. I am sure of this because of certain printf statements I have placed in the code to print out certain variables for debugging purposes.
I am not asking for any help at all about implementing malloc() and free(). Would just like to know what is means when it seems that the program continues to run for a short time (even possibly calling other user-defined functions) even after an assertion has been reported to fail.
If you’re seeing ‘assertion failed’, followed by debugging prints, followed by an exit, there are two obvious possibilities.
One is that the assertion message and the debugging prints are going into two different buffered output streams (e.g. stderr and stdout) that are not getting flushed in the same order they are filled.
Another is that multiple threads of execution are hitting malloc().