[compiler-rt] [scudo] Do not unmap the memory containing the this object in unmapRingBuffer (PR #83034)
Fabio D'Urso via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 14:12:34 PST 2024
https://github.com/fabio-d updated https://github.com/llvm/llvm-project/pull/83034
>From da6fa7f7407242bc331de34f941cfafd1cedbe73 Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <fdurso at google.com>
Date: Mon, 26 Feb 2024 18:09:06 +0100
Subject: [PATCH 1/2] [scudo] Do not unmap the memory containing the this
object in unmapRingBuffer
---
compiler-rt/lib/scudo/standalone/combined.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index cd5a07be1576e9..197c6d85c9b06c 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -1610,8 +1610,9 @@ class Allocator {
// is very important.
RB->RawStackDepotMap.unmap(RB->RawStackDepotMap.getBase(),
RB->RawStackDepotMap.getCapacity());
- RB->RawRingBufferMap.unmap(RB->RawRingBufferMap.getBase(),
- RB->RawRingBufferMap.getCapacity());
+ MemMapT RawRingBufferMap = RB->RawRingBufferMap;
+ RawRingBufferMap.unmap(RawRingBufferMap.getBase(),
+ RawRingBufferMap.getCapacity());
atomic_store(&RingBufferAddress, 0, memory_order_release);
}
>From 6608d26179202f652e9db110c3e7d1dfe69cdc7d Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <fdurso at google.com>
Date: Mon, 26 Feb 2024 23:07:09 +0100
Subject: [PATCH 2/2] fixup! [scudo] Do not unmap the memory containing the
this object in unmapRingBuffer
---
compiler-rt/lib/scudo/standalone/combined.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index 197c6d85c9b06c..581be0deeb9372 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -1610,6 +1610,9 @@ class Allocator {
// is very important.
RB->RawStackDepotMap.unmap(RB->RawStackDepotMap.getBase(),
RB->RawStackDepotMap.getCapacity());
+ // Note that the `RB->RawRingBufferMap` is stored on the pages managed by
+ // itself. Take over the ownership before calling unmap() so that any operation
+ // along with unmap() won't touch inaccessible pages.
MemMapT RawRingBufferMap = RB->RawRingBufferMap;
RawRingBufferMap.unmap(RawRingBufferMap.getBase(),
RawRingBufferMap.getCapacity());
More information about the llvm-commits
mailing list