Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vm/ffi] CFE crashes when compiling wrong Array annotation #46085

Closed
sgrekhov opened this issue May 20, 2021 · 1 comment
Closed

[vm/ffi] CFE crashes when compiling wrong Array annotation #46085

sgrekhov opened this issue May 20, 2021 · 1 comment
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi

Comments

@sgrekhov
Copy link
Contributor

The following test crashes CFE

import "dart:ffi";

class MyStruct extends Struct {
  @Array.multi([])
//^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
  external Array<Int16> a0;

  @Array.multi([1])
//^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
  external Array<Array<Int16>> a1;
}

void main() {
  MyStruct? ms = null;
}

Output is the following:

Crash when compiling null,
at character offset null:
RangeError (start): Invalid value: Only valid value is 0: 1
#0      RangeError.checkValidRange (dart:core/errors.dart:328:7)
#1      List.sublist (dart:core-patch/growable_array.dart:84:38)
#2      new ArrayNativeTypeCfe.multi (package:vm/transformations/ffi_definitions.dart:1299:58)
#3      new NativeTypeCfe (package:vm/transformations/ffi_definitions.dart:917:33)
#4      _FfiDefinitionTransformer._findFields (package:vm/transformations/ffi_definitions.dart:559:18)
#5      _FfiDefinitionTransformer.manualVisitInTopologicalOrder.<anonymous closure> (package:vm/transformations/ffi_definitions.dart:202:30)
#6      List.forEach (dart:core-patch/growable_array.dart:403:8)
#7      _FfiDefinitionTransformer.manualVisitInTopologicalOrder (package:vm/transformations/ffi_definitions.dart:172:25)
#8      transformLibraries (package:vm/transformations/ffi_definitions.dart:89:15)
#9      VmTarget.performModularTransformationsOnLibraries (package:vm/target/vm.dart:162:7)
#10     KernelTarget.runBuildTransformations (package:front_end/src/fasta/kernel/kernel_target.dart:1236:19)
#11     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:372:7)
<asynchronous suspension>
#12     withCrashReporting (package:front_end/src/fasta/crash.dart:121:12)
<asynchronous suspension>
#13     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:164:19)
<asynchronous suspension>
#14     withCrashReporting (package:front_end/src/fasta/crash.dart:121:12)
<asynchronous suspension>
#15     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:53:12)
<asynchronous suspension>
#16     generateKernel (package:front_end/src/kernel_generator_impl.dart:52:10)
<asynchronous suspension>
#17     kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:99:11)
<asynchronous suspension>
#18     SingleShotCompilerWrapper.compileInternal (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:404:11)
<asynchronous suspension>
#19     Compiler.compile.<anonymous closure> (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:218:45)
<asynchronous suspension>
#20     _processLoadRequest (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:885:37)
<asynchronous suspension>


#0      RangeError.checkValidRange (dart:core/errors.dart:328:7)
#1      List.sublist (dart:core-patch/growable_array.dart:84:38)
#2      new ArrayNativeTypeCfe.multi (package:vm/transformations/ffi_definitions.dart:1299:58)
#3      new NativeTypeCfe (package:vm/transformations/ffi_definitions.dart:917:33)
#4      _FfiDefinitionTransformer._findFields (package:vm/transformations/ffi_definitions.dart:559:18)
#5      _FfiDefinitionTransformer.manualVisitInTopologicalOrder.<anonymous closure> (package:vm/transformations/ffi_definitions.dart:202:30)
#6      List.forEach (dart:core-patch/growable_array.dart:403:8)
#7      _FfiDefinitionTransformer.manualVisitInTopologicalOrder (package:vm/transformations/ffi_definitions.dart:172:25)
#8      transformLibraries (package:vm/transformations/ffi_definitions.dart:89:15)
#9      VmTarget.performModularTransformationsOnLibraries (package:vm/target/vm.dart:162:7)
#10     KernelTarget.runBuildTransformations (package:front_end/src/fasta/kernel/kernel_target.dart:1236:19)
#11     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:372:7)
<asynchronous suspension>
#12     withCrashReporting (package:front_end/src/fasta/crash.dart:121:12)
<asynchronous suspension>
#13     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:164:19)
<asynchronous suspension>
#14     withCrashReporting (package:front_end/src/fasta/crash.dart:121:12)
<asynchronous suspension>
#15     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:53:12)
<asynchronous suspension>
#16     generateKernel (package:front_end/src/kernel_generator_impl.dart:52:10)
<asynchronous suspension>
#17     kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:99:11)
<asynchronous suspension>
#18     SingleShotCompilerWrapper.compileInternal (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:404:11)
<asynchronous suspension>
#19     Compiler.compile.<anonymous closure> (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:218:45)
<asynchronous suspension>
#20     _processLoadRequest (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:885:37)
<asynchronous suspension>

Tested on Dart SDK version: 2.14.0-edge.b9a0c0dfba993e726c36c255470af9868b65a6e5 (be) (Thu May 20 00:50:07 2021 +0000) on "linux_x64"

@sgrekhov sgrekhov added area-front-end Use area-front-end for front end / CFE / kernel format related issues. library-ffi crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. labels May 20, 2021
@johnniwinther
Copy link
Member

cc @dcharkes

@dcharkes dcharkes self-assigned this May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi
Projects
None yet
Development

No branches or pull requests

3 participants