Skip to content

Extension type with a factory constructor crashes CFE #53140

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

Closed
sgrekhov opened this issue Aug 7, 2023 · 3 comments
Closed

Extension type with a factory constructor crashes CFE #53140

sgrekhov opened this issue Aug 7, 2023 · 3 comments
Labels
cfe-feature-extension-types Implement extension types feature in the CFE crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. feature-extension-types Implementation of the extension type feature legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Aug 7, 2023

The followig code crashes the compiler

extension type ET2<T>(T id) {
  factory ET2.f(T id) = ET2.new;
}

main() {
}

Output is

dart-sdk/sdk/out/ReleaseX64/dart-sdk/bin/dart --enable-experiment=inline-class --enable-asserts test.dart

Crash when compiling:
type 'Null' is not a subtype of type 'SourceClassBuilder' in type cast

#0      SourceFactoryBuilder.classBuilder (package:front_end/src/fasta/source/source_factory_builder.dart:114:26)
#1      RedirectingFactoryBuilder.buildOutlineExpressions (package:front_end/src/fasta/source/source_factory_builder.dart:492:24)
#2      SourceExtensionTypeDeclarationBuilder.buildOutlineExpressions (package:front_end/src/fasta/source/source_extension_type_declaration_builder.dart:394:24)
#3      SourceLibraryBuilder.buildOutlineExpressions (package:front_end/src/fasta/source/source_library_builder.dart:3549:21)
#4      SourceLoader.buildOutlineExpressions (package:front_end/src/fasta/source/source_loader.dart:2807:15)
#5      KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:525:14)
<asynchronous suspension>
#6      withCrashReporting (package:front_end/src/fasta/crash.dart:133:12)
<asynchronous suspension>
#7      KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:388:12)
<asynchronous suspension>
#8      _buildInternal (package:front_end/src/kernel_generator_impl.dart:144:7)
<asynchronous suspension>
#9      withCrashReporting (package:front_end/src/fasta/crash.dart:133:12)
<asynchronous suspension>
#10     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:49:12)
<asynchronous suspension>
#11     CompilerContext.clear (package:front_end/src/fasta/compiler_context.dart:139:3)
<asynchronous suspension>
#12     generateKernel (package:front_end/src/kernel_generator_impl.dart:48:10)
<asynchronous suspension>
#13     kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#14     SingleShotCompilerWrapper.compileInternal (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:414:11)
<asynchronous suspension>
#15     Compiler.compile.<anonymous closure> (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:220:45)
<asynchronous suspension>
#16     _processLoadRequest (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/vm/bin/kernel_service.dart:897:37)
<asynchronous suspension>


Process finished with exit code 252

Tested on the edge SDK (built on Aug 7, 2023) on Linux x64

@sgrekhov sgrekhov added legacy-area-front-end Legacy: Use area-dart-model instead. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. labels Aug 7, 2023
@johnniwinther johnniwinther added the feature-extension-types Implementation of the extension type feature label Sep 28, 2023
@johnniwinther johnniwinther added the cfe-feature-extension-types Implement extension types feature in the CFE label Oct 13, 2023
@chloestefantsova
Copy link
Contributor

This appears to be fixed at the top of the branch. Please reopen if needed.

@sgrekhov
Copy link
Contributor Author

Please try to run the following test (tested on Dart SDK version: 3.3.0-edge.4d1bdaaca9f600545e8517349714f6bf683ebbe3 (be) (Tue Oct 17 07:41:49 2023 +0000) on "linux_x64")

sgrekhov@SGREKHOV-HP:~/Google/dart-sdk/sdk$ python3 tools/test.py -n cfe-strong-linux co19/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06
No build targets found.
Test configuration:
    cfe-strong-linux(architecture: x64, compiler: fasta, mode: release, runtime: none, system: linux)
Suites tested: co19

FAILED: fasta-none release_x64 co19/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06
Expected: Pass
Actual: Crash

--- Command "fasta" (took 15.000371s):
(cd /home/sgrekhov/Google/dart-sdk/sdk/ ; DART_CONFIGURATION=ReleaseX64 ./out/ReleaseX64/dart ./pkg/front_end/tool/_fasta/compile.dart --verify --skip-platform-verification -o ./out/ReleaseX64/generated_compilations/cfe-strong-linux/tests_co19_src_LanguageFeatures_Extension-types_static_analysis_extension_types_A21_t06/out.dill --platform ./out/ReleaseX64/vm_platform_strong.dill -Dtest_runner.configuration=cfe-strong-linux --enable-experiment=inline-class --nnbd-strong --packages=./.dart_tool/package_config.json ./tests/co19/src/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06.dart )

exit code:
253

stdout:
tests/co19/src/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06.dart:26:16: Error: Verification of the generated program failed:
Target=vm, VerificationStage.afterModularTransformations: StaticInvocation with incompatible arguments for 'ET1|constructor#c'.
  factory ET1.f(int id) = ET1.c;
               ^
tests/co19/src/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06.dart:26:11: Error: Verification of the generated program failed:
Target=vm, VerificationStage.afterModularTransformations: StaticInvocation with incompatible arguments for 'ET1|constructor#c'.
  factory ET1.f(int id) = ET1.c;
          ^
tests/co19/src/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06.dart:34:16: Error: Verification of the generated program failed:
Target=vm, VerificationStage.afterModularTransformations: StaticInvocation with incompatible arguments for 'ET2|constructor#n'.
  factory ET2.f(int id) = ET2.n;
               ^
tests/co19/src/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06.dart:34:11: Error: Verification of the generated program failed:
Target=vm, VerificationStage.afterModularTransformations: StaticInvocation with incompatible arguments for 'ET2|constructor#n'.
  factory ET2.f(int id) = ET2.n;
          ^

stderr:
Unhandled exception:
  Crash when compiling:
'package:front_end/src/fasta/kernel/kernel_target.dart': Failed assertion: line 1623 pos 12: 'allowVerificationErrorForTesting || errors.isEmpty': Verification errors found.

#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      KernelTarget._verify (package:front_end/src/fasta/kernel/kernel_target.dart:1623:12)
#3      KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:634:9)
<asynchronous suspension>
#4      withCrashReporting (package:front_end/src/fasta/crash.dart:133:12)
<asynchronous suspension>
#5      KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:575:12)
<asynchronous suspension>
#6      CompileTask.compile (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:436:19)
<asynchronous suspension>
#7      BatchCompiler.batchCompileImpl (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:221:5)
<asynchronous suspension>
#8      CompilerContext.clear (package:front_end/src/fasta/compiler_context.dart:139:3)
<asynchronous suspension>
#9      runProtectedFromAbort (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/front_end/tool/_fasta/command_line.dart:416:12)
<asynchronous suspension>
#10     BatchCompiler.run (file:///home/sgrekhov/Google/dart-sdk/sdk/pkg/front_end/tool/_fasta/entry_points.dart:173:13)
<asynchronous suspension>

--- Re-run this test:
python3 tools/test.py -n cfe-strong-linux co19/LanguageFeatures/Extension-types/static_analysis_extension_types_A21_t06
[00:15 | 100% | +    0 | -    1]

=== 0 tests passed, 1 failed ===

@sgrekhov sgrekhov reopened this Oct 17, 2023
@chloestefantsova
Copy link
Contributor

Please try to run the following test

This one seem to be already tracked in #53232. I'm closing #53232 as the duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cfe-feature-extension-types Implement extension types feature in the CFE crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. feature-extension-types Implementation of the extension type feature legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

3 participants