[vm] Unpoison memory before zapping.

Zapping is applied to the whole segment, not just what had been allocated, and the unallocated portion is poisoned.

TEST=debug asan
Change-Id: I2e0d42f97dda4d38fc2579b54d8e171ee88098fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309781
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
This commit is contained in:
Ryan Macnak
2023-06-15 16:53:25 +00:00
committed by Commit Queue
parent 5f7b77bafc
commit 218ef4712b
+3
View File
@@ -101,6 +101,7 @@ Zone::Segment* Zone::Segment::New(intptr_t size, Zone::Segment* next) {
#ifdef DEBUG
// Zap the entire allocated segment (including the header).
ASAN_UNPOISON(reinterpret_cast<void*>(result), size);
memset(reinterpret_cast<void*>(result), kZapUninitializedByte, size);
#endif
ASAN_POISON(reinterpret_cast<void*>(result), size);
@@ -125,6 +126,7 @@ void Zone::Segment::DeleteSegmentList(Segment* head) {
VirtualMemory* memory = current->memory();
#ifdef DEBUG
// Zap the entire current segment (including the header).
ASAN_UNPOISON(reinterpret_cast<void*>(current), current->size());
memset(reinterpret_cast<void*>(current), kZapDeletedByte, current->size());
#endif
ASAN_POISON(reinterpret_cast<void*>(current), size);
@@ -179,6 +181,7 @@ void Zone::Reset() {
segments_ = nullptr;
#ifdef DEBUG
ASAN_UNPOISON(&buffer_, kInitialChunkSize);
memset(&buffer_, kZapDeletedByte, kInitialChunkSize);
#endif
ASAN_POISON(&buffer_, kInitialChunkSize);