Skip to content

lsan_internals.h

mhahnFr edited this page Jun 12, 2024 · 25 revisions

Using the variables defined in this header, the behaviour of the sanitizer can be adjusted.

extern bool __lsan_humanPrint

If this value is set to true, the byte amounts are printed in a human friendly way.
Defaults to true.

extern bool __lsan_printCout

If this value is set to true, normal messages are printed to the standard output stream. Otherwise, the standard error stream is also used for normal messages.
Defaults to false.

Note

Added in version 1.1.

extern bool __lsan_printFormatted

If this value is set to true, ANSI escape codes are used to format the output of this sanitizer. Otherwise, the output is not formatted using escape codes.
Defaults to true.

Note

Added in version 1.1.

extern bool __lsan_printLicense

Warning

Deprecated since version 1.8: This option is no longer supported.
Will be removed in version 2.

If this value is set to true, the license information is printed upon normal termination of the program.

Note

Added in version 1.1.

extern bool __lsan_printWebsite

Warning

Deprecated since version 1.8: This option is no longer supported.
Will be removed in version 2.

If this value is set to true, the link to the home page of the LeakSanitizer is printed.

Note

Added in version 1.4.

extern bool __lsan_invalidCrash

If this value is set to true, the program is terminated when doing something invalid regarding the memory management.
Defaults to true.

extern bool __lsan_invalidFree

If this value is set to true, the freed pointers are checked for whether they have previously been allocated using the sanitizer. If a pointer which is unknown to the sanitizer is freed, a warning or a termination is issued, according to the value __lsan_invalidCrash. Freeing a null pointer is not checked by this flag, but by __lsan_freeNull.
Defaults to false.

extern bool __lsan_freeNull

If this value is set to true, a warning is issued when a null pointer is freed. It does not cause a termination of the program, regardless of __lsan_invalidCrash.
Defaults to false.

extern bool __lsan_zeroAllocation

If this value is set to true, a warning is issued when zero bytes are allocated. It does not cause a termination of the program, regardless of __lsan_invalidCrash.
Defaults to false.

Note

Added in version 1.8.

extern bool __lsan_trackMemory

Warning

Deprecated since version 1.5: replaced by __lsan_statsActive.
Will be removed in version 2.

If this value is set to true, the memory fragmentation can be analyzed. It should be set at the very beginning of the program in order to get realistic results.
Defaults to false.

Note

Added in version 1.2.

extern bool __lsan_statsActive

If this value is set to true, the memory allocation statistics can be analyzed.

It should be set at the very beginning of the program in order to get realistic results.
Defaults to false.

Note

Added in version 1.5.

extern bool __lsan_printExitPoint

If this value is set to true, a callstack of the exit point is printed upon regular termination.

Defaults to false.

Note

Added in version 1.7.

extern bool __lsan_printBinaries

If this value is set to true the name of the binary file a given callstack frame comes from is printed as well.

Defaults to true.

Note

Added in version v1.8.

extern bool __lsan_printFunctions

If this value is set to false the function names are omitted if source file and line number information is available.

Defaults to true.

Note

Added in version v1.8.

extern bool __lsan_relativePaths

If this value is set to true the printed file paths are allowed to be relative paths.

Defaults to true.

Note

Added in version v1.8.

extern size_t __lsan_leakCount

This value defines the count of leaks that are printed at the exit of the program. If more leaks are detected, the first leaks are printed and a message about the truncation is also printed.
Defaults to 100.

Note

Added in version 1.3.

extern size_t __lsan_callstackSize

This value defines the number of functions that are printed in a callstack. If there are more functions in such a callstack a message about the truncation is printed.
Defaults to 20.

Note

Added in version 1.3.

extern size_t __lsan_firstPartyThreshold

This value defines the number of first party frames upon which callstacks are considered to be first party.

Up to this amount of frames callstacks are considered to be user initiated.
Defaults to 3.

Note

Added in version 1.7.

extern const char * __lsan_firstPartyRegex

This string defines the regular expression which matching binary file names are considered to be first party.

This regular expression is applied to the absolute path of the binary file names.

Note

Added in version 1.8.