Using LSan's provided interface in lsan_interface.h, we attempted to use the __lsan_enable() call at the beginning of the program to assure that it was turned on if it was turned off by some infrastructure previously. This, however, resulted in this error message:
==2100623==Unmatched call to __lsan_enable().
This error message, however, is very vague. There isn't any official documentation for this API, so this combined with the non-descriptive error message led to a lot of headache.
For one, it isn't obvious this error messages comes out of LSan from a glance. Second, there isn't any description of how the issue could be fixed. If, for instance, it instead said:
==2100623==Unmatched call to __lsan_enable() without corresponding call to __lsan_disable().
or something along those lines, that would be much more descriptive and actually point to a solution. This would also make it clear the error message is coming out of LSan rather than something else.
As a note, the only other indication that there needs to be a matching pair of calls is this comment in lsan_interface.h:
// Allocations made between calls to __lsan_disable() and __lsan_enable() will
// be treated as non-leaks. Disable/enable pairs may be nested.
void SANITIZER_CDECL __lsan_disable(void);
void SANITIZER_CDECL __lsan_enable(void);
Even this, though, isn't concrete and is easy to miss. It would be helpful to add a comment in the lsan_interface.h file that describes this requirement in lieu of documentation.
Using LSan's provided interface in
lsan_interface.h
, we attempted to use the__lsan_enable()
call at the beginning of the program to assure that it was turned on if it was turned off by some infrastructure previously. This, however, resulted in this error message:==2100623==Unmatched call to __lsan_enable().
This error message, however, is very vague. There isn't any official documentation for this API, so this combined with the non-descriptive error message led to a lot of headache.For one, it isn't obvious this error messages comes out of LSan from a glance. Second, there isn't any description of how the issue could be fixed. If, for instance, it instead said:
==2100623==Unmatched call to __lsan_enable() without corresponding call to __lsan_disable().
or something along those lines, that would be much more descriptive and actually point to a solution. This would also make it clear the error message is coming out of LSan rather than something else.As a note, the only other indication that there needs to be a matching pair of calls is this comment in
lsan_interface.h
:Even this, though, isn't concrete and is easy to miss. It would be helpful to add a comment in the
lsan_interface.h
file that describes this requirement in lieu of documentation.