This is an archive of the discontinued LLVM Phabricator instance.

[lsan] Try to fix test failure due to compiler optimization
ClosedPublic

Authored by Lekensteyn on May 9 2018, 10:39 AM.

Details

Summary

The SanitizerCommon-lsan-x86_64-Linux test failed due to the address of
the very first allocation ending up in the stack through "delete[]".
Workaround this by performing another allocation. The issue was only
present with optimization enabled, the test would pass with -O0.

Diff Detail

Repository
rL LLVM

Event Timeline

Lekensteyn created this revision.May 9 2018, 10:39 AM
Herald added subscribers: Restricted Project, llvm-commits, kubamracek. · View Herald TranscriptMay 9 2018, 10:39 AM
Lekensteyn added inline comments.May 9 2018, 10:52 AM
test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
3 ↗(On Diff #145955)

Renato, this line was added in r249398, "[LSAN] Mark death callback as unstable while we investigate the cause in AArch64". If the issue was also caused by pointers on the stack, perhaps this line can be removed?

To investigate what is leaking, try env var LSAN_OPTIONS=log_pointers=1

vitalybuka added inline comments.May 10 2018, 10:51 AM
test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
28 ↗(On Diff #145955)

This stack cleanup looks unreliable.
Maybe just leak twice?

__attribute__((noinline))
void Leak() {
  sink = new char[100];
  sink = new char[100];
}
vitalybuka requested changes to this revision.May 10 2018, 11:14 AM
This revision now requires changes to proceed.May 10 2018, 11:14 AM
Lekensteyn edited the summary of this revision. (Show Details)

Done, it still passes my tests.

vitalybuka accepted this revision.May 10 2018, 11:26 AM
This revision is now accepted and ready to land.May 10 2018, 11:26 AM
This revision was automatically updated to reflect the committed changes.