[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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
// sanitizer_symbolizer_markup.cpp implements these differently.
|
||||
#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 differently.
|
||||
#if !SANITIZER_SYMBOLIZER_MARKUP
|
||||
|
||||
static const char *DemangleFunctionName(const char *function) {
|
||||
if (!function) return nullptr;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user