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

the Dart compiler exited unexpectedly, if I place a breakpoint inside a certain function #53382

Closed
escamoteur opened this issue Aug 30, 2023 · 20 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on vm-debugger

Comments

@escamoteur
Copy link

Unhandled exception:
FormatException: Invalid radix-10 number (at character 1)
package:functional_listener/functional_listener.dart
functional_listener.dart:1
^

#0      int._handleFormatError (dart:core-patch/integers_patch.dart:126:5)
#1      int._parseRadix (dart:core-patch/integers_patch.dart:152:16)

#2      int._parse (dart:core-patch/integers_patch.dart:98:12)
#3      int.parse (dart:core-patch/integers_patch.dart:60:12)
#4      parseDefinitionTypes (package:front_end/src/api_prototype/expression_compilation_tools.dart:113:36)
#5      createDefinitionsWithTypes (package:front_end/src/api_prototype/expression_compilation_tools.dart:32:7)
#6      IncrementalCompiler.compileExpression (package:vm/incremental_compiler.dart:219:50)
#7      FrontendCompiler.compileExpression (package:frontend_server/frontend_server.dart:981:45)
#8      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1452:26)
#9      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#10     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#11     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#12     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#13     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#14     _StringAdapterSink.add (dart:convert/string_conversion.dart:228:11)
#15     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:164:13)
#16     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:131:7)
#17     StringConversionSink.add (dart:convert/string_conversion.dart:39:5)

It only happens when I set a breakpoint inside

image

if I remove the breakpoint the app doesn't crash.
I also have no idea where I should do an int.parse to get such an exception. also thee reported file as place where it happens doesn't make sense as the listen function only looks like this

  ListenableSubscription listen(
    void Function(T, ListenableSubscription) handler,
  ) {
    final subscription = ListenableSubscription(this);
    subscription.handler = () => handler(this.value, subscription);
    this.addListener(subscription.handler);
    return subscription;
  }

happens on: Flutter (Channel stable, 3.13.1, on Microsoft Windows [Version 10.0.19045.3324], locale de-DE)

@a-siva a-siva added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-debugger labels Aug 30, 2023
@a-siva a-siva added the P2 A bug or feature request we're likely to work on label Aug 30, 2023
@derekxu16
Copy link
Member

derekxu16 commented Aug 31, 2023

I created a Flutter app and made the contents of lib/main.dart the following:

import 'package:flutter/material.dart';
import 'package:functional_listener/functional_listener.dart';

class C {
  Object error = 123;
}

void main() {
  final listenable1 = ValueNotifier<C?>(C());
  final listenable2 = ValueNotifier<C>(C());

  final mergedListenable = listenable1.mergeWith([
    listenable2,
  ]);
  final subscription = mergedListenable.listen((x, _) {
    final apiException = x?.error;
    print(apiException);
  });

  listenable1.value = C();

  subscription.cancel();
}

I was able to set a breakpoint on the final apiException = x?.error; line without any problems. I tested on Linux and not Windows though. It would take me a while to get my Windows environment back up-to-date. So first, can you please try this example on Windows? If it works without issue, can you please try writing a minimal reproduction example? It will be hard to fix this bug without one. Thanks!

@escamoteur
Copy link
Author

unfortunately I couldn't reproduce it with the example from you. I can still reproduce it in our real app project. Still wondering why it crashes in

#0 int._handleFormatError (dart:core-patch/integers_patch.dart:126:5)

and the stack trace seems to have no connection to my code whatsoever.

Is there anything that I can add to my code to get more details?
Because I have no idea how to reproduce this in a smaller demo project?

@derekxu16
Copy link
Member

Since you're using VSCode, can you please follow these instructions and paste the contents of the log here?

@escamoteur
Copy link
Author

dart.log

@derekxu16
Copy link
Member

Looks like Dart Code is trying to get the value of di, which is making the compiler crash. Is di from a public package or is it something you wrote yourself? And is di the name of a function or the name of a class here?

@escamoteur
Copy link
Author

di is a global variable defined in my package watch_it

@escamoteur
Copy link
Author

escamoteur commented Sep 1, 2023

oh, and its a callable class

@mraleph
Copy link
Member

mraleph commented Sep 8, 2023

/cc @johnniwinther @jensjoha - seems to be related to the expression evaluation.

@mraleph mraleph added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Sep 8, 2023
@johnniwinther
Copy link
Member

This might be related to #53453 where the crash also originates from FrontEndCompiler.compileExpression where an invalid definitionTypes value can cause the crash.

@derekxu16 @mraleph Do you know where these values are created?

@johnniwinther
Copy link
Member

@aam Do you know where calls to compileExpression comes from when called through Flutter?

I can see the change that added the definitionTypes argument (flutter/flutter@09c0706) but I cannot see any call-site changes other than in tests.

@aam
Copy link
Contributor

aam commented Sep 11, 2023

@johnniwinther wrote

@aam Do you know where calls to compileExpression comes from when called through Flutter?

I can see the change that added the definitionTypes argument (flutter/flutter@09c0706) but I cannot see any call-site changes other than in tests.

Flutter registers compileExpression service https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/vmservice.dart#L260, which is invoked by dart vm in https://github.com/dart-lang/sdk/blob/main/sdk/lib/vmservice/running_isolates.dart#L148, which runs when evaluate or evaluateInFrame service requests were made.

@derekxu16
Copy link
Member

@johnniwinther do you suspect that your fix for #53453 also fixes this issue?

@johnniwinther
Copy link
Member

Yes.

@derekxu16
Copy link
Member

@escamoteur if you try switching to the master channel with flutter channel master (https://docs.flutter.dev/release/upgrade#changing-channels), you should not see the same compiler crash anymore. Please let us know if you do.

@escamoteur
Copy link
Author

A bit busy at the moment will try today or tomorrow

@escamoteur
Copy link
Author

I would really love to but I get suddenly this errors if I switch to master channel

PS C:\Entwicklung\projects\watchcrunch-mobile-v2> flutter run
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.6.0/lib/src/internal/image_provider.dart:61:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.6.0/lib/src/internal/image_provider.dart:86:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.6.0/lib/src/internal/image_provider.dart:61:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.6.0/lib/src/internal/image_provider.dart:86:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image-3.2.3/lib/src/image_provider/cached_network_image_provider.dart:78:54: Error: Type 'DecoderCallback' not found.
      image_provider.CachedNetworkImageProvider key, DecoderCallback decode) {
                                                     ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image-3.2.3/lib/src/image_provider/cached_network_image_provider.dart:99:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode,
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image-3.2.3/lib/src/image_provider/cached_network_image_provider.dart:78:54: Error: 'DecoderCallback' isn't a type.
      image_provider.CachedNetworkImageProvider key, DecoderCallback decode) {
                                                     ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image-3.2.3/lib/src/image_provider/cached_network_image_provider.dart:99:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode,
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image-3.2.3/lib/src/image_provider/_image_loader.dart:25:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode,
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image-3.2.3/lib/src/image_provider/_image_loader.dart:25:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode,
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image_platform_interface-2.0.0/lib/cached_network_image_platform_interface.dart:29:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode,
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/cached_network_image_platform_interface-2.0.0/lib/cached_network_image_platform_interface.dart:29:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode,
    ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib/src/blurhash_image.dart:32:48: Error: Type 'DecoderCallback' not found.
  ImageStreamCompleter load(BlurHashImage key, DecoderCallback decode) => OneFrameImageStreamCompleter(_loadAsync(key));
                                               ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib/src/blurhash_image.dart:32:48: Error: 'DecoderCallback' isn't a type.
  ImageStreamCompleter load(BlurHashImage key, DecoderCallback decode) => OneFrameImageStreamCompleter(_loadAsync(key));
                                               ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib/src/blurhash_widget.dart:218:42: Error: Type 'DecoderCallback' not found.
  ImageStreamCompleter load(UiImage key, DecoderCallback decode) => OneFrameImageStreamCompleter(_loadAsync(key));
                                         ^^^^^^^^^^^^^^^
/C:/Users/escam/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib/src/blurhash_widget.dart:218:42: Error: 'DecoderCallback' isn't a type.
  ImageStreamCompleter load(UiImage key, DecoderCallback decode) => OneFrameImageStreamCompleter(_loadAsync(key));
                                         ^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script 'C:\Users\escam\fvm\versions\3.13.4\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1343

* What went wrong:
Execution failed for task ':app:compileFlutterBuildProductionDebug'.
> Process 'command 'C:\Users\escam\fvm\versions\3.13.4\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
Running Gradle task 'assembleDebug'...                              6,5s
Exception: Gradle task assembleDebug failed with exit code 1
PS

@johnniwinther
Copy link
Member

@derekxu16 Can we close this, given your verification of the fix for the similar error in #53637 ?

@derekxu16
Copy link
Member

@derekxu16 Can we close this, given your verification of the fix for the similar error in #53637 ?

SGTM

@honeybansal2968

This comment was marked as off-topic.

@mraleph

This comment was marked as off-topic.

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. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on vm-debugger
Projects
None yet
Development

No branches or pull requests

8 participants
@mraleph @aam @derekxu16 @a-siva @johnniwinther @escamoteur @honeybansal2968 and others