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

AOT compilation failed: Invalid argument(s): Missing canonical name for Reference #47878

Closed
xvrh opened this issue Dec 9, 2021 · 2 comments
Closed
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-kernel

Comments

@xvrh
Copy link
Contributor

xvrh commented Dec 9, 2021

Here is a stripped down version of a compiler error that appear when upgrading to Flutter 2.8 (Dart 2.15.0).
Dart SDK version: 2.15.0 (stable) (Fri Dec 3 14:23:23 2021 +0100) on "macos_x64"

I can reproduce it with dart compile so I open the bug in this repository.

dart compile exe -o output canonical_name_bug.dart

import 'dart:async';
import 'package:rxdart/rxdart.dart';

void main() {
  DataStream<A>(loader: () async => A());
}

abstract class Disposable {
  void dispose();
}

class A {}

class Data<T> {
  final T? value;
  final Object? error;

  const Data({this.value, this.error, bool? isLoading});
}

class _Event<T> {
  final completer = Completer<Data<T>>();
}

class DataStream<T> {
  final _stream = BehaviorSubject<Data<T>>();
  final _events = StreamController<_Event<T>>();
  final Future<T> Function() loader;

  DataStream({
    required this.loader,
  }) {
    _events.stream.asyncExpand(_expand).listen((data) {
      var lastValue = _stream.value.value;
      var newValue = data.value;

      if (lastValue != null &&
          lastValue is Disposable &&
          lastValue != newValue) {
        lastValue.dispose();
      }
    });
  }

  Stream<Data<T>> _expand(_Event<T> event) async* {
    var result = await loader();
    yield Data(value: result);
  }
}

Compiler output:

Invalid argument(s): Missing canonical name for Reference to Disposable
#0      BinaryPrinter.writeNonNullReference (package:kernel/binary/ast_to_binary.dart:941:9)
#1      BinaryPrinter.visitInterfaceType (package:kernel/binary/ast_to_binary.dart:2325:7)
#2      InterfaceType.accept (package:kernel/ast.dart:11111:42)
#3      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#4      BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:522:7)
#5      BinaryPrinter.visitTypeParameterType (package:kernel/binary/ast_to_binary.dart:2433:5)
#6      TypeParameterType.accept (package:kernel/ast.dart:11884:42)
#7      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#8      BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:522:7)
#9      BinaryPrinter.visitVariableGet (package:kernel/binary/ast_to_binary.dart:1514:7)
#10     VariableGet.accept (package:kernel/ast.dart:4142:44)
#11     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#12     BinaryPrinter.visitEqualsCall (package:kernel/binary/ast_to_binary.dart:1664:5)
#13     EqualsCall.accept (package:kernel/ast.dart:6094:44)
#14     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#15     BinaryPrinter.visitNot (package:kernel/binary/ast_to_binary.dart:1770:5)
#16     Not.accept (package:kernel/ast.dart:6534:44)
#17     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#18     BinaryPrinter.visitLogicalExpression (package:kernel/binary/ast_to_binary.dart:1794:5)
#19     LogicalExpression.accept (package:kernel/ast.dart:6606:44)
#20     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#21     BinaryPrinter.visitIfStatement (package:kernel/binary/ast_to_binary.dart:2201:5)
#22     IfStatement.accept (package:kernel/ast.dart:9794:43)
#23     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#24     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:340:7)
#25     BinaryPrinter.visitBlock (package:kernel/binary/ast_to_binary.dart:2069:5)
#26     Block.accept (package:kernel/ast.dart:8890:43)
#27     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#28     BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:522:7)
#29     BinaryPrinter.visitFunctionNode (package:kernel/binary/ast_to_binary.dart:1487:5)
#30     FunctionNode.accept (package:kernel/ast.dart:3851:38)
#31     BinaryPrinter.writeFunctionNode (package:kernel/binary/ast_to_binary.dart:437:10)
#32     BinaryPrinter.visitFunctionExpression (package:kernel/binary/ast_to_binary.dart:2002:5)
#33     FunctionExpression.accept (package:kernel/ast.dart:8284:44)
#34     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#35     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:340:7)
#36     BinaryPrinter.visitArguments (package:kernel/binary/ast_to_binary.dart:1757:5)
#37     Arguments.accept (package:kernel/ast.dart:5124:38)
#38     BinaryPrinter.writeArgumentsNode (package:kernel/binary/ast_to_binary.dart:444:10)
#39     BinaryPrinter.visitInstanceInvocation (package:kernel/binary/ast_to_binary.dart:1696:5)
#40     InstanceInvocation.accept (package:kernel/ast.dart:5505:44)
#41     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#42     BinaryPrinter.visitExpressionStatement (package:kernel/binary/ast_to_binary.dart:2058:5)
#43     ExpressionStatement.accept (package:kernel/ast.dart:8834:43)
#44     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#45     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:340:7)
#46     BinaryPrinter.visitBlock (package:kernel/binary/ast_to_binary.dart:2069:5)
#47     Block.accept (package:kernel/ast.dart:8890:43)
#48     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#49     BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:522:7)
#50     BinaryPrinter.visitFunctionNode (package:kernel/binary/ast_to_binary.dart:1487:5)
#51     FunctionNode.accept (package:kernel/ast.dart:3851:38)
#52     BinaryPrinter.writeFunctionNode (package:kernel/binary/ast_to_binary.dart:437:10)
#53     BinaryPrinter.visitConstructor (package:kernel/binary/ast_to_binary.dart:1254:5)
#54     Constructor.accept (package:kernel/ast.dart:2472:40)
#55     BinaryPrinter.writeConstructorNode (package:kernel/binary/ast_to_binary.dart:486:10)
#56     BinaryPrinter.writeConstructorNodeList (package:kernel/binary/ast_to_binary.dart:385:7)
#57     BinaryPrinter.visitClass (package:kernel/binary/ast_to_binary.dart:1220:5)
#58     Class.accept (package:kernel/ast.dart:1417:38)
#59     BinaryPrinter.writeClassNode (package:kernel/binary/ast_to_binary.dart:472:10)
#60     BinaryPrinter.writeClassNodeList (package:kernel/binary/ast_to_binary.dart:367:7)
#61     BinaryPrinter.visitLibrary (package:kernel/binary/ast_to_binary.dart:1058:5)
#62     Library.accept (package:kernel/ast.dart:557:38)
#63     BinaryPrinter.writeLibraryNode (package:kernel/binary/ast_to_binary.dart:451:10)
#64     BinaryPrinter.writeLibraries (package:kernel/binary/ast_to_binary.dart:756:9)
#65     BinaryPrinter.writeComponentFile.<anonymous closure> (package:kernel/binary/ast_to_binary.dart:595:7)
#66     Timeline.timeSync (dart:developer/timeline.dart:163:22)
#67     BinaryPrinter.writeComponentFile (package:kernel/binary/ast_to_binary.dart:577:14)
#68     runCompiler (package:vm/kernel_front_end.dart:289:11)
<asynchronous suspension>
#69     main (file:///opt/s/w/ir/cache/builder/sdk/pkg/vm/bin/gen_kernel.dart:34:19)
<asynchronous suspension>
Error: AOT compilation failed
Generating AOT kernel dill failed!

It seems this is because I have an is on an abstract class that is not extended anywhere.

@mraleph
Copy link
Member

mraleph commented Dec 9, 2021

/cc @alexmarkov

@lrhn lrhn added area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-kernel labels Dec 9, 2021
@alexmarkov alexmarkov self-assigned this Dec 9, 2021
@a-siva
Copy link
Contributor

a-siva commented Dec 13, 2021

fix for this is a potential candidate for cherry pick into 2.16 beta 1

copybara-service bot pushed a commit that referenced this issue Dec 14, 2021
If tree shaker doesn't visit TypeParameterType.promotedBound which
contains the only reference to a particular class it may remove that
class, leaving a dangling reference from promotedBound. After that
kernel AST serialization would crash with "Missing canonical name for
Reference" error.

This change also fixes TypeParameterType.visitChildren.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_47878.dart
Fixes #47878

Change-Id: I555261713240bf0be412db27efb68f32cfd8008b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222781
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Alexander Markov <[email protected]>
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. front-end-kernel
Projects
None yet
Development

No branches or pull requests

5 participants