-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LeakSanitizer support with
-fsanitize=leak
(#4005)
* Add LeakSanitizer support * Windows and FreeBSD do not support LSan yet * Test LLVM >= 10 only with LSan
- Loading branch information
1 parent
a2ce3f3
commit 3b9665b
Showing
7 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Test leak detection with LSan | ||
|
||
// REQUIRES: LSan && atleast_llvm1000 | ||
|
||
// UNSUPPORTED: Windows, FreeBSD | ||
|
||
// RUN: %ldc -g -fsanitize=address %s -of=%t_asan%exe | ||
// RUN: not env %env_asan_opts=detect_leaks=true %t_asan%exe 2>&1 | FileCheck %s | ||
// RUN: %ldc -g -fsanitize=leak %s -of=%t%exe | ||
// RUN: not %t%exe 2>&1 | FileCheck %s | ||
|
||
import core.stdc.stdlib; | ||
|
||
// CHECK: ERROR: LeakSanitizer: detected memory leaks | ||
|
||
void* foo() | ||
{ | ||
// CHECK: Direct leak of 17 byte(s) in 1 object(s) allocated from: | ||
// CHECK: #{{.*}} in {{.*}}lsan_memleak.d:[[@LINE+1]] | ||
return malloc(17); | ||
} | ||
|
||
void main() | ||
{ | ||
foo(); | ||
} |