Skip to content

Commit 27228de

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Fix crash when --heap_snapshot_on_oom triggers on the background compiler.
Remove use of Thread::Current()->isolate(). TEST=ci Change-Id: I991d4339cc81e11b42a691f3884eb0051c829d61 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446985 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 08964e2 commit 27228de

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

runtime/lib/developer.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ DEFINE_NATIVE_ENTRY(Developer_NativeRuntime_writeHeapSnapshotToFile, 0, 1) {
212212
String::CheckedHandle(zone, arguments->NativeArgAt(0));
213213
bool successful = false;
214214
{
215+
NoActiveIsolateScope no_active_isolate_scope(thread);
215216
FileHeapSnapshotWriter file_writer(thread, filename.ToCString(),
216217
&successful);
217218
HeapSnapshotWriter writer(thread, &file_writer);

runtime/vm/heap/heap.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ uword Heap::AllocateOld(Thread* thread, intptr_t size, bool is_exec) {
196196
if (FLAG_heap_snapshot_on_oom != nullptr) {
197197
bool successful = false;
198198
{
199+
NoActiveIsolateScope no_active_isolate_scope(thread);
199200
FileHeapSnapshotWriter file_writer(thread, FLAG_heap_snapshot_on_oom,
200201
&successful);
201202
HeapSnapshotWriter writer(thread, &file_writer);

runtime/vm/object_graph.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ void HeapSnapshotWriter::Write() {
15011501

15021502
WriteBytes("dartheap", 8); // Magic value.
15031503
WriteUnsigned(0); // Flags.
1504-
WriteUtf8(isolate()->name());
1504+
WriteUtf8(isolate_group()->source()->name);
15051505
Heap* H = thread()->heap();
15061506

15071507
{
@@ -1525,7 +1525,8 @@ void HeapSnapshotWriter::Write() {
15251525
Library& lib = Library::Handle();
15261526
String& str = String::Handle();
15271527

1528-
intptr_t field_table_size = isolate()->field_table()->NumFieldIds();
1528+
intptr_t field_table_size =
1529+
isolate_group()->initial_field_table()->NumFieldIds();
15291530
const char** field_table_names =
15301531
thread()->zone()->Alloc<const char*>(field_table_size);
15311532
for (intptr_t i = 0; i < field_table_size; i++) {
@@ -1707,7 +1708,7 @@ void HeapSnapshotWriter::Write() {
17071708
iteration.IterateObjects(&visitor);
17081709

17091710
// External properties.
1710-
isolate()->group()->VisitWeakPersistentHandles(&visitor);
1711+
isolate_group()->VisitWeakPersistentHandles(&visitor);
17111712

17121713
// Smis.
17131714
for (SmiPtr smi : smis_) {
@@ -1796,7 +1797,7 @@ void HeapSnapshotWriter::Write() {
17961797

17971798
// External properties.
17981799
WriteUnsigned(external_property_count_);
1799-
isolate()->group()->VisitWeakPersistentHandles(&visitor);
1800+
isolate_group()->VisitWeakPersistentHandles(&visitor);
18001801
}
18011802

18021803
{

0 commit comments

Comments
 (0)