Skip to content

Commit

Permalink
[CFE] Incremental compiler + FFI crash reproduction
Browse files Browse the repository at this point in the history
Run like
```
out/ReleaseX64/dart --enable-asserts pkg/front_end/test/incremental_suite.dart -DupdateExpectations=true -- incremental/crash_05
```

Crashes like this:
```
NoSuchMethodError: The getter 'iterator' was called on null.
Receiver: null
Tried calling: iterator
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      computeStrongComponents.recursivelySearch (package:kernel/util/graph.dart:36:30)
#2      computeStrongComponents.recursivelySearch (package:kernel/util/graph.dart:41:26)
#3      computeStrongComponents (package:kernel/util/graph.dart:74:24)
#4      _FfiDefinitionTransformer.manualVisitInTopologicalOrder (package:vm/transformations/ffi_definitions.dart:131:33)
#5      transformLibraries (package:vm/transformations/ffi_definitions.dart:89:15)
#6      VmTarget.performModularTransformationsOnLibraries (package:vm/target/vm.dart:162:34)
#7      KernelTarget.runBuildTransformations (package:front_end/src/fasta/kernel/kernel_target.dart:1236:19)
#8      KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:372:7)
```

Run like
```
out/ReleaseX64/dart --enable-asserts pkg/front_end/test/incremental_suite.dart -DupdateExpectations=true -- incremental/crash_06
```

Crashes like this:
```
Class((whatnot)) not found in compoundCache
#0      new NativeTypeCfe (package:vm/transformations/ffi_definitions.dart:775:9)
#1      _FfiDefinitionTransformer._replaceFields (package:vm/transformations/ffi_definitions.dart:494:16)
#2      _FfiDefinitionTransformer.visitClassInTopologicalOrder (package:vm/transformations/ffi_definitions.dart:198:28)
#3      _FfiDefinitionTransformer.manualVisitInTopologicalOrder.<anonymous closure> (package:vm/transformations/ffi_definitions.dart:158:9)
#4      List.forEach (dart:core-patch/growable_array.dart:403:8)
#5      _FfiDefinitionTransformer.manualVisitInTopologicalOrder (package:vm/transformations/ffi_definitions.dart:134:25)
#6      transformLibraries (package:vm/transformations/ffi_definitions.dart:89:15)
#7      VmTarget.performModularTransformationsOnLibraries (package:vm/target/vm.dart:162:34)
```

Bug: #45899

Change-Id: I9d42ed16577a79c80f1c3bd77ee82a135d4e107c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197740
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
  • Loading branch information
jensjoha authored and commit-bot@chromium.org committed May 4, 2021
1 parent 00e5e38 commit 107ed1c
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/front_end/testcases/incremental.status
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@

# http://dartbug.com/41812#issuecomment-684825703
strongmode_mixins_2: Crash

# http://dartbug.com/45899
crash_05: Crash
crash_06: Crash
33 changes: 33 additions & 0 deletions pkg/front_end/testcases/incremental/crash_05.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE.md file.

# Reproduce a crash.

type: newworld
worlds:
- entry: main.dart
experiments: non-nullable
sources:
main.dart: |
import 'dart:ffi';
import 'lib.dart';
class X extends Struct {
external Y xx;
}
lib.dart: |
import 'dart:ffi';
class Y extends Struct {
@Uint32()
external int yy;
}
expectedLibraryCount: 2

- entry: main.dart
experiments: non-nullable
worldType: updated
expectInitializeFromDill: false
invalidate:
- main.dart
expectedLibraryCount: 2
expectsRebuildBodiesOnly: true
62 changes: 62 additions & 0 deletions pkg/front_end/testcases/incremental/crash_05.yaml.world.1.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
main = <No Member>;
library from "org-dartlang-test:///lib.dart" as lib {

import "dart:ffi";

@#C6
class Y extends dart.ffi::Struct {
static final field dart.core::int* #sizeOf = (#C8).{dart.core::List::[]}(dart.ffi::_abi())/*isLegacy*/;
synthetic constructor •() → lib::Y
: super dart.ffi::Struct::•()
;
constructor #fromTypedDataBase(dart.core::Object #typedDataBase) → lib::Y
: super dart.ffi::Struct::_fromTypedDataBase(#typedDataBase)
;
@#C9
get yy() → dart.core::int
return dart.ffi::_loadUint32(this.{dart.ffi::_Compound::_typedDataBase}, (#C11).{dart.core::List::[]}(dart.ffi::_abi()));
@#C9
set yy(dart.core::int #externalFieldValue) → void
return dart.ffi::_storeUint32(this.{dart.ffi::_Compound::_typedDataBase}, (#C11).{dart.core::List::[]}(dart.ffi::_abi()), #externalFieldValue);
}
}
library from "org-dartlang-test:///main.dart" as main {

import "dart:ffi";
import "org-dartlang-test:///lib.dart";

@#C15
class X extends dart.ffi::Struct {
static final field dart.core::int* #sizeOf = (#C8).{dart.core::List::[]}(dart.ffi::_abi())/*isLegacy*/;
synthetic constructor •() → main::X
: super dart.ffi::Struct::•()
;
constructor #fromTypedDataBase(dart.core::Object #typedDataBase) → main::X
: super dart.ffi::Struct::_fromTypedDataBase(#typedDataBase)
;
get xx() → lib::Y
return new lib::Y::#fromTypedDataBase( block {
dart.core::Object #typedDataBase = this.{dart.ffi::_Compound::_typedDataBase};
dart.core::int #offset = (#C11).{dart.core::List::[]}(dart.ffi::_abi());
} =>#typedDataBase is dart.ffi::Pointer<dynamic> ?{dart.core::Object} dart.ffi::_fromAddress<lib::Y>(#typedDataBase.{dart.ffi::Pointer::address}.{dart.core::num::+}(#offset)) : let dart.typed_data::TypedData #typedData = dart._internal::unsafeCast<dart.typed_data::TypedData>(#typedDataBase) in #typedData.{dart.typed_data::TypedData::buffer}.{dart.typed_data::ByteBuffer::asUint8List}(#typedData.{dart.typed_data::TypedData::offsetInBytes}.{dart.core::num::+}(#offset), (#C8).{dart.core::List::[]}(dart.ffi::_abi())));
set xx(lib::Y #externalFieldValue) → void
return dart.ffi::_memCopy(this.{dart.ffi::_Compound::_typedDataBase}, (#C11).{dart.core::List::[]}(dart.ffi::_abi()), #externalFieldValue.{dart.ffi::_Compound::_typedDataBase}, #C10, (#C8).{dart.core::List::[]}(dart.ffi::_abi()));
}
}
constants {
#C1 = "vm:ffi:struct-fields"
#C2 = TypeLiteralConstant(dart.ffi::Uint32)
#C3 = <dart.core::Type>[#C2]
#C4 = null
#C5 = dart.ffi::_FfiStructLayout {fieldTypes:#C3, packing:#C4}
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = 4
#C8 = <dart.core::int*>[#C7, #C7, #C7]
#C9 = dart.ffi::Uint32 {}
#C10 = 0
#C11 = <dart.core::int*>[#C10, #C10, #C10]
#C12 = TypeLiteralConstant(lib::Y)
#C13 = <dart.core::Type>[#C12]
#C14 = dart.ffi::_FfiStructLayout {fieldTypes:#C13, packing:#C4}
#C15 = dart.core::pragma {name:#C1, options:#C14}
}
30 changes: 30 additions & 0 deletions pkg/front_end/testcases/incremental/crash_06.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE.md file.

# Reproduce a crash.

type: newworld
worlds:
- entry: structs.dart
experiments: non-nullable
sources:
structs.dart: |
import 'dart:ffi';
class A extends Struct {
external Y yy;
}
class Y extends Struct {
external Z zz;
}
expectedLibraryCount: 1

- entry: structs.dart
experiments: non-nullable
worldType: updated
expectInitializeFromDill: false
invalidate:
- structs.dart
expectedLibraryCount: 1
expectsRebuildBodiesOnly: true

0 comments on commit 107ed1c

Please sign in to comment.