Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
MALLOC_CHECK_ is an environment variable used by the GNU C Library (glibc) to automatically enable an extensive suite of debugging functions, which check for proper memory allocation, usage, and deallocation. It includes options to enable aborting a program as soon as corruption is detection and for printing out error messages.
KDE enables MALLOC_CHECK_ by default in development versions of KDE by setting the environment variable in the startkde script, from among the following possibilities:
- MALLOC_CHECK_ is not set: When MALLOC_CHECK_ has not been set, then memory is used as normal with no special behavior. If bugs exist you may still receive "Segmentation faults" after the corruption has become severe enough to trip an operating system error routine.
- MALLOC_CHECK_ = 0: Memory check code is enabled. However all errors are silently ignored without so much as a warning.
- MALLOC_CHECK_ = 1: On error, a diagnostic message is printed on stderr.
- MALLOC_CHECK_ = 2: On error, abort(3) is called without a diagnostic message. This is the value set by startkde for glibc versions less than 2.9.
- MALLOC_CHECK_ = 3: abort(3) is called, and a diagnostic message is printed. This is the value set by startkde for glibc versions greater than or equal to 2.9. Earlier glibc versions were unnecessarily "noisy" with this variable set to 3.
More information is available in the man page for malloc(3), and in the "Heap Consistency Checking" GNU info page for libc. (Konqueror users can open info:/libc/Heap Consistency Checking)
This checking may reveal bugs in programs, with a " *** glibc: corruption detected" message (or similar). See an example of a crash because of this variable.
Note that these crashes are not bugs with MALLOC_CHECK_, but a bug in the program which has gone unnoticed up to this point.
If you are a developer experiencing crashes due to this checking and you are unable to diagnose the source of the bug, it may be fruitful to use the Valgrind tool to search for the source of the error.