// 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;
}
}
-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);
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
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 * {
return function;
}
+// sanitizer_symbolizer_markup.cpp implements these differently.
+#if !SANITIZER_SYMBOLIZER_MARKUP
+
static const char *DemangleFunctionName(const char *function) {
if (!function) return nullptr;
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
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;
}
__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;
}
#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);
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;
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
return 0;
}
-// CHECK: Uninitialized bytes in __interceptor_fwrite at offset 0 inside
+// CHECK: Uninitialized bytes in fwrite at offset 0 inside
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;
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
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);
}
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