Commit d5f29907 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[msan] Treat more memory uninitialized

After closing a handle scope, and when allocating a new segment in a
zone, treat that memory as uninitialized in MSan. This will hopefully
catch more errors than handle zapping, which needs to be enabled
explicitly.

R=ahaas@chromium.org

Bug: v8:7570
Change-Id: Ie3be07434bed878fb607a522787514421f397197
Reviewed-on: https://chromium-review.googlesource.com/1046657
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53089}
parent b50ac57d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/handles.h" #include "src/handles.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/msan.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
namespace v8 { namespace v8 {
...@@ -68,15 +69,17 @@ void HandleScope::CloseScope(Isolate* isolate, ...@@ -68,15 +69,17 @@ void HandleScope::CloseScope(Isolate* isolate,
std::swap(current->next, prev_next); std::swap(current->next, prev_next);
current->level--; current->level--;
Object** limit = prev_next;
if (current->limit != prev_limit) { if (current->limit != prev_limit) {
current->limit = prev_limit; current->limit = prev_limit;
limit = prev_limit;
DeleteExtensions(isolate); DeleteExtensions(isolate);
}
#ifdef ENABLE_HANDLE_ZAPPING #ifdef ENABLE_HANDLE_ZAPPING
ZapRange(current->next, prev_limit); ZapRange(current->next, limit);
} else {
ZapRange(current->next, prev_next);
#endif #endif
} MSAN_ALLOCATED_UNINITIALIZED_MEMORY(
current->next, static_cast<size_t>(limit - current->next));
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "src/zone/zone-segment.h" #include "src/zone/zone-segment.h"
#include "src/msan.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -11,12 +13,14 @@ void Segment::ZapContents() { ...@@ -11,12 +13,14 @@ void Segment::ZapContents() {
#ifdef DEBUG #ifdef DEBUG
memset(reinterpret_cast<void*>(start()), kZapDeadByte, capacity()); memset(reinterpret_cast<void*>(start()), kZapDeadByte, capacity());
#endif #endif
MSAN_ALLOCATED_UNINITIALIZED_MEMORY(start(), capacity());
} }
void Segment::ZapHeader() { void Segment::ZapHeader() {
#ifdef DEBUG #ifdef DEBUG
memset(this, kZapDeadByte, sizeof(Segment)); memset(this, kZapDeadByte, sizeof(Segment));
#endif #endif
MSAN_ALLOCATED_UNINITIALIZED_MEMORY(start(), sizeof(Segment));
} }
} // namespace internal } // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment