[compiler-rt] [WIP] Sanitizer ReportReceiver (PR #224706)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 11:59:08 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.cpp compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.h compiler-rt/lib/asan/asan_descriptions.cpp compiler-rt/lib/asan/asan_descriptions.h compiler-rt/lib/asan/asan_errors.cpp compiler-rt/lib/asan/asan_errors.h compiler-rt/lib/asan/asan_report.cpp compiler-rt/lib/tsan/rtl/tsan_report.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index 8372807bb..6f167ec31 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "asan_descriptions.h"
+
#include "asan_mapping.h"
#include "asan_report.h"
#include "asan_stack.h"
@@ -91,7 +92,7 @@ static bool GetShadowKind(uptr addr, ShadowKind *shadow_kind) {
return true;
}
-bool DescribeAddressIfShadow(ScopedSanitizerReport *srep, uptr addr) {
+bool DescribeAddressIfShadow(ScopedSanitizerReport* srep, uptr addr) {
ShadowAddressDescription descr;
if (!GetShadowAddressInformation(addr, &descr)) return false;
descr.Print(srep);
@@ -187,7 +188,7 @@ static StackTrace GetStackTraceFromId(u32 id) {
return res;
}
-bool DescribeAddressIfHeap(ScopedSanitizerReport *srep, uptr addr,
+bool DescribeAddressIfHeap(ScopedSanitizerReport* srep, uptr addr,
uptr access_size) {
HeapAddressDescription descr;
if (!GetHeapAddressInformation(addr, access_size, &descr)) {
@@ -276,7 +277,7 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr,
Printf("%s", str.data());
}
-bool DescribeAddressIfStack(ScopedSanitizerReport *srep, uptr addr,
+bool DescribeAddressIfStack(ScopedSanitizerReport* srep, uptr addr,
uptr access_size) {
StackAddressDescription descr;
if (!GetStackAddressInformation(addr, access_size, &descr)) return false;
@@ -320,8 +321,8 @@ bool GetGlobalAddressInformation(uptr addr, uptr access_size,
return globals_num != 0;
}
-bool DescribeAddressIfGlobal(ScopedSanitizerReport *srep, uptr addr,
- uptr access_size, const char *bug_type) {
+bool DescribeAddressIfGlobal(ScopedSanitizerReport* srep, uptr addr,
+ uptr access_size, const char* bug_type) {
GlobalAddressDescription descr;
if (!GetGlobalAddressInformation(addr, access_size, &descr)) return false;
@@ -329,16 +330,18 @@ bool DescribeAddressIfGlobal(ScopedSanitizerReport *srep, uptr addr,
return true;
}
-void ShadowAddressDescription::Print(ScopedSanitizerReport *srep) const {
+void ShadowAddressDescription::Print(ScopedSanitizerReport* srep) const {
// Shadow addresses have no meaningful access size.
- if (srep) srep->AddAddress(addr, 0, kReportAddressFault, "fault", 5);
+ if (srep)
+ srep->AddAddress(addr, 0, kReportAddressFault, "fault", 5);
Printf("Address %p is located in the %s area.\n", (void *)addr,
ShadowNames[kind]);
}
-void GlobalAddressDescription::Print(ScopedSanitizerReport *srep,
- const char *bug_type) const {
- if (srep) srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
+void GlobalAddressDescription::Print(ScopedSanitizerReport* srep,
+ const char* bug_type) const {
+ if (srep)
+ srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
for (int i = 0; i < size; i++) {
DescribeAddressRelativeToGlobal(addr, access_size, globals[i]);
if (bug_type &&
@@ -370,8 +373,9 @@ bool GlobalAddressDescription::PointsInsideTheSameVariable(
return false;
}
-void StackAddressDescription::Print(ScopedSanitizerReport *srep) const {
- if (srep) srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
+void StackAddressDescription::Print(ScopedSanitizerReport* srep) const {
+ if (srep)
+ srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
Decorator d;
Printf("%s", d.Location());
Printf("Address %p is located in stack of thread %s", (void *)addr,
@@ -426,16 +430,18 @@ void StackAddressDescription::Print(ScopedSanitizerReport *srep) const {
DescribeThread(GetThreadContextByTidLocked(tid));
}
-void HeapAddressDescription::Print(ScopedSanitizerReport *srep) const {
- if (srep) srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
+void HeapAddressDescription::Print(ScopedSanitizerReport* srep) const {
+ if (srep)
+ srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
PrintHeapChunkAccess(addr, chunk_access);
asanThreadRegistry().CheckLocked();
AsanThreadContext *alloc_thread = GetThreadContextByTidLocked(alloc_tid);
StackTrace alloc_stack = GetStackTraceFromId(alloc_stack_id);
- if (srep) srep->AddAddress(chunk_access.chunk_begin, chunk_access.chunk_size,
- kReportAddressAllocation, "allocation", 10);
+ if (srep)
+ srep->AddAddress(chunk_access.chunk_begin, chunk_access.chunk_size,
+ kReportAddressAllocation, "allocation", 10);
Decorator d;
AsanThreadContext *free_thread = nullptr;
@@ -445,7 +451,9 @@ void HeapAddressDescription::Print(ScopedSanitizerReport *srep) const {
AsanThreadIdAndName(free_thread).c_str(), d.Default());
StackTrace free_stack = GetStackTraceFromId(free_stack_id);
free_stack.Print();
- if (srep) srep->AddStack(free_stack.trace, free_stack.size, kReportStackDeallocation, "Freed", 5);
+ if (srep)
+ srep->AddStack(free_stack.trace, free_stack.size,
+ kReportStackDeallocation, "Freed", 5);
Printf("%spreviously allocated by thread %s here:%s\n", d.Allocation(),
AsanThreadIdAndName(alloc_thread).c_str(), d.Default());
} else {
@@ -453,7 +461,9 @@ void HeapAddressDescription::Print(ScopedSanitizerReport *srep) const {
AsanThreadIdAndName(alloc_thread).c_str(), d.Default());
}
alloc_stack.Print();
- if (srep) srep->AddStack(alloc_stack.trace, alloc_stack.size, kReportStackAllocation, "Allocated", 9);
+ if (srep)
+ srep->AddStack(alloc_stack.trace, alloc_stack.size, kReportStackAllocation,
+ "Allocated", 9);
DescribeThread(GetCurrentThread());
if (free_thread) DescribeThread(free_thread);
DescribeThread(alloc_thread);
@@ -507,15 +517,15 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
data.wild.access_size = access_size;
}
-void WildAddressDescription::Print(ScopedSanitizerReport *srep) const {
- if (srep) srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
+void WildAddressDescription::Print(ScopedSanitizerReport* srep) const {
+ if (srep)
+ srep->AddAddress(addr, access_size, kReportAddressFault, "fault", 5);
Printf("Address %p is a wild pointer inside of access range of size %p.\n",
(void *)addr, (void *)access_size);
}
-void PrintAddressDescription(ScopedSanitizerReport *srep, uptr addr,
- uptr access_size,
- const char *bug_type) {
+void PrintAddressDescription(ScopedSanitizerReport* srep, uptr addr,
+ uptr access_size, const char* bug_type) {
ShadowAddressDescription shadow_descr;
if (GetShadowAddressInformation(addr, &shadow_descr)) {
shadow_descr.Print(srep);
diff --git a/compiler-rt/lib/asan/asan_descriptions.h b/compiler-rt/lib/asan/asan_descriptions.h
index 1617717ea..ea2816163 100644
--- a/compiler-rt/lib/asan/asan_descriptions.h
+++ b/compiler-rt/lib/asan/asan_descriptions.h
@@ -93,11 +93,11 @@ struct ShadowAddressDescription {
ShadowKind kind;
u8 shadow_byte;
- void Print(ScopedSanitizerReport *srep) const;
+ void Print(ScopedSanitizerReport* srep) const;
};
bool GetShadowAddressInformation(uptr addr, ShadowAddressDescription *descr);
-bool DescribeAddressIfShadow(ScopedSanitizerReport *srep, uptr addr);
+bool DescribeAddressIfShadow(ScopedSanitizerReport* srep, uptr addr);
enum AccessType {
kAccessTypeLeft,
@@ -125,12 +125,13 @@ struct HeapAddressDescription {
u32 free_stack_id;
ChunkAccess chunk_access;
- void Print(ScopedSanitizerReport *srep) const;
+ void Print(ScopedSanitizerReport* srep) const;
};
bool GetHeapAddressInformation(uptr addr, uptr access_size,
HeapAddressDescription *descr);
-bool DescribeAddressIfHeap(ScopedSanitizerReport *srep, uptr addr, uptr access_size = 1);
+bool DescribeAddressIfHeap(ScopedSanitizerReport* srep, uptr addr,
+ uptr access_size = 1);
struct StackAddressDescription {
uptr addr;
@@ -140,7 +141,7 @@ struct StackAddressDescription {
uptr access_size;
const char *frame_descr;
- void Print(ScopedSanitizerReport *srep) const;
+ void Print(ScopedSanitizerReport* srep) const;
};
bool GetStackAddressInformation(uptr addr, uptr access_size,
@@ -150,7 +151,7 @@ struct WildAddressDescription {
uptr addr;
uptr access_size;
- void Print(ScopedSanitizerReport *srep) const;
+ void Print(ScopedSanitizerReport* srep) const;
};
struct GlobalAddressDescription {
@@ -162,7 +163,7 @@ struct GlobalAddressDescription {
uptr access_size;
u8 size;
- void Print(ScopedSanitizerReport *srep, const char *bug_type = "") const;
+ void Print(ScopedSanitizerReport* srep, const char* bug_type = "") const;
// Returns true when this descriptions points inside the same global variable
// as other. Descriptions can have different address within the variable
@@ -171,7 +172,8 @@ struct GlobalAddressDescription {
bool GetGlobalAddressInformation(uptr addr, uptr access_size,
GlobalAddressDescription *descr);
-bool DescribeAddressIfGlobal(ScopedSanitizerReport *srep, uptr addr, uptr access_size, const char *bug_type);
+bool DescribeAddressIfGlobal(ScopedSanitizerReport* srep, uptr addr,
+ uptr access_size, const char* bug_type);
// General function to describe an address. Will try to describe the address as
// a shadow, global (variable), stack, or heap address.
@@ -181,9 +183,8 @@ bool DescribeAddressIfGlobal(ScopedSanitizerReport *srep, uptr addr, uptr access
// addresses. Defaults to 1.
// Each of the *AddressDescription functions has its own Print() member, which
// may take access_size and bug_type parameters if needed.
-void PrintAddressDescription(ScopedSanitizerReport *srep, uptr addr,
- uptr access_size = 1,
- const char *bug_type = "");
+void PrintAddressDescription(ScopedSanitizerReport* srep, uptr addr,
+ uptr access_size = 1, const char* bug_type = "");
enum AddressKind {
kAddressKindWild,
@@ -231,7 +232,8 @@ class AddressDescription {
}
UNREACHABLE("AddressInformation kind is invalid");
}
- void Print(ScopedSanitizerReport &srep, const char *bug_descr = nullptr) const {
+ void Print(ScopedSanitizerReport& srep,
+ const char* bug_descr = nullptr) const {
switch (data.kind) {
case kAddressKindWild:
data.wild.Print(&srep);
diff --git a/compiler-rt/lib/asan/asan_errors.cpp b/compiler-rt/lib/asan/asan_errors.cpp
index fc44c024f..8992c3433 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -42,15 +42,15 @@ static void OnStackUnwind(const SignalContext &sig,
fast);
}
-void ErrorDeadlySignal::Print(ScopedSanitizerReport &srep) {
+void ErrorDeadlySignal::Print(ScopedSanitizerReport& srep) {
ReportDeadlySignal(signal, tid, &OnStackUnwind, &scariness);
}
-void ErrorDoubleFree::Print(ScopedSanitizerReport &srep) {
+void ErrorDoubleFree::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF("ERROR: AddressSanitizer: attempting %s on %p in thread %s:",
- scariness.GetDescription(), (void *)addr_description.addr,
- AsanThreadIdAndName(tid).c_str());
+ scariness.GetDescription(), (void*)addr_description.addr,
+ AsanThreadIdAndName(tid).c_str());
scariness.Print();
GET_STACK_TRACE_FATAL(second_free_stack->trace[0],
second_free_stack->top_frame_bp);
@@ -60,11 +60,11 @@ void ErrorDoubleFree::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), &stack);
}
-void ErrorNewDeleteTypeMismatch::Print(ScopedSanitizerReport &srep) {
+void ErrorNewDeleteTypeMismatch::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF("ERROR: AddressSanitizer: %s on %p in thread %s:",
- scariness.GetDescription(), (void *)addr_description.addr,
- AsanThreadIdAndName(tid).c_str());
+ scariness.GetDescription(), (void*)addr_description.addr,
+ AsanThreadIdAndName(tid).c_str());
Printf("%s object passed to delete has wrong type:\n", d.Default());
if (delete_size != 0) {
Printf(
@@ -100,11 +100,11 @@ void ErrorNewDeleteTypeMismatch::Print(ScopedSanitizerReport &srep) {
"ASAN_OPTIONS=new_delete_type_mismatch=0\n");
}
-void ErrorFreeSizeMismatch::Print(ScopedSanitizerReport &srep) {
+void ErrorFreeSizeMismatch::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF("ERROR: AddressSanitizer: %s on %p in thread %s:",
- scariness.GetDescription(), (void*)addr_description.addr,
- AsanThreadIdAndName(tid).c_str());
+ scariness.GetDescription(), (void*)addr_description.addr,
+ AsanThreadIdAndName(tid).c_str());
Printf("%s object passed to %s has wrong size or alignment:\n", d.Default(),
(isFreeAlignedSized() ? "free_aligned_sized" : "free_sized"));
if (delete_size != 0) {
@@ -141,12 +141,12 @@ void ErrorFreeSizeMismatch::Print(ScopedSanitizerReport &srep) {
"ASAN_OPTIONS=free_size_mismatch=0\n");
}
-void ErrorFreeNotMalloced::Print(ScopedSanitizerReport &srep) {
+void ErrorFreeNotMalloced::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: attempting free on address "
"which was not malloc()-ed: %p in thread %s",
- (void *)addr_description.Address(), AsanThreadIdAndName(tid).c_str());
+ (void*)addr_description.Address(), AsanThreadIdAndName(tid).c_str());
CHECK_GT(free_stack->size, 0);
scariness.Print();
GET_STACK_TRACE_FATAL(free_stack->trace[0], free_stack->top_frame_bp);
@@ -156,7 +156,7 @@ void ErrorFreeNotMalloced::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), &stack);
}
-void ErrorAllocTypeMismatch::Print(ScopedSanitizerReport &srep) {
+void ErrorAllocTypeMismatch::Print(ScopedSanitizerReport& srep) {
static const char *alloc_names[] = {"INVALID", "malloc", "operator new",
"operator new []"};
static const char *dealloc_names[] = {"INVALID", "free", "operator delete",
@@ -164,8 +164,9 @@ void ErrorAllocTypeMismatch::Print(ScopedSanitizerReport &srep) {
CHECK_NE(alloc_type, dealloc_type);
Decorator d;
srep.AddTitleF("ERROR: AddressSanitizer: %s (%s vs %s) on %p",
- scariness.GetDescription(), alloc_names[alloc_type],
- dealloc_names[dealloc_type], (void *)addr_description.Address());
+ scariness.GetDescription(), alloc_names[alloc_type],
+ dealloc_names[dealloc_type],
+ (void*)addr_description.Address());
CHECK_GT(dealloc_stack->size, 0);
scariness.Print();
GET_STACK_TRACE_FATAL(dealloc_stack->trace[0], dealloc_stack->top_frame_bp);
@@ -178,31 +179,32 @@ void ErrorAllocTypeMismatch::Print(ScopedSanitizerReport &srep) {
"ASAN_OPTIONS=alloc_dealloc_mismatch=0\n");
}
-void ErrorMallocUsableSizeNotOwned::Print(ScopedSanitizerReport &srep) {
+void ErrorMallocUsableSizeNotOwned::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: attempting to call malloc_usable_size() for "
"pointer which is not owned: %p",
- (void *)addr_description.Address());
+ (void*)addr_description.Address());
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
addr_description.Print(srep);
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorSanitizerGetAllocatedSizeNotOwned::Print(ScopedSanitizerReport &srep) {
+void ErrorSanitizerGetAllocatedSizeNotOwned::Print(
+ ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: attempting to call "
"__sanitizer_get_allocated_size() for pointer which is not owned: %p",
- (void *)addr_description.Address());
+ (void*)addr_description.Address());
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
addr_description.Print(srep);
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorCallocOverflow::Print(ScopedSanitizerReport &srep) {
+void ErrorCallocOverflow::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: calloc parameters overflow: count * size "
@@ -214,7 +216,7 @@ void ErrorCallocOverflow::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorReallocArrayOverflow::Print(ScopedSanitizerReport &srep) {
+void ErrorReallocArrayOverflow::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: reallocarray parameters overflow: count * size "
@@ -226,7 +228,7 @@ void ErrorReallocArrayOverflow::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorPvallocOverflow::Print(ScopedSanitizerReport &srep) {
+void ErrorPvallocOverflow::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: pvalloc parameters overflow: size 0x%zx "
@@ -239,7 +241,7 @@ void ErrorPvallocOverflow::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorInvalidAllocationAlignment::Print(ScopedSanitizerReport &srep) {
+void ErrorInvalidAllocationAlignment::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: invalid allocation alignment: %zd, "
@@ -251,18 +253,21 @@ void ErrorInvalidAllocationAlignment::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorInvalidAlignedAllocAlignment::Print(ScopedSanitizerReport &srep) {
+void ErrorInvalidAlignedAllocAlignment::Print(ScopedSanitizerReport& srep) {
Decorator d;
#if SANITIZER_POSIX
- srep.AddTitleF("ERROR: AddressSanitizer: invalid alignment requested in "
- "aligned_alloc: %zd, alignment must be a power of two and the "
- "requested size 0x%zx must be a multiple of alignment "
- "(thread %s)", alignment, size, AsanThreadIdAndName(tid).c_str());
+ srep.AddTitleF(
+ "ERROR: AddressSanitizer: invalid alignment requested in "
+ "aligned_alloc: %zd, alignment must be a power of two and the "
+ "requested size 0x%zx must be a multiple of alignment "
+ "(thread %s)",
+ alignment, size, AsanThreadIdAndName(tid).c_str());
#else
- srep.AddTitleF("ERROR: AddressSanitizer: invalid alignment requested in "
- "aligned_alloc: %zd, the requested size 0x%zx must be a multiple "
- "of alignment (thread %s)", alignment, size,
- AsanThreadIdAndName(tid).c_str());
+ srep.AddTitleF(
+ "ERROR: AddressSanitizer: invalid alignment requested in "
+ "aligned_alloc: %zd, the requested size 0x%zx must be a multiple "
+ "of alignment (thread %s)",
+ alignment, size, AsanThreadIdAndName(tid).c_str());
#endif
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
@@ -270,20 +275,20 @@ void ErrorInvalidAlignedAllocAlignment::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorInvalidPosixMemalignAlignment::Print(ScopedSanitizerReport &srep) {
+void ErrorInvalidPosixMemalignAlignment::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: invalid alignment requested in posix_memalign: "
"%zd, alignment must be a power of two and a multiple of sizeof(void*) "
"== %zd (thread %s)",
- alignment, sizeof(void *), AsanThreadIdAndName(tid).c_str());
+ alignment, sizeof(void*), AsanThreadIdAndName(tid).c_str());
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
PrintHintAllocatorCannotReturnNull();
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorAllocationSizeTooBig::Print(ScopedSanitizerReport &srep) {
+void ErrorAllocationSizeTooBig::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: requested allocation size 0x%zx (0x%zx after "
@@ -296,36 +301,40 @@ void ErrorAllocationSizeTooBig::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorRssLimitExceeded::Print(ScopedSanitizerReport &srep) {
+void ErrorRssLimitExceeded::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF(
"ERROR: AddressSanitizer: specified RSS limit exceeded, currently set to "
- "soft_rss_limit_mb=%zd", common_flags()->soft_rss_limit_mb);
+ "soft_rss_limit_mb=%zd",
+ common_flags()->soft_rss_limit_mb);
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
PrintHintAllocatorCannotReturnNull();
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorOutOfMemory::Print(ScopedSanitizerReport &srep) {
- srep.AddTitleF("ERROR: %s: out of memory: allocator is trying to allocate 0x%zx "
- "bytes", SanitizerToolName, requested_size);
+void ErrorOutOfMemory::Print(ScopedSanitizerReport& srep) {
+ srep.AddTitleF(
+ "ERROR: %s: out of memory: allocator is trying to allocate 0x%zx "
+ "bytes",
+ SanitizerToolName, requested_size);
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
PrintHintAllocatorCannotReturnNull();
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorStringFunctionMemoryRangesOverlap::Print(ScopedSanitizerReport &srep) {
+void ErrorStringFunctionMemoryRangesOverlap::Print(
+ ScopedSanitizerReport& srep) {
char bug_type[100];
internal_snprintf(bug_type, sizeof(bug_type), "%s-param-overlap", function);
srep.AddTitleF(
"ERROR: AddressSanitizer: %s: memory ranges [%p,%p) and [%p, %p) "
"overlap",
- bug_type, (void *)addr1_description.Address(),
- (void *)(addr1_description.Address() + length1),
- (void *)addr2_description.Address(),
- (void *)(addr2_description.Address() + length2));
+ bug_type, (void*)addr1_description.Address(),
+ (void*)(addr1_description.Address() + length1),
+ (void*)addr2_description.Address(),
+ (void*)(addr2_description.Address() + length2));
scariness.Print();
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
@@ -334,10 +343,10 @@ void ErrorStringFunctionMemoryRangesOverlap::Print(ScopedSanitizerReport &srep)
ReportErrorSummary(bug_type, stack);
}
-void ErrorStringFunctionSizeOverflow::Print(ScopedSanitizerReport &srep) {
+void ErrorStringFunctionSizeOverflow::Print(ScopedSanitizerReport& srep) {
Decorator d;
srep.AddTitleF("ERROR: AddressSanitizer: %s: (size=%zd)",
- scariness.GetDescription(), size);
+ scariness.GetDescription(), size);
scariness.Print();
stack->Print();
srep.AddStack(stack->trace, stack->size, kReportStackFault, "fault", 5);
@@ -345,7 +354,8 @@ void ErrorStringFunctionSizeOverflow::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorBadParamsToAnnotateContiguousContainer::Print(ScopedSanitizerReport &srep) {
+void ErrorBadParamsToAnnotateContiguousContainer::Print(
+ ScopedSanitizerReport& srep) {
Report(
"ERROR: AddressSanitizer: bad parameters to "
"__sanitizer_annotate_contiguous_container:\n"
@@ -359,7 +369,8 @@ void ErrorBadParamsToAnnotateContiguousContainer::Print(ScopedSanitizerReport &s
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorBadParamsToAnnotateDoubleEndedContiguousContainer::Print(ScopedSanitizerReport &srep) {
+void ErrorBadParamsToAnnotateDoubleEndedContiguousContainer::Print(
+ ScopedSanitizerReport& srep) {
Report(
"ERROR: AddressSanitizer: bad parameters to "
"__sanitizer_annotate_double_ended_contiguous_container:\n"
@@ -377,10 +388,10 @@ void ErrorBadParamsToAnnotateDoubleEndedContiguousContainer::Print(ScopedSanitiz
ReportErrorSummary(scariness.GetDescription(), stack);
}
-void ErrorODRViolation::Print(ScopedSanitizerReport &srep) {
+void ErrorODRViolation::Print(ScopedSanitizerReport& srep) {
Decorator d;
- srep.AddTitleF("ERROR: AddressSanitizer: %s (%p):", scariness.GetDescription(),
- (void *)global1.beg);
+ srep.AddTitleF("ERROR: AddressSanitizer: %s (%p):",
+ scariness.GetDescription(), (void*)global1.beg);
InternalScopedString g1_loc;
InternalScopedString g2_loc;
PrintGlobalLocation(&g1_loc, global1, /*print_module_name=*/true);
@@ -405,11 +416,11 @@ void ErrorODRViolation::Print(ScopedSanitizerReport &srep) {
ReportErrorSummary(error_msg.data());
}
-void ErrorInvalidPointerPair::Print(ScopedSanitizerReport &srep) {
+void ErrorInvalidPointerPair::Print(ScopedSanitizerReport& srep) {
Decorator d;
- srep.AddTitleF("ERROR: AddressSanitizer: %s: %p %p", scariness.GetDescription(),
- (void *)addr1_description.Address(),
- (void *)addr2_description.Address());
+ srep.AddTitleF("ERROR: AddressSanitizer: %s: %p %p",
+ scariness.GetDescription(), (void*)addr1_description.Address(),
+ (void*)addr2_description.Address());
GET_STACK_TRACE_FATAL(pc, bp);
stack.Print();
srep.AddStack(stack.trace, stack.size, kReportStackFault, "fault", 5);
@@ -647,11 +658,12 @@ static void CheckPoisonRecords(uptr addr) {
}
}
-void ErrorGeneric::Print(ScopedSanitizerReport &srep) {
+void ErrorGeneric::Print(ScopedSanitizerReport& srep) {
Decorator d;
uptr addr = addr_description.Address();
- srep.AddTitleF("ERROR: AddressSanitizer: %s on address %p at pc %p bp %p sp %p",
- bug_descr, (void *)addr, (void *)pc, (void *)bp, (void *)sp);
+ srep.AddTitleF(
+ "ERROR: AddressSanitizer: %s on address %p at pc %p bp %p sp %p",
+ bug_descr, (void*)addr, (void*)pc, (void*)bp, (void*)sp);
Printf("%s%s of size %zu at %p thread %s%s\n", d.Access(),
access_size ? (is_write ? "WRITE" : "READ") : "ACCESS", access_size,
diff --git a/compiler-rt/lib/asan/asan_errors.h b/compiler-rt/lib/asan/asan_errors.h
index 599546a35..2c609f500 100644
--- a/compiler-rt/lib/asan/asan_errors.h
+++ b/compiler-rt/lib/asan/asan_errors.h
@@ -62,7 +62,7 @@ struct ErrorDeadlySignal : ErrorBase {
scariness.Scare(25, "wild-addr");
}
}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorDoubleFree : ErrorBase {
@@ -76,7 +76,7 @@ struct ErrorDoubleFree : ErrorBase {
CHECK_GT(second_free_stack->size, 0);
GetHeapAddressInformation(addr, 1, &addr_description);
}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorNewDeleteTypeMismatch : ErrorBase {
@@ -94,7 +94,7 @@ struct ErrorNewDeleteTypeMismatch : ErrorBase {
delete_alignment(delete_alignment_) {
GetHeapAddressInformation(addr, 1, &addr_description);
}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorFreeSizeMismatch : ErrorBase {
@@ -112,7 +112,7 @@ struct ErrorFreeSizeMismatch : ErrorBase {
delete_alignment(delete_alignment) {
GetHeapAddressInformation(addr, 1, &addr_description);
}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
bool isFreeAlignedSized() const { return delete_alignment != 0; }
};
@@ -125,7 +125,7 @@ struct ErrorFreeNotMalloced : ErrorBase {
: ErrorBase(tid, 40, "bad-free"),
free_stack(stack),
addr_description(addr, /*shouldLockThreadRegistry=*/false) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorAllocTypeMismatch : ErrorBase {
@@ -141,7 +141,7 @@ struct ErrorAllocTypeMismatch : ErrorBase {
alloc_type(alloc_type_),
dealloc_type(dealloc_type_),
addr_description(addr, 1, false) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorMallocUsableSizeNotOwned : ErrorBase {
@@ -153,7 +153,7 @@ struct ErrorMallocUsableSizeNotOwned : ErrorBase {
: ErrorBase(tid, 10, "bad-malloc_usable_size"),
stack(stack_),
addr_description(addr, /*shouldLockThreadRegistry=*/false) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorSanitizerGetAllocatedSizeNotOwned : ErrorBase {
@@ -166,7 +166,7 @@ struct ErrorSanitizerGetAllocatedSizeNotOwned : ErrorBase {
: ErrorBase(tid, 10, "bad-__sanitizer_get_allocated_size"),
stack(stack_),
addr_description(addr, /*shouldLockThreadRegistry=*/false) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorCallocOverflow : ErrorBase {
@@ -181,7 +181,7 @@ struct ErrorCallocOverflow : ErrorBase {
stack(stack_),
count(count_),
size(size_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorReallocArrayOverflow : ErrorBase {
@@ -196,7 +196,7 @@ struct ErrorReallocArrayOverflow : ErrorBase {
stack(stack_),
count(count_),
size(size_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorPvallocOverflow : ErrorBase {
@@ -208,7 +208,7 @@ struct ErrorPvallocOverflow : ErrorBase {
: ErrorBase(tid, 10, "pvalloc-overflow"),
stack(stack_),
size(size_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorInvalidAllocationAlignment : ErrorBase {
@@ -221,7 +221,7 @@ struct ErrorInvalidAllocationAlignment : ErrorBase {
: ErrorBase(tid, 10, "invalid-allocation-alignment"),
stack(stack_),
alignment(alignment_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorInvalidAlignedAllocAlignment : ErrorBase {
@@ -236,7 +236,7 @@ struct ErrorInvalidAlignedAllocAlignment : ErrorBase {
stack(stack_),
size(size_),
alignment(alignment_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorInvalidPosixMemalignAlignment : ErrorBase {
@@ -249,7 +249,7 @@ struct ErrorInvalidPosixMemalignAlignment : ErrorBase {
: ErrorBase(tid, 10, "invalid-posix-memalign-alignment"),
stack(stack_),
alignment(alignment_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorAllocationSizeTooBig : ErrorBase {
@@ -266,7 +266,7 @@ struct ErrorAllocationSizeTooBig : ErrorBase {
user_size(user_size_),
total_size(total_size_),
max_size(max_size_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorRssLimitExceeded : ErrorBase {
@@ -276,7 +276,7 @@ struct ErrorRssLimitExceeded : ErrorBase {
ErrorRssLimitExceeded(u32 tid, BufferedStackTrace *stack_)
: ErrorBase(tid, 10, "rss-limit-exceeded"),
stack(stack_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorOutOfMemory : ErrorBase {
@@ -288,7 +288,7 @@ struct ErrorOutOfMemory : ErrorBase {
: ErrorBase(tid, 10, "out-of-memory"),
stack(stack_),
requested_size(requested_size_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorStringFunctionMemoryRangesOverlap : ErrorBase {
@@ -314,7 +314,7 @@ struct ErrorStringFunctionMemoryRangesOverlap : ErrorBase {
scariness.Clear();
scariness.Scare(10, bug_type);
}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorStringFunctionSizeOverflow : ErrorBase {
@@ -331,7 +331,7 @@ struct ErrorStringFunctionSizeOverflow : ErrorBase {
addr_description(addr, /*shouldLockThreadRegistry=*/false),
size(size),
is_write(is_write) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorBadParamsToAnnotateContiguousContainer : ErrorBase {
@@ -350,7 +350,7 @@ struct ErrorBadParamsToAnnotateContiguousContainer : ErrorBase {
end(end_),
old_mid(old_mid_),
new_mid(new_mid_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorBadParamsToAnnotateDoubleEndedContiguousContainer : ErrorBase {
@@ -372,7 +372,7 @@ struct ErrorBadParamsToAnnotateDoubleEndedContiguousContainer : ErrorBase {
old_container_end(old_container_end_),
new_container_beg(new_container_beg_),
new_container_end(new_container_end_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorODRViolation : ErrorBase {
@@ -387,7 +387,7 @@ struct ErrorODRViolation : ErrorBase {
global2(*g2),
stack_id1(stack_id1_),
stack_id2(stack_id2_) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorInvalidPointerPair : ErrorBase {
@@ -404,7 +404,7 @@ struct ErrorInvalidPointerPair : ErrorBase {
sp(sp_),
addr1_description(p1, 1, /*shouldLockThreadRegistry=*/false),
addr2_description(p2, 1, /*shouldLockThreadRegistry=*/false) {}
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
struct ErrorGeneric : ErrorBase {
@@ -418,7 +418,7 @@ struct ErrorGeneric : ErrorBase {
ErrorGeneric() = default; // (*)
ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr, bool is_write_,
uptr access_size_);
- void Print(ScopedSanitizerReport &srep);
+ void Print(ScopedSanitizerReport& srep);
};
// clang-format off
@@ -481,7 +481,7 @@ struct ErrorDescription {
ASAN_FOR_EACH_ERROR_KIND(ASAN_ERROR_DESCRIPTION_CONSTRUCTOR)
bool IsValid() { return kind != kErrorKindInvalid; }
- void Print(ScopedSanitizerReport &srep) {
+ void Print(ScopedSanitizerReport& srep) {
switch (kind) {
ASAN_FOR_EACH_ERROR_KIND(ASAN_ERROR_DESCRIPTION_PRINT)
case kErrorKindInvalid:
diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp
index 6cde3840a..7f10c44a7 100644
--- a/compiler-rt/lib/asan/asan_report.cpp
+++ b/compiler-rt/lib/asan/asan_report.cpp
@@ -173,7 +173,7 @@ class ScopedInErrorReport {
if (current_error_.IsValid()) {
// Passed by reference (or pointer) through the Error*::Print /
// *AddressDescription::Print methods so they can push receiver events.
- const char *type_str =
+ const char* type_str =
current_error_.kind == kErrorKindGeneric
? current_error_.Generic.bug_descr
: current_error_.Base.scariness.GetDescription();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.cpp
index 680bf89c7..37a3570e8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.cpp
@@ -8,25 +8,25 @@
#include "sanitizer_report_receiver.h"
+#include <stdarg.h>
+
#include "sanitizer_common.h"
#include "sanitizer_libc.h"
#include "sanitizer_report_decorator.h"
-#include <stdarg.h>
-
namespace __sanitizer {
// Internal in sanitizer_printf.cpp — not in a public header but linked in the
// same library. Used to format AddTitleF's varargs without re-implementing
// the sanitizer printf state machine.
-int VSNPrintf(char *buff, int buff_length, const char *format, va_list args);
+int VSNPrintf(char* buff, int buff_length, const char* format, va_list args);
// Fixed-size list; registration happens once at init.
static const int kMaxReceivers = 4;
-static ReportReceiver *g_receivers[kMaxReceivers];
+static ReportReceiver* g_receivers[kMaxReceivers];
static int g_num_receivers = 0;
-void RegisterReportReceiver(ReportReceiver *r) {
+void RegisterReportReceiver(ReportReceiver* r) {
if (!r)
return;
if (g_num_receivers >= kMaxReceivers)
@@ -34,19 +34,18 @@ void RegisterReportReceiver(ReportReceiver *r) {
g_receivers[g_num_receivers++] = r;
}
-ScopedSanitizerReport::ScopedSanitizerReport(const char *sanitizer,
- const char *type)
+ScopedSanitizerReport::ScopedSanitizerReport(const char* sanitizer,
+ const char* type)
: sanitizer_(sanitizer ? sanitizer : "") {
for (int i = 0; i < g_num_receivers; i++)
g_receivers[i]->OnStart(sanitizer, type);
}
ScopedSanitizerReport::~ScopedSanitizerReport() {
- for (int i = 0; i < g_num_receivers; i++)
- g_receivers[i]->OnFinish();
+ for (int i = 0; i < g_num_receivers; i++) g_receivers[i]->OnFinish();
}
-void ScopedSanitizerReport::AddTitleF(const char *fmt, ...) {
+void ScopedSanitizerReport::AddTitleF(const char* fmt, ...) {
// Format into a heap-owned buffer so we don't blow the -Wframe-larger-than
// limit with a stack-resident 1 KiB title buffer.
InternalMmapVector<char> buf(1024);
@@ -71,7 +70,7 @@ void ScopedSanitizerReport::AddTitleF(const char *fmt, ...) {
}
void ScopedSanitizerReport::AddAddress(uptr addr, uptr size,
- ReportAddressKind kind, const char *desc,
+ ReportAddressKind kind, const char* desc,
uptr desc_len) {
if (!addr)
return;
@@ -79,8 +78,8 @@ void ScopedSanitizerReport::AddAddress(uptr addr, uptr size,
g_receivers[i]->OnAddress(addr, size, kind, desc, desc_len);
}
-void ScopedSanitizerReport::AddStack(const uptr *frames, uptr num_frames,
- ReportStackKind kind, const char *desc,
+void ScopedSanitizerReport::AddStack(const uptr* frames, uptr num_frames,
+ ReportStackKind kind, const char* desc,
uptr desc_len) {
if (!frames || !num_frames)
return;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.h b/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.h
index f69f2bbf7..10f5f1a1b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_report_receiver.h
@@ -51,52 +51,51 @@ enum ReportAddressKind {
class ReportReceiver {
public:
virtual ~ReportReceiver() {}
- virtual void OnStart(const char *sanitizer, const char *type) {}
+ virtual void OnStart(const char* sanitizer, const char* type) {}
// Fully-formatted "ERROR: <sanitizer>: ..." header line for the report.
- virtual void OnTitle(const char *title, uptr title_len) {}
+ virtual void OnTitle(const char* title, uptr title_len) {}
// A memory address involved in the report. `size` may be 0.
virtual void OnAddress(uptr addr, uptr size, ReportAddressKind kind,
- const char *desc, uptr desc_len) {}
+ const char* desc, uptr desc_len) {}
// A backtrace involved in the report. `frames` is top-of-stack-first.
- virtual void OnStack(const uptr *frames, uptr num_frames,
- ReportStackKind kind, const char *desc,
- uptr desc_len) {}
+ virtual void OnStack(const uptr* frames, uptr num_frames,
+ ReportStackKind kind, const char* desc, uptr desc_len) {}
virtual void OnFinish() {}
};
// Register a receiver. The pointer must remain valid for the process lifetime.
// Not thread-safe; call during platform init before any report can fire.
-void RegisterReportReceiver(ReportReceiver *receiver);
+void RegisterReportReceiver(ReportReceiver* receiver);
// Piped to all registered receivers. Construct at the start of a report,
// destroy at the end. Passed by reference (or pointer where the caller may
// be outside a report) through the sanitizer's Print methods.
class ScopedSanitizerReport {
public:
- ScopedSanitizerReport(const char *sanitizer, const char *type);
+ ScopedSanitizerReport(const char* sanitizer, const char* type);
~ScopedSanitizerReport();
// Format printf-style, print the resulting line with error decoration + pid
// prefix, and notify OnTitle. Caller writes the full title text (including
// the "ERROR: AddressSanitizer:" or "WARNING: ThreadSanitizer:" prefix); no
// newline needed — one is appended for printing.
- void AddTitleF(const char *fmt, ...) FORMAT(2, 3);
+ void AddTitleF(const char* fmt, ...) FORMAT(2, 3);
// Notify OnAddress. Does not print. addr == 0 is treated as a no-op.
void AddAddress(uptr addr, uptr size, ReportAddressKind kind,
- const char *desc, uptr desc_len);
+ const char* desc, uptr desc_len);
// Notify OnStack. Does not print. Empty stack is treated as a no-op.
- void AddStack(const uptr *frames, uptr num_frames, ReportStackKind kind,
- const char *desc, uptr desc_len);
+ void AddStack(const uptr* frames, uptr num_frames, ReportStackKind kind,
+ const char* desc, uptr desc_len);
- const char *sanitizer() const { return sanitizer_; }
+ const char* sanitizer() const { return sanitizer_; }
private:
- const char *sanitizer_;
+ const char* sanitizer_;
- ScopedSanitizerReport(const ScopedSanitizerReport &) = delete;
- void operator=(const ScopedSanitizerReport &) = delete;
+ ScopedSanitizerReport(const ScopedSanitizerReport&) = delete;
+ void operator=(const ScopedSanitizerReport&) = delete;
};
} // namespace __sanitizer
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index 83880dfb9..fc60c828c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -10,13 +10,14 @@
//
//===----------------------------------------------------------------------===//
#include "tsan_report.h"
-#include "tsan_platform.h"
-#include "tsan_rtl.h"
+
#include "sanitizer_common/sanitizer_file.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_report_decorator.h"
#include "sanitizer_common/sanitizer_report_receiver.h"
#include "sanitizer_common/sanitizer_stacktrace_printer.h"
+#include "tsan_platform.h"
+#include "tsan_rtl.h"
namespace __tsan {
@@ -144,11 +145,11 @@ namespace {
// Flatten a SymbolizedStack (top-of-stack-first linked list of symbolized
// frames) into a raw-PC array on `out`, capped at `cap`. Returns count.
-uptr FlattenStack(const ReportStack *stack, uptr *out, uptr cap) {
+uptr FlattenStack(const ReportStack* stack, uptr* out, uptr cap) {
if (!stack || !stack->frames)
return 0;
uptr n = 0;
- for (SymbolizedStack *f = stack->frames; f && f->info.address && n < cap;
+ for (SymbolizedStack* f = stack->frames; f && f->info.address && n < cap;
f = f->next)
out[n++] = f->info.address;
return n;
@@ -161,8 +162,8 @@ uptr FlattenStack(const ReportStack *stack, uptr *out, uptr cap) {
// output and the receiver's OnStack event. `desc` is passed verbatim to
// OnStack; it is NOT printed (the caller prints the description on the
// preceding line, as required for the mutex-set-suffix layout).
-void PrintStack(ScopedSanitizerReport &srep, const ReportStack *stack,
- ReportStackKind kind, const char *desc, uptr desc_len) {
+void PrintStack(ScopedSanitizerReport& srep, const ReportStack* stack,
+ ReportStackKind kind, const char* desc, uptr desc_len) {
PrintStack(stack);
// Heap-owned to keep this function (and any caller it gets inlined into)
// under the -Wframe-larger-than limit.
@@ -171,7 +172,7 @@ void PrintStack(ScopedSanitizerReport &srep, const ReportStack *stack,
srep.AddStack(frames.data(), n, kind, desc, desc_len);
}
-static void PrintMop(ScopedSanitizerReport &srep, const ReportMop *mop,
+static void PrintMop(ScopedSanitizerReport& srep, const ReportMop* mop,
bool first) {
Decorator d;
char thrbuf[kThreadBufSize];
@@ -180,14 +181,13 @@ static void PrintMop(ScopedSanitizerReport &srep, const ReportMop *mop,
if (mop->external_tag == kExternalTagNone) {
s.AppendF("%s of size %d at %p by %s",
MopDesc(first, mop->write, mop->atomic), mop->size,
- (void *)mop->addr, thread_name(thrbuf, mop->tid));
+ (void*)mop->addr, thread_name(thrbuf, mop->tid));
} else {
const char *object_type = GetObjectTypeFromTag(mop->external_tag);
if (object_type == nullptr)
object_type = "external object";
- s.AppendF("%s access of %s at %p by %s",
- ExternalMopDesc(first, mop->write), object_type,
- (void *)mop->addr, thread_name(thrbuf, mop->tid));
+ s.AppendF("%s access of %s at %p by %s", ExternalMopDesc(first, mop->write),
+ object_type, (void*)mop->addr, thread_name(thrbuf, mop->tid));
}
Printf(" %s", s.data());
PrintMutexSet(mop->mset);
@@ -196,13 +196,12 @@ static void PrintMop(ScopedSanitizerReport &srep, const ReportMop *mop,
if (first)
srep.AddAddress((uptr)mop->addr, mop->size, kReportAddressFault, "fault",
5);
- PrintStack(srep, mop->stack,
- first ? kReportStackFault : kReportStackOther, s.data(),
- s.length());
+ PrintStack(srep, mop->stack, first ? kReportStackFault : kReportStackOther,
+ s.data(), s.length());
}
-static void PrintLocation(ScopedSanitizerReport &srep,
- const ReportLocation *loc) {
+static void PrintLocation(ScopedSanitizerReport& srep,
+ const ReportLocation* loc) {
Decorator d;
char thrbuf[kThreadBufSize];
bool print_stack = false;
@@ -212,25 +211,24 @@ static void PrintLocation(ScopedSanitizerReport &srep,
const DataInfo &global = loc->global;
if (global.size != 0)
s.AppendF("Location is global '%s' of size %zu at %p (%s+0x%zx)",
- global.name, global.size,
- reinterpret_cast<void *>(global.start),
+ global.name, global.size, reinterpret_cast<void*>(global.start),
StripModuleName(global.module), global.module_offset);
else
s.AppendF("Location is global '%s' at %p (%s+0x%zx)", global.name,
- reinterpret_cast<void *>(global.start),
+ reinterpret_cast<void*>(global.start),
StripModuleName(global.module), global.module_offset);
} else if (loc->type == ReportLocationHeap) {
const char *object_type = GetObjectTypeFromTag(loc->external_tag);
if (!object_type)
s.AppendF("Location is heap block of size %zu at %p allocated by %s:",
loc->heap_chunk_size,
- reinterpret_cast<void *>(loc->heap_chunk_start),
+ reinterpret_cast<void*>(loc->heap_chunk_start),
thread_name(thrbuf, loc->tid));
else
- s.AppendF("Location is %s of size %zu at %p allocated by %s:",
- object_type, loc->heap_chunk_size,
- reinterpret_cast<void *>(loc->heap_chunk_start),
- thread_name(thrbuf, loc->tid));
+ s.AppendF(
+ "Location is %s of size %zu at %p allocated by %s:", object_type,
+ loc->heap_chunk_size, reinterpret_cast<void*>(loc->heap_chunk_start),
+ thread_name(thrbuf, loc->tid));
print_stack = true;
stack_kind = kReportStackAllocation;
srep.AddAddress((uptr)loc->heap_chunk_start, loc->heap_chunk_size,
@@ -265,18 +263,18 @@ static void PrintMutexShortWithAddress(const ReportMutex *rm,
reinterpret_cast<void *>(rm->addr), d.Default(), after);
}
-static void PrintMutex(ScopedSanitizerReport &srep, const ReportMutex *rm) {
+static void PrintMutex(ScopedSanitizerReport& srep, const ReportMutex* rm) {
Decorator d;
Printf("%s", d.Mutex());
InternalScopedString s;
s.AppendF("Mutex M%u (%p) created at:", rm->id,
- reinterpret_cast<void *>(rm->addr));
+ reinterpret_cast<void*>(rm->addr));
Printf(" %s\n", s.data());
Printf("%s", d.Default());
PrintStack(srep, rm->stack, kReportStackOther, s.data(), s.length());
}
-static void PrintThread(ScopedSanitizerReport &srep, const ReportThread *rt) {
+static void PrintThread(ScopedSanitizerReport& srep, const ReportThread* rt) {
Decorator d;
if (rt->id == kMainTid) // Little sense in describing the main thread.
return;
@@ -361,11 +359,11 @@ void PrintReport(const ReportDesc *rep) {
Printf("%s:\n", thread_name(thrbuf, rep->unique_tids[i]));
Printf("%s", d.Default());
if (flags()->second_deadlock_stack) {
- PrintStack(srep, rep->stacks[2*i], kReportStackOther, nullptr, 0);
+ PrintStack(srep, rep->stacks[2 * i], kReportStackOther, nullptr, 0);
Printf(" Mutex ");
PrintMutexShort(rep->mutexes[i],
" previously acquired by the same thread here:\n");
- PrintStack(srep, rep->stacks[2*i+1], kReportStackOther, nullptr, 0);
+ PrintStack(srep, rep->stacks[2 * i + 1], kReportStackOther, nullptr, 0);
} else {
PrintStack(srep, rep->stacks[i], kReportStackOther, nullptr, 0);
if (i == 0)
@@ -389,8 +387,7 @@ void PrintReport(const ReportDesc *rep) {
if (rep->sleep)
PrintSleep(rep->sleep);
- for (uptr i = 0; i < rep->locs.Size(); i++)
- PrintLocation(srep, rep->locs[i]);
+ for (uptr i = 0; i < rep->locs.Size(); i++) PrintLocation(srep, rep->locs[i]);
if (rep->typ != ReportTypeDeadlock) {
for (uptr i = 0; i < rep->mutexes.Size(); i++)
@@ -414,7 +411,6 @@ void PrintReport(const ReportDesc *rep) {
Printf("==================\n");
}
-
#else // #if !SANITIZER_GO
const Tid kMainGoroutineId = 1;
``````````
</details>
https://github.com/llvm/llvm-project/pull/224706
More information about the llvm-commits
mailing list