summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Barinov <v.barinov@samsung.com>2017-09-14 12:42:17 +0300
committerDongkyun Son <dongkyun.s@samsung.com>2017-10-20 08:49:38 +0900
commit60af37c3341505774d6aec59def8c2fa284e10d7 (patch)
tree8f4e2a8903ab72ecf3dbc3ab2e1da2dd62464165
parent5827371affb63bc4b527847371990b20065df667 (diff)
downloadlinaro-gcc-60af37c3341505774d6aec59def8c2fa284e10d7.tar.gz
linaro-gcc-60af37c3341505774d6aec59def8c2fa284e10d7.tar.bz2
linaro-gcc-60af37c3341505774d6aec59def8c2fa284e10d7.zip
[TTC-9] Make LSan compliant with recovery mode when running on top of ASan
Don't overwrite exit code in LSan when running on top of ASan in recovery mode to avoid breakage of users code due to found leaks. Change-Id: I172f59734837d3df350c9e586ace2547ae9f3f23 Signed-off-by: Slava Barinov <v.barinov@samsung.com>
-rw-r--r--ChangeLog.Tizen7
-rw-r--r--gcc/testsuite/gcc.dg/asan/leak_recover-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/asan/leak_recover-2.c17
-rw-r--r--libsanitizer/asan/asan_rtl.cc5
-rw-r--r--libsanitizer/lsan/lsan_common.cc5
-rw-r--r--libsanitizer/lsan/lsan_common.h1
6 files changed, 50 insertions, 1 deletions
diff --git a/ChangeLog.Tizen b/ChangeLog.Tizen
index f1ebf58d78d..df9eecae783 100644
--- a/ChangeLog.Tizen
+++ b/ChangeLog.Tizen
@@ -29,6 +29,13 @@
# log at the same time (actually you can't). However, if you update this
# file after the commit hash is fixed, you are free to add the commit hash.
################################################################################
+2017-10-20 Slava Barinov <v.barinov@samsung.com>
+
+ [TTC-9] Enable recovery mode for ASan with leak detector
+
+2017-10-17 Mikhail Kashkarov <m.kashkarov@partner.samsung.com>
+
+ Add armv7hl support.
2017-09-26 Dongkyun Son <dongkyun.s@samsung.com>
diff --git a/gcc/testsuite/gcc.dg/asan/leak_recover-1.c b/gcc/testsuite/gcc.dg/asan/leak_recover-1.c
new file mode 100644
index 00000000000..a17a72be3b2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/leak_recover-1.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=0" } */
+
+#include <stdlib.h>
+
+int f () {
+ volatile int* a = malloc(20);
+ a[0] = 1;
+ return a[0];
+}
+
+int main() {
+ f();
+}
+
+/* { dg-output {Direct leak of 20 byte} } */
diff --git a/gcc/testsuite/gcc.dg/asan/leak_recover-2.c b/gcc/testsuite/gcc.dg/asan/leak_recover-2.c
new file mode 100644
index 00000000000..1f57fb4c1c1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/leak_recover-2.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=1" } */
+/* { dg-shouldfail "asan" } */
+
+#include <stdlib.h>
+
+int f () {
+ volatile int* a = malloc(20);
+ a[0] = 1;
+ return a[0];
+}
+
+int main() {
+ f();
+}
+
+/* { dg-output {Direct leak of 20 byte} } */
diff --git a/libsanitizer/asan/asan_rtl.cc b/libsanitizer/asan/asan_rtl.cc
index ba8cbb31994..8b28e6aa247 100644
--- a/libsanitizer/asan/asan_rtl.cc
+++ b/libsanitizer/asan/asan_rtl.cc
@@ -595,7 +595,10 @@ static void AsanInitInternal() {
if (CAN_SANITIZE_LEAKS) {
__lsan::InitCommonLsan();
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) {
- Atexit(__lsan::DoLeakCheck);
+ if (flags()->halt_on_error)
+ Atexit(__lsan::DoLeakCheck);
+ else
+ Atexit(__lsan::DoRecoverableLeakCheckVoid);
}
}
diff --git a/libsanitizer/lsan/lsan_common.cc b/libsanitizer/lsan/lsan_common.cc
index 670eb60384d..3808f2bf8e0 100644
--- a/libsanitizer/lsan/lsan_common.cc
+++ b/libsanitizer/lsan/lsan_common.cc
@@ -509,6 +509,10 @@ static int DoRecoverableLeakCheck() {
return have_leaks ? 1 : 0;
}
+void DoRecoverableLeakCheckVoid() {
+ DoRecoverableLeakCheck();
+}
+
static Suppression *GetSuppressionForAddr(uptr addr) {
Suppression *s = nullptr;
@@ -671,6 +675,7 @@ uptr LeakReport::UnsuppressedLeakCount() {
namespace __lsan {
void InitCommonLsan() { }
void DoLeakCheck() { }
+void DoRecoverableLeakCheckVoid() { }
void DisableInThisThread() { }
void EnableInThisThread() { }
}
diff --git a/libsanitizer/lsan/lsan_common.h b/libsanitizer/lsan/lsan_common.h
index 53cd1c6a55d..85b76db7d71 100644
--- a/libsanitizer/lsan/lsan_common.h
+++ b/libsanitizer/lsan/lsan_common.h
@@ -117,6 +117,7 @@ enum IgnoreObjectResult {
// Functions called from the parent tool.
void InitCommonLsan();
void DoLeakCheck();
+void DoRecoverableLeakCheckVoid();
bool DisabledInThisThread();
// Used to implement __lsan::ScopedDisabler.