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

Windows app crashes when using .ceil() after update #138693

Closed
kirill-21 opened this issue Nov 19, 2023 · 50 comments
Closed

Windows app crashes when using .ceil() after update #138693

kirill-21 opened this issue Nov 19, 2023 · 50 comments
Labels
a: desktop Running on desktop c: fatal crash Crashes that terminate the process dependency: dart Dart team may need to help us dependency:dart-triaged Triaged by Dart team e: device-specific Only manifests on certain devices P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically r: fixed Issue is closed as already fixed in a newer version team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team

Comments

@kirill-21
Copy link

kirill-21 commented Nov 19, 2023

AnyDesk_as9FKEfHIi.mp4
  int _scale(double source, double factor) {
    MessageBox(0, TEXT("CALLED!"), TEXT("TEST"), MB_OK);
    MessageBox(0, TEXT("No ceil: ${source * factor}!"), TEXT("TEST"), MB_OK);
    return (source * factor).ceil();
  }
  
  
  MessageBox(0, TEXT("sf: $scaleFactor"), TEXT("TEST"), MB_OK);
  MessageBox(0, TEXT("sc: $scale"), TEXT("TEST"), MB_OK);
  MessageBox(0, TEXT("width: ${appWindowSize.width}"), TEXT("TEST"), MB_OK);
  MessageBox(0, TEXT("height: ${appWindowSize.height}"), TEXT("TEST"), MB_OK);

  // Calculate the approptiate size of the window
  int normalWidth = 0;
  int normalHeight = 0;
  try {
     normalWidth = _scale(appWindowSize.width, scaleFactor * scale);
     MessageBox(0, TEXT("1dwada"), TEXT("TEST"), MB_OK);
     normalHeight = _scale(appWindowSize.height, scaleFactor * scale);
  } catch (_) {
    MessageBox(0, TEXT("$_"), TEXT("ERROR"), MB_OK);
  }

This started to happen since the latest Flutter 3.16.0 update.

If i remove .ceil(), there will be no crash, for some reason this happens not on all computers, but many users report to me that app is simply not launched because of this error. As soon as i change .ceil() to .toInt() problem disappears

PlatformDispatcher.instance.onError, try catch, FlutterError.onError, runZonedGuarded do not catch any errors

@kirill-21
Copy link
Author

Here is the winver data of user who faced this issue
image
image

@kirill-21
Copy link
Author

I also tested this on the master channel and it is ### not fixed there

@kirill-21
Copy link
Author

kirill-21 commented Nov 19, 2023

I also tested the launch of Flutter Counter example app and it crashes too, i can see it for a few seconds in task manager and then it crashes (on the same PC as the .ceil() crash problem), maybe this problem is somewhere deeper since even when you stop using .ceil() method, app crashes after the initialization

enGqiaO8QP.mp4
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          //
          // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
          // action in the IDE, or press "p" in the console), to see the
          // wireframe for each widget.
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

@huycozy huycozy added the in triage Presently being triaged by the triage team label Nov 20, 2023
@huycozy
Copy link
Member

huycozy commented Nov 20, 2023

I also tried building the simple Flutter app (counter app) on the latest Flutter stable release but can't see the issue.

flutter doctor -v (stable & master)
[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.19045.3570], locale en-US)
    • Flutter version 3.16.0 on channel stable at C:\WIP\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (5 hours ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\AndroidSDK
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = C:\AndroidSDK
    • Java binary at: C:\Program Files\Android\Android Studio Electric Eel 2022.1.1\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.4)
    • Visual Studio at D:\DOWNLOADWORK\VS2022
    • Visual Studio Community 2022 version 17.4.33213.308
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio Electric Eel 2022.1.1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.84.2)
    • VS Code at C:\Users\ADMIN\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.76.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.3570]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 119.0.6045.124
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 119.0.2151.58

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
[!] Flutter (Channel master, 3.17.0-10.0.pre.20, on Microsoft Windows [Version 10.0.19045.3570], locale en-US)
    • Flutter version 3.17.0-10.0.pre.20 on channel master at C:\WIP\flutter_master
    ! Warning: `flutter` on your path resolves to C:\WIP\flutter\bin\flutter, which is not inside your current
      Flutter SDK checkout at C:\WIP\flutter_master. Consider adding C:\WIP\flutter_master\bin to the front of your
      path.
    ! Warning: `dart` on your path resolves to C:\WIP\flutter\bin\dart, which is not inside your current Flutter SDK
      checkout at C:\WIP\flutter_master. Consider adding C:\WIP\flutter_master\bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9baa539251 (44 minutes ago), 2023-11-16 02:12:27 -0500
    • Engine revision 3cfcdebe86
    • Dart version 3.3.0 (build 3.3.0-135.0.dev)
    • DevTools version 2.30.0-dev.4
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git"
      directly to perform update checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\AndroidSDK
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = C:\AndroidSDK
    • Java binary at: C:\Program Files\Android\Android Studio Electric Eel 2022.1.1\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.4)
    • Visual Studio at D:\DOWNLOADWORK\VS2022
    • Visual Studio Community 2022 version 17.4.33213.308
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio Electric Eel 2022.1.1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.84.2)
    • VS Code at C:\Users\ADMIN\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.76.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.3570]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 119.0.6045.124
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 119.0.2151.58

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

I don't see you use .ceil() in the sample code, could you complete it and share again?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 20, 2023
@kirill-21
Copy link
Author

I also tried building the simple Flutter app (counter app) on the latest Flutter stable release but can't see the issue.

flutter doctor -v (stable & master)
I don't see you use .ceil() in the sample code, could you complete it and share again?

I also do not see the issue on my pc, but some users have this problem, how can i debug this?

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 20, 2023
@kirill-21
Copy link
Author

I also tried building the simple Flutter app (counter app) on the latest Flutter stable release but can't see the issue.

flutter doctor -v (stable & master)
I don't see you use .ceil() in the sample code, could you complete it and share again?

The .ceil() problem is in the first(initial) comment in the issue, the flutter sample app crash is the second problem

@huycozy
Copy link
Member

huycozy commented Nov 21, 2023

The .ceil() problem is in the first(initial) comment in the issue

Could you share a complete & minimal sample code to replicate the issue?

the flutter sample app crash is the second problem

Please separate the issue into another one for better tracking. When you file a new issue, please provide all information indicated in the issue template.

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 21, 2023
@kirill-21
Copy link
Author

The .ceil() problem is in the first(initial) comment in the issue

Could you share a complete & minimal sample code to replicate the issue?

the flutter sample app crash is the second problem

Please separate the issue into another one for better tracking. When you file a new issue, please provide all information indicated in the issue template.

Just final int b = (1016.0 * 1.0).ceil(); is enough for crash

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 21, 2023
@huycozy
Copy link
Member

huycozy commented Nov 22, 2023

Below is minimal sample code that I call ceil() method as you mentioned above:

Sample code
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
    
   final int b = (1016.0 * 1.0).ceil();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

But the issue is not reproduced in both debug and release modes.

Could you ask your user to try running the app using a debugger to get the crash's call stack? For example, here's how to do that using Visual Studio: https://learn.microsoft.com/visualstudio/debugger/how-to-debug-an-executable-not-part-of-a-visual-studio-solution

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 22, 2023
@kirill-21
Copy link
Author

kirill-21 commented Nov 24, 2023

@huycozy

import 'package:flutter/material.dart';

void main() {
  print('HJERE!');
  final int b = (1016.0 * 1.0).ceil();
  print('ceil result: ${b}!');
  runApp(const MyApp());

}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          //
          // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
          // action in the IDE, or press "p" in the console), to see the
          // wireframe for each widget.
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

image

Dart_entry.cc version is taken from here: https://dart.googlesource.com/sdk/+/refs/tags/3.2.0/runtime/vm/dart_entry.cc

And as Disassembly:
image
image

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 24, 2023
@huycozy
Copy link
Member

huycozy commented Nov 27, 2023

Thanks for the update. The issue still is not reproducible with the above sample code on my end. Looking at the screenshot, it seems like you were able to debug the stack trace.

Please provide the crash log in text format instead of a screenshot for better readability and investigation. Meanwhile, I will label this for other's input.

@huycozy huycozy added platform-windows Building on or for Windows specifically a: desktop Running on desktop team-desktop Owned by Desktop platforms team e: device-specific Only manifests on certain devices c: fatal crash Crashes that terminate the process waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds and removed in triage Presently being triaged by the triage team labels Nov 27, 2023
@kirill-21
Copy link
Author

Thanks for the update. The issue still is not reproducible with the above sample code on my end. Looking at the screenshot, it seems like you were able to debug the stack trace.

Please provide the crash log in text format instead of a screenshot for better readability and investigation. Meanwhile, I will label this for other's input.

I don't have access to that log, that was tested on user's PC and he will be unavailable for some time, so i'm not able to copy that in text format

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 27, 2023
@gspencergoog
Copy link
Contributor

Would it be possible to try this out with a simple Dart script that doesn't use Flutter, in order to reduce the number of moving parts in diagnosing the problem?

@gspencergoog gspencergoog added the P2 Important issues not at the top of the work list label Nov 30, 2023
@a-siva
Copy link
Contributor

a-siva commented Jan 25, 2024

@kirill-21 after the hot fix release with the cherry pick do you still see the crash, if not can you please close this issue.

@kirill-21
Copy link
Author

kirill-21 commented Jan 25, 2024

@kirill-21 after the hot fix release with the cherry pick do you still see the crash, if not can you please close this issue.

Which hot-fix? Issue was never gone on stable channel. There are dozens of related issues on GitHub , after 3.16 flutter is not usable for windows at all :c

#138784 (comment)

@a-siva
Copy link
Contributor

a-siva commented Jan 25, 2024

Which hot-fix? Issue was never gone on stable channel. There are dozens of related issues on GitHub , after 3.16 flutter is not usable for windows at all :c

Flutter 3.16.5 has the cherry pick dart-lang/sdk#54215 which was supposed to address this issue. Can you try that version and report back if you still see crashes

@kirill-21
Copy link
Author

Which hot-fix? Issue was never gone on stable channel. There are dozens of related issues on GitHub , after 3.16 flutter is not usable for windows at all :c

Flutter 3.16.5 has the cherry pick dart-lang/sdk#54215 which was supposed to address this issue. Can you try that version and report back if you still see crashes

I tested that when it released and it had the same problem

@a-siva
Copy link
Contributor

a-siva commented Jan 29, 2024

I tested that when it released and it had the same problem

Thanks for the reply. Did you also test it with the 'dart compile exe' command you mention in #138693 (comment) ?
We are trying to determine if the issue is only in the JIT version of the VM and the AOT generation is fine after the hot fix.

@kirill-21
Copy link
Author

I tested that when it released and it had the same problem

Thanks for the reply. Did you also test it with the 'dart compile exe' command you mention in #138693 (comment) ? We are trying to determine if there if the issue is only in the JIT version of the VM and the AOT generation is fine after the hot fix.

dart compile also did not work

@a-siva a-siva added the dependency:dart-triaged Triaged by Dart team label Feb 8, 2024
@a-siva
Copy link
Contributor

a-siva commented Feb 8, 2024

@rmacnak-google were you able to reproduce this on QEMU ?

@rmacnak-google
Copy link
Contributor

No, it seems to be working on QEMU with -cpu core2duo.

@aam
Copy link
Member

aam commented Feb 8, 2024

Could it be because unary ceil https://github.com/dart-lang/sdk/blob/main/runtime/vm/compiler/backend/il_x64.cc#L4714 is not guarded by double_truncate_round_supported check?

@aam
Copy link
Member

aam commented Feb 8, 2024

Given #138693 (comment) @kirill-21 could you run the same small sample test.dart

import 'dart:io';

void main() async {
  stdout.writeln('HERE.');
  final int b = (1016.0 * 1.0).ceil();
  stdout.writeln('ceil result: $b!');

  await Future.delayed(const Duration(seconds: 10));
}

via first dart.exe --target-unknown-cpu test.dart and then via dart.exe test.dart?
If first works, second fails, that means dart vm cpu feature detection https://github.com/dart-lang/sdk/blob/5a70848899fb96ac21a2d9244e842234fc1f138b/runtime/vm/cpuid.cc#L34 is not working as expected.

@kirill-21
Copy link
Author

kirill-21 commented Feb 8, 2024

Given #138693 (comment) @kirill-21 could you run the same small sample test.dart

import 'dart:io';

void main() async {
  stdout.writeln('HERE.');
  final int b = (1016.0 * 1.0).ceil();
  stdout.writeln('ceil result: $b!');

  await Future.delayed(const Duration(seconds: 10));
}

via first dart.exe --target-unknown-cpu test.dart and then via dart.exe test.dart? If first works, second fails, that means dart vm cpu feature detection https://github.com/dart-lang/sdk/blob/5a70848899fb96ac21a2d9244e842234fc1f138b/runtime/vm/cpuid.cc#L34 is not working as expected.

I tried --extra-gen-snapshot-options=--target-unknown-cpu during initial tests, did not help . Is this command working for dart or I should use strictly "--target-unknown-cpu"?

@aam
Copy link
Member

aam commented Feb 8, 2024

Yes, just do dart.exe --target-unknown-cpu test.dart and see if it works.

--extra-gen-snapshot-options=--target-unknown-cpu is the option for when you use flutter process, building release/profile builds.
For release/profile builds flutter passes content of --extra-gen-snapshot-options to dart's gen_snapshot. You could see that if you also pass --verbose flag to flutter command. The flow that involves gen_snapshot is also referred as AOT path, which is slightly different from JIT path employed by flutter debug build and standalone dart.exe invocation.
In either case it tells vm compiler to use restricted set of machine instructions.

@kirill-21
Copy link
Author

Yes, just do dart.exe --target-unknown-cpu test.dart and see if it works.

--extra-gen-snapshot-options=--target-unknown-cpu is the option for when you use flutter process, building release/profile builds. For release/profile builds flutter passes content of --extra-gen-snapshot-options to dart's gen_snapshot. You could see that if you also pass --verbose flag to flutter command. The flow that involves gen_snapshot is also referred as AOT path, which is slightly different from JIT path employed by flutter debug build and standalone dart.exe invocation. In either case it tells vm compiler to use restricted set of machine instructions.

But if I used --extra-gen-snapshot-options=--target-unknown-cpu for flutter build then what's the reason to test it directly with dart?

@aam
Copy link
Member

aam commented Feb 8, 2024

Taking flutter and other pieces of the AOT pipeline(gen_kernel, gen_snapshot) out of the equation simplifies root cause determination.
Once we confirm that dart.exe --target-unknown-cpu test.dart works, while dart.exe test.dart fails on that machine, ideally we would want to clarify values for level variable populated by [__cpuid() call](https://github.com/dart-lang/sdk/blob/5a70848899fb96ac21a2d9244e842234fc1f138b/runtime/vm/cpuid.cc#L34). Perhaps we can introduce a flag that dart.exe would use to print those values or have a small binary that does nothing but just prints those values so you run it on that machine.
If on the other hand dart.exe --target-unknown-cpu test.dart still doesn't work, __cpuid() result interpretation is not at fault and something else is.

@kirill-21
Copy link
Author

kirill-21 commented Feb 8, 2024

Taking flutter and other pieces of the AOT pipeline(gen_kernel, gen_snapshot) out of the equation simplifies root cause determination. Once we confirm that dart.exe --target-unknown-cpu test.dart works, while dart.exe test.dart fails on that machine, ideally we would want to clarify values for level variable populated by [__cpuid() call](https://github.com/dart-lang/sdk/blob/5a70848899fb96ac21a2d9244e842234fc1f138b/runtime/vm/cpuid.cc#L34). Perhaps we can introduce a flag that dart.exe would use to print those values or have a small binary that does nothing but just prints those values so you run it on that machine. If on the other hand dart.exe --target-unknown-cpu test.dart still doesn't work, __cpuid() result interpretation is not at fault and something else is.

Lol it's even worse right now, dart crashes immediately on execution of just "dart" command (after updating to the latest flutter/dart version)
image

When i try to use "dart test.dart" or "dart --target-unknown-cpu test.dart" cmd crashes, i don't even see the output of

  stdout.writeln('HERE.');

So now it's not even the .ceil problem, dart does not work AT ALL

dart.mp4

@aam
Copy link
Member

aam commented Feb 8, 2024

Sorry to see this.
The fact that you are able to run flutter and it prints out its version information indicates that dart.exe is actually running on the machine, since that's how flutter runs. Perhaps worth checking command prompt's path to confirm dart executable being invoked (echo %PATH%)

If you can run dart.exe from flutter\bin\cache\dart-sdk\bin folder from Visual Studio(similarly to how you did it previously #138693 (comment)), or confirm application error in Event Viewer(eventvwr.msc) Windows Logs/Application, that should shed some light as to what is going on.

@kirill-21
Copy link
Author

Sorry to see this. The fact that you are able to run flutter and it prints out its version information indicates that dart.exe is actually running on the machine, since that's how flutter runs. Perhaps worth checking command prompt's path to confirm dart executable being invoked (echo %PATH%)

If you can run dart.exe from flutter\bin\cache\dart-sdk\bin folder from Visual Studio(similarly to how you did it previously #138693 (comment)), or confirm application error in Event Viewer(eventvwr.msc) Windows Logs/Application, that should shed some light as to what is going on.

If dart wouldn't be accessible via %path% then cmd wouldn't crash and it would print that such command does not exist

@aam aam added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Feb 9, 2024
@kirill-21
Copy link
Author

kirill-21 commented Feb 10, 2024

Sorry to see this. The fact that you are able to run flutter and it prints out its version information indicates that dart.exe is actually running on the machine, since that's how flutter runs. Perhaps worth checking command prompt's path to confirm dart executable being invoked (echo %PATH%)

If you can run dart.exe from flutter\bin\cache\dart-sdk\bin folder from Visual Studio(similarly to how you did it previously #138693 (comment)), or confirm application error in Event Viewer(eventvwr.msc) Windows Logs/Application, that should shed some light as to what is going on.

Sorry but as I've said I have to ask users who have this problem to help with tests and it's really time-consuming so if you need to test something, give me whole list of possible outcomes like "do a, if if goes wrong do b, then do c, etc." I'm not able to test every little detail separately, as I've mentioned above, if there's some problem with %path%, then cmd wouldn't crash, I can not test redundant things that are already known

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Feb 10, 2024
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Mar 19, 2024
BUG=flutter/flutter#140138
BUG=flutter/flutter#138784
BUG=flutter/flutter#138693
TEST=manually on win x64 with `__ int3();` added in front of `roundsd` and forced `CpuId::sse41=false;`

Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/357218
Cherry-pick-request: #55211
Change-Id: I90a60d4972c5183d43516c628b68a71b7cc76912
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357983
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Mar 19, 2024
BUG=flutter/flutter#140138
BUG=flutter/flutter#138784
BUG=flutter/flutter#138693
TEST=manually on win x64 with `__ int3();` added in front of `roundsd` and forced `CpuId::sse41=false;`
Change-Id: I9e2dbf2615549dcc7c979036b5442276c2e0fb29
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/357218
Cherry-pick-request: #55211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358040
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
@ProZhar
Copy link

ProZhar commented Mar 29, 2024

Hi @kirill-21
Result according to your request for #140138 comment

All works fine in flutter 3.19.5

void main() {
  print('HJERE!');
  final int b = (1016.0 * 1.0).ceil();
  print('ceil result: ${b}!');
  runApp(const MyApp());
}

Debug mode:

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
√  Built build\windows\x64\runner\Debug\aaa_bbb.exe.
Debug service listening on ws://127.0.0.1:60264/03U0KslejRs=/ws
Syncing files to device Windows...
flutter: HJERE!
flutter: ceil result: 1016!

Release mode:

PS C:\src\aaa_bbb> flutter run --release -d windows
Launching lib\main.dart on Windows in release mode...
Building Windows application...                                    83,8s
√  Built build\windows\x64\runner\Release\aaa_bbb.exe (0.1MB).

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
flutter: HJERE!
flutter: ceil result: 1016!

Application finished.
PS C:\src\aaa_bbb> 

@kirill-21
Copy link
Author

Thank god issue seems to be finally fixed

@a-siva a-siva closed this as completed Mar 29, 2024
@huycozy huycozy added the r: fixed Issue is closed as already fixed in a newer version label Apr 1, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop c: fatal crash Crashes that terminate the process dependency: dart Dart team may need to help us dependency:dart-triaged Triaged by Dart team e: device-specific Only manifests on certain devices P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically r: fixed Issue is closed as already fixed in a newer version team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team
Projects
None yet
Development

No branches or pull requests

10 participants