From 218ef4712bee104666551079f23d798fb4bc2e49 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Thu, 15 Jun 2023 16:53:25 +0000 Subject: [PATCH] [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 Reviewed-by: Brian Quinlan --- runtime/vm/zone.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc index 47a42ab5ea8..a6d62c48ae9 100644 --- a/runtime/vm/zone.cc +++ b/runtime/vm/zone.cc @@ -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(result), size); memset(reinterpret_cast(result), kZapUninitializedByte, size); #endif ASAN_POISON(reinterpret_cast(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(current), current->size()); memset(reinterpret_cast(current), kZapDeletedByte, current->size()); #endif ASAN_POISON(reinterpret_cast(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);