[compiler-rt] 542f91f - [NFC][hwasan] Store thread id in SavedStackAllocations (#66682)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 18:14:22 PDT 2023
Author: Vitaly Buka
Date: 2023-09-18T18:13:57-07:00
New Revision: 542f91f755b99af978425fa584a9f0a5594cd729
URL: https://github.com/llvm/llvm-project/commit/542f91f755b99af978425fa584a9f0a5594cd729
DIFF: https://github.com/llvm/llvm-project/commit/542f91f755b99af978425fa584a9f0a5594cd729.diff
LOG: [NFC][hwasan] Store thread id in SavedStackAllocations (#66682)
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_report.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index a18941f703051df..8e376447623972e 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -114,24 +114,39 @@ namespace {
// example, Printf may call syslog() which can itself be built with hwasan).
class SavedStackAllocations {
public:
- SavedStackAllocations(StackAllocationsRingBuffer *rb) {
+ SavedStackAllocations() = default;
+
+ explicit SavedStackAllocations(Thread *t) { CopyFrom(t); }
+
+ void CopyFrom(Thread *t) {
+ StackAllocationsRingBuffer *rb = t->stack_allocations();
uptr size = rb->size() * sizeof(uptr);
void *storage =
MmapAlignedOrDieOnFatalError(size, size * 2, "saved stack allocations");
new (&rb_) StackAllocationsRingBuffer(*rb, storage);
+ thread_id_ = t->unique_id();
}
~SavedStackAllocations() {
- StackAllocationsRingBuffer *rb = get();
- UnmapOrDie(rb->StartOfStorage(), rb->size() * sizeof(uptr));
+ if (rb_) {
+ StackAllocationsRingBuffer *rb = get();
+ UnmapOrDie(rb->StartOfStorage(), rb->size() * sizeof(uptr));
+ }
+ }
+
+ const StackAllocationsRingBuffer *get() const {
+ return (const StackAllocationsRingBuffer *)&rb_;
}
StackAllocationsRingBuffer *get() {
return (StackAllocationsRingBuffer *)&rb_;
}
+ u32 thread_id() const { return thread_id_; }
+
private:
- uptr rb_;
+ uptr rb_ = 0;
+ u32 thread_id_;
};
class Decorator: public __sanitizer::SanitizerCommonDecorator {
@@ -737,8 +752,7 @@ class TagMismatchReport : public BaseReport {
};
TagMismatchReport::~TagMismatchReport() {
- SavedStackAllocations current_stack_allocations(
- GetCurrentThread()->stack_allocations());
+ SavedStackAllocations current_stack_allocations(GetCurrentThread());
Decorator d;
// TODO: when possible, try to print heap-use-after-free, etc.
More information about the llvm-commits
mailing list