Fighting "*** glibc detected ***"

    Hello, habrasociety!

    I want to talk about a small problem that I encountered today.
    It happens that a program crashes, issuing a line starting with "*** glibc detected ***" and accompanied by a lot of overhead information. The fact is that glibc has its own memory manager, which, in the event of an attempt to free unallocated memory, starts to panic and think that the internal structures of the memory manager have collapsed.

    Of course, the correct way to solve the problem is to defer the program, find the error and / or report it to the developer. But sometimes the result is urgently needed, and there is no time to do it. In this case, you can try switching the glibc memory manager to another mode, less productive, but more resistant to such programmer errors. You can do it this way:

    MALLOC_CHECK_ = 0 / path / to / program


    A value of “0” forces one to completely ignore such errors, “1” - displays messages about them in stderr, “2” - terminates the program when an error is detected.
    Runs on Linux libc newer than 5.4.23 and GNU libc 2.x.

    Also popular now: