mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[vm] For now, initialize the contents of null with its address.
When running with `--no-sound-null-safety` turned on, it turns out null
is unboxed as an Mint in some cases without checking for null first.
Before, tests would fail because unboxing it would give a really
large int that was unlikely to be acceptable to subsequent range
checks and the like.
However, since 2f63ace
, that memory is now zero-initialized, and zero is
more likely to be an acceptable value, so tests either fail for
unexpected reasons or, worse, unexpectedly succeed.
As a stopgap until the appropriate checks are emitted, we initialize
the contents of null with its address as an ObjectPtr like we used to.
TEST=corelib{,_2}/list_removeat_test on dartkp-* configurations.
Issue: https://github.com/dart-lang/sdk/issues/52910
Change-Id: If456d503c86202616f4f566a402118e9c41194ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313500
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
parent
db2e318b5d
commit
3fcf660ed1
1 changed files with 14 additions and 1 deletions
|
@ -566,7 +566,20 @@ void Object::InitNullAndBool(IsolateGroup* isolate_group) {
|
|||
heap->Allocate(thread, Instance::InstanceSize(), Heap::kOld);
|
||||
null_ = static_cast<InstancePtr>(address + kHeapObjectTag);
|
||||
// The call below is using 'null_' to initialize itself.
|
||||
InitializeObjectVariant<Instance>(address, kNullCid);
|
||||
//
|
||||
// TODO(52910): Change the below to
|
||||
// InitializeObjectVariant<Instance>(address, kNullCid);
|
||||
// after we've fixed the unboxing of the null object without checking for
|
||||
// null first when --no-sound-null-safety is on. (This is a stopgap so that
|
||||
// those bad unboxings pull out really large values that almost certainly
|
||||
// will fail, which was the old status quo.)
|
||||
const intptr_t ptr_field_end_offset =
|
||||
Instance::InstanceSize() - (Instance::ContainsCompressedPointers()
|
||||
? kCompressedWordSize
|
||||
: kWordSize);
|
||||
InitializeObject(address, kNullCid, Instance::InstanceSize(),
|
||||
Instance::ContainsCompressedPointers(),
|
||||
sizeof(UntaggedObject), ptr_field_end_offset);
|
||||
null_->untag()->SetCanonical();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue