[compiler-rt] 5732cdc - [msan] Strip __interceptor_ from reports
Marco Elver via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 03:01:49 PDT 2023
Author: Marco Elver
Date: 2023-05-25T12:01:11+02:00
New Revision: 5732cdc1be519eba3fe176cae2c8fea1e0ce7ea7
URL: https://github.com/llvm/llvm-project/commit/5732cdc1be519eba3fe176cae2c8fea1e0ce7ea7
DIFF: https://github.com/llvm/llvm-project/commit/5732cdc1be519eba3fe176cae2c8fea1e0ce7ea7.diff
LOG: [msan] Strip __interceptor_ from reports
Showing __interceptor_ as part of the function name in reports does not
make sense and is distracting.
Strip the interceptor function name before printing.
Reviewed By: dvyukov, vitalybuka
Differential Revision: https://reviews.llvm.org/D151343
Added:
Modified:
compiler-rt/lib/msan/msan_report.cpp
compiler-rt/lib/msan/msan_report.h
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
compiler-rt/test/msan/Linux/b64.cpp
compiler-rt/test/msan/Linux/sendmsg.cpp
compiler-rt/test/msan/fgets_fputs.cpp
compiler-rt/test/msan/fread_fwrite.cpp
compiler-rt/test/msan/getaddrinfo-positive.cpp
compiler-rt/test/msan/scoped-interceptors.cpp
compiler-rt/test/msan/strndup.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/msan/msan_report.cpp b/compiler-rt/lib/msan/msan_report.cpp
index d1ef36d9a322a..90164e50ca3ac 100644
--- a/compiler-rt/lib/msan/msan_report.cpp
+++ b/compiler-rt/lib/msan/msan_report.cpp
@@ -11,16 +11,18 @@
// Error reporting.
//===----------------------------------------------------------------------===//
+#include "msan_report.h"
+
#include "msan.h"
#include "msan_chained_origin_depot.h"
#include "msan_origin.h"
-#include "msan_report.h"
#include "sanitizer_common/sanitizer_allocator_internal.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_mutex.h"
#include "sanitizer_common/sanitizer_report_decorator.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
+#include "sanitizer_common/sanitizer_stacktrace_printer.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
using namespace __sanitizer;
@@ -265,12 +267,13 @@ void DescribeMemoryRange(const void *x, uptr size) {
}
}
-void ReportUMRInsideAddressRange(const char *what, const void *start, uptr size,
- uptr offset) {
+void ReportUMRInsideAddressRange(const char *function, const void *start,
+ uptr size, uptr offset) {
+ function = StripFunctionName(function);
Decorator d;
Printf("%s", d.Warning());
Printf("%sUninitialized bytes in %s%s%s at offset %zu inside [%p, %zu)%s\n",
- d.Warning(), d.Name(), what, d.Warning(), offset, start, size,
+ d.Warning(), d.Name(), function, d.Warning(), offset, start, size,
d.Default());
if (__sanitizer::Verbosity())
DescribeMemoryRange(start, size);
diff --git a/compiler-rt/lib/msan/msan_report.h b/compiler-rt/lib/msan/msan_report.h
index 0965b8cb68137..2ad81c37cf60a 100644
--- a/compiler-rt/lib/msan/msan_report.h
+++ b/compiler-rt/lib/msan/msan_report.h
@@ -25,8 +25,8 @@ void ReportExpectedUMRNotFound(StackTrace *stack);
void ReportStats();
void ReportAtExitStatistics();
void DescribeMemoryRange(const void *x, uptr size);
-void ReportUMRInsideAddressRange(const char *what, const void *start, uptr size,
- uptr offset);
+void ReportUMRInsideAddressRange(const char *function, const void *start,
+ uptr size, uptr offset);
} // namespace __msan
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
index ce9f24a9b61c7..337e2d64b1a99 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
@@ -16,11 +16,7 @@
namespace __sanitizer {
-// sanitizer_symbolizer_markup.cpp implements these
diff erently.
-#if !SANITIZER_SYMBOLIZER_MARKUP
-
-// Strip interceptor prefixes from function name.
-static const char *StripFunctionName(const char *function) {
+const char *StripFunctionName(const char *function) {
if (!function)
return nullptr;
auto try_strip = [function](const char *prefix) -> const char * {
@@ -39,6 +35,9 @@ static const char *StripFunctionName(const char *function) {
return function;
}
+// sanitizer_symbolizer_markup.cpp implements these
diff erently.
+#if !SANITIZER_SYMBOLIZER_MARKUP
+
static const char *DemangleFunctionName(const char *function) {
if (!function) return nullptr;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
index 457e3215da4b0..bf2755a2e8f45 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
@@ -17,6 +17,9 @@
namespace __sanitizer {
+// Strip interceptor prefixes from function name.
+const char *StripFunctionName(const char *function);
+
// Render the contents of "info" structure, which represents the contents of
// stack frame "frame_no" and appends it to the "buffer". "format" is a
// string with placeholders, which is copied to the output with
diff --git a/compiler-rt/test/msan/Linux/b64.cpp b/compiler-rt/test/msan/Linux/b64.cpp
index 90a31db233c78..39f3d8cf0da0f 100644
--- a/compiler-rt/test/msan/Linux/b64.cpp
+++ b/compiler-rt/test/msan/Linux/b64.cpp
@@ -60,7 +60,7 @@ int main(int iArgc, char *szArgv[]) {
char dst[dst_len];
int res = b64_ntop(reinterpret_cast<const unsigned char *>(src), src_len,
dst, dst_len);
- // NTOP_READ: Uninitialized bytes in __interceptor___b64_ntop
+ // NTOP_READ: Uninitialized bytes in __b64_ntop
return 0;
}
@@ -73,7 +73,7 @@ int main(int iArgc, char *szArgv[]) {
__msan_poison(src, src_len);
unsigned char target[src_len];
int res = b64_pton(src, target, src_len);
- // PTON_READ: Uninitialized bytes in __interceptor___b64_pton
+ // PTON_READ: Uninitialized bytes in __b64_pton
return 0;
}
diff --git a/compiler-rt/test/msan/Linux/sendmsg.cpp b/compiler-rt/test/msan/Linux/sendmsg.cpp
index 91c3f64d7f215..6089f595a6687 100644
--- a/compiler-rt/test/msan/Linux/sendmsg.cpp
+++ b/compiler-rt/test/msan/Linux/sendmsg.cpp
@@ -75,7 +75,7 @@ int main() {
#if defined(SEND)
sent = send(sockfd[0], buf, kBufSize, 0);
- // SEND: Uninitialized bytes in __interceptor_send at offset 7 inside [{{.*}}, 10)
+ // SEND: Uninitialized bytes in send at offset 7 inside [{{.*}}, 10)
assert(sent > 0);
ret = recv(sockfd[1], rbuf, kRecvBufSize, 0);
@@ -83,7 +83,7 @@ int main() {
assert(__msan_test_shadow(rbuf, kRecvBufSize) == sent);
#elif defined(SENDTO)
sent = sendto(sockfd[0], buf, kBufSize, 0, nullptr, 0);
- // SENDTO: Uninitialized bytes in __interceptor_sendto at offset 7 inside [{{.*}}, 10)
+ // SENDTO: Uninitialized bytes in sendto at offset 7 inside [{{.*}}, 10)
assert(sent > 0);
struct sockaddr_storage ss;
diff --git a/compiler-rt/test/msan/fgets_fputs.cpp b/compiler-rt/test/msan/fgets_fputs.cpp
index 1e96943980d6b..e050234ed2393 100644
--- a/compiler-rt/test/msan/fgets_fputs.cpp
+++ b/compiler-rt/test/msan/fgets_fputs.cpp
@@ -43,5 +43,5 @@ int main(int argc, char *argv[]) {
return 0;
}
-// CHECK-FPUTS: Uninitialized bytes in __interceptor_fputs at offset 0 inside
-// CHECK-PUTS: Uninitialized bytes in __interceptor_puts at offset 0 inside
+// CHECK-FPUTS: Uninitialized bytes in fputs at offset 0 inside
+// CHECK-PUTS: Uninitialized bytes in puts at offset 0 inside
diff --git a/compiler-rt/test/msan/fread_fwrite.cpp b/compiler-rt/test/msan/fread_fwrite.cpp
index d6cace56c8d89..9980d114086bc 100644
--- a/compiler-rt/test/msan/fread_fwrite.cpp
+++ b/compiler-rt/test/msan/fread_fwrite.cpp
@@ -31,4 +31,4 @@ int main(int argc, char *argv[]) {
return 0;
}
-// CHECK: Uninitialized bytes in __interceptor_fwrite at offset 0 inside
+// CHECK: Uninitialized bytes in fwrite at offset 0 inside
diff --git a/compiler-rt/test/msan/getaddrinfo-positive.cpp b/compiler-rt/test/msan/getaddrinfo-positive.cpp
index 891fcf881161c..a793374133967 100644
--- a/compiler-rt/test/msan/getaddrinfo-positive.cpp
+++ b/compiler-rt/test/msan/getaddrinfo-positive.cpp
@@ -16,7 +16,7 @@ int main(void) {
int res = getaddrinfo("localhost", NULL, NULL, &ai);
if (ai) z = 1; // OK
res = getaddrinfo("localhost", NULL, &hint, &ai);
- // CHECK: Uninitialized bytes in __interceptor_getaddrinfo at offset 0 inside [0x{{.*}}, 48)
+ // CHECK: Uninitialized bytes in getaddrinfo at offset 0 inside [0x{{.*}}, 48)
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
// CHECK: #0 {{.*}} in main {{.*}}getaddrinfo-positive.cpp:[[@LINE-3]]
return 0;
diff --git a/compiler-rt/test/msan/scoped-interceptors.cpp b/compiler-rt/test/msan/scoped-interceptors.cpp
index 5eff33d6bf691..5389797e21906 100644
--- a/compiler-rt/test/msan/scoped-interceptors.cpp
+++ b/compiler-rt/test/msan/scoped-interceptors.cpp
@@ -26,13 +26,13 @@ int main(int argc, char *argv[]) {
char *copy = strndup(uninit, sizeof(uninit)); // BOOM
free(copy);
break;
- // CASE-0: Uninitialized bytes in __interceptor_strndup
+ // CASE-0: Uninitialized bytes in strndup
}
case '1': {
puts(uninit); // BOOM
puts(uninit); // Ensure previous call did not enable interceptor checks.
break;
- // CASE-1: Uninitialized bytes in __interceptor_puts
+ // CASE-1: Uninitialized bytes in puts
}
case '2': {
int cmp = memcmp(uninit, uninit, sizeof(uninit)); // BOOM
@@ -42,7 +42,7 @@ int main(int argc, char *argv[]) {
case '3': {
size_t len = strlen(uninit); // BOOM
break;
- // CASE-3: Uninitialized bytes in __interceptor_strlen
+ // CASE-3: Uninitialized bytes in strlen
}
default: assert(0);
}
diff --git a/compiler-rt/test/msan/strndup.cpp b/compiler-rt/test/msan/strndup.cpp
index 5e1aa33668c2f..78a6617cf3164 100644
--- a/compiler-rt/test/msan/strndup.cpp
+++ b/compiler-rt/test/msan/strndup.cpp
@@ -18,7 +18,7 @@ int main(int argc, char **argv) {
assert(__msan_test_shadow(copy, 4) == 2); // Poisoning is preserved.
free(copy);
return 0;
- // ON: Uninitialized bytes in __interceptor_{{(__)?}}strndup at offset 2 inside [{{.*}}, 4)
+ // ON: Uninitialized bytes in {{(__)?}}strndup at offset 2 inside [{{.*}}, 4)
// ON: MemorySanitizer: use-of-uninitialized-value
// ON: #0 {{.*}}main {{.*}}strndup.cpp:[[@LINE-6]]
// ON-LABEL: SUMMARY
More information about the llvm-commits
mailing list