cppgc: Check for wrong sentinel values

Check for the most commonly used wrong sentinel value (-1). Users
should use cppgc::kSentinelPointer instead.

Bug: chromium:1263009
Change-Id: I200954bcd70c6a100ffec24aece3e1843e1438a0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3242002
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77529}
This commit is contained in:
Michael Lippautz 2021-10-25 17:10:34 +02:00 committed by V8 LUCI CQ
parent dcbcb52c9c
commit 9568732a0f

View File

@ -34,6 +34,8 @@ void SameThreadEnabledCheckingPolicyBase::CheckPointerImpl(
const void* ptr, bool points_to_payload, bool check_off_heap_assignments) { const void* ptr, bool points_to_payload, bool check_off_heap_assignments) {
// `ptr` must not reside on stack. // `ptr` must not reside on stack.
DCHECK(!IsOnStack(ptr)); DCHECK(!IsOnStack(ptr));
// Check for the most commonly used wrong sentinel value (-1).
DCHECK_NE(reinterpret_cast<void*>(-1), ptr);
auto* base_page = BasePage::FromPayload(ptr); auto* base_page = BasePage::FromPayload(ptr);
// Large objects do not support mixins. This also means that `base_page` is // Large objects do not support mixins. This also means that `base_page` is
// valid for large objects. // valid for large objects.