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

Crash on windows_x64 with dart sdk 2.19.0-444.6.beta #51369

Closed
6f opened this issue Feb 11, 2023 · 3 comments
Closed

Crash on windows_x64 with dart sdk 2.19.0-444.6.beta #51369

6f opened this issue Feb 11, 2023 · 3 comments

Comments

@6f
Copy link

6f commented Feb 11, 2023

We have a program that crashes on windows x64 with the latest dart beta version. The crash is likely related to the usage of typed_data.

It does not crash using the latest stable dart version.

Dart Version (installed using flutter upgrade)

> dart --version
Dart SDK version: 2.19.0-444.6.beta (beta) (Fri Jan 20 12:27:02 2023 +0000) on "windows_x64"

This is currently the smallest example I have which crashes.

import 'dart:math';
import 'dart:typed_data';

// COPIED FROM THE vector_math PACKAGE
// INCLUDED HERE TO MAKE ANALYSIS EASIER
// import 'package:vector_math/vector_math.dart';
class Vector2 {
  final Float32List _v2storage;
  
  factory Vector2(double x, double y) => Vector2.zero()..setValues(x, y);
  
  Vector2.zero() : _v2storage = Float32List(2);
  
  void setValues(double x, double y) {
    _v2storage[0] = x;
    _v2storage[1] = y;
  }
  
  double dot(Vector2 other) {
    final otherStorage = other._v2storage;
    double sum;
    sum = _v2storage[0] * otherStorage[0];
    sum += _v2storage[1] * otherStorage[1];
    return sum;
  }
  
  double get length => sqrt(length2);
  
  double get length2 {
    double sum;
    sum = _v2storage[0] * _v2storage[0];
    sum += _v2storage[1] * _v2storage[1];
    return sum;
  }
  
  double normalize() {
    final l = length;
    if (l == 0.0) {
      return 0.0;
    }
    final d = 1.0 / l;
    _v2storage[0] *= d;
    _v2storage[1] *= d;
    return l;
  }
}

void main() {
  print("START main()");
  var rng = Random(0);
  
  var sum = 0.0;
  for (var i = 0; i < 10000; ++i) {
    if (i % 100 == 0) print("$i");
    var theta1 = rng.nextDouble() * pi * 2.0;
    var theta2 = rng.nextDouble() * pi * 2.0;

    var a = Vector2(sin(theta1), cos(theta1));
    var b = Vector2(sin(theta2), cos(theta2));

    a.normalize();

    sum += a.dot(b);
  }

  print("sum: $sum");
}

The following output is visible in console. Crash always happens between iteration 3700 and 3800. No error information is printed.

> dart run
Building package executable...
Built crashtest:crashtest.
START main()
0
100
< some lines omitted >
3600
3700

Crash details are visible in windows event log:

Faulting application name: dart.exe, version: 0.0.0.0, time stamp: 0x63ca924c
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0x80000003
Fault offset: 0x0000027a701bd51c
Faulting process id: 0x2a28
Faulting application start time: 0x01d93dfccce3c90e
Faulting application path: D:\flutter\bin\cache\dart-sdk\bin\dart.exe
Faulting module path: unknown
Report Id: 6860e180-d5af-490f-9583-78974a1a7418
Faulting package full name: 
Faulting package-relative application ID: 
@asashour
Copy link
Contributor

Would you mind testing it with the dev channel (3.0.0-218.0.dev)? I couldn't reproduce it by:

dart compile exe .\lib\a.dart
.\lib\a.exe

@mraleph
Copy link
Member

mraleph commented Feb 11, 2023

Duplicate of #50622

@mraleph mraleph marked this as a duplicate of #50622 Feb 11, 2023
@mraleph mraleph closed this as completed Feb 11, 2023
@6f
Copy link
Author

6f commented Feb 11, 2023

For completeness sake:
I cannot reproduce it on the dev channel (3.0.0-218.0.dev). It looks like it has indeed been fixed. Thank you your time and quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants