Skip to content

br_on_non_null[0] expected subtype of ((ref null any), (ref null extern) or (ref null func)), found f64.const of type f64. #59840

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
ditman opened this issue Jan 4, 2025 · 1 comment
Assignees
Labels
area-dart2wasm Issues for the dart2wasm compiler. area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.

Comments

@ditman
Copy link
Member

ditman commented Jan 4, 2025

Crash

I found the following crash when running some code in Wasm:

Uncaught (in promise) CompileError: WebAssembly.compileStreaming(): Compiling function
#5610:"repro" failed: br_on_non_null[0] expected subtype of ((ref null any), (ref null
extern) or (ref null func)), found f64.const of type f64 @+646856

Repro

Here's a minimal repro test:

// Test
import 'package:test/test.dart';

void main() {
  test('crashes', () {
    repro(something: 1.0, other: 1.0);
  });
}

void repro({double? something, double? other}) {
  assert(
    (something == null && other == null) ||
        (something != null && other != null),
  );

  if (something != null) {
    print(something);
    print(other!); // Crash!
  }
}

Run with:

$ dart test --platform=chrome --compiler=dart2wasm

Logs

The crash yields the following stack trace (most of it is unrelated to the failure, which is not great for debugging):

$ dart test --platform=chrome --compiler=dart2wasm
00:03 +0: [Chrome, Dart2Wasm] loading test/widget_test.dart                                                                                                                                  
Generated wasm module '/tmp/dart_test_RNPNKS/test_NRPVTX/widget_test.dart.browser_test.dart.wasm', and JS init file '/tmp/dart_test_RNPNKS/test_NRPVTX/widget_test.dart.browser_test.dart.mjs'.

00:35 +0 -1: [Chrome, Dart2Wasm] loading test/widget_test.dart [E]                                                                                                                           
  Failed to load "test/widget_test.dart":
  Timed out waiting for browser to load test suite. Browser output: [2016838:2016838:0103/163220.197554:WARNING:chrome_main_delegate.cc(672)] This is Chrome version 131.0.6778.204 (not a warning)
  [2016884:2016884:0103/163220.362138:WARNING:sandbox_linux.cc(430)] InitializeSandbox() called with multiple threads in process gpu-process.
  [2016884:2016884:0103/163220.363661:WARNING:viz_main_impl.cc(85)] VizNullHypothesis is disabled (not a warning)
  [2016838:2016838:0103/163220.381727:INFO:chrome_browser_cloud_management_controller.cc(247)] Starting cloud management registration with an enrollment token.
  [2016838:2016838:0103/163220.389129:ERROR:secret_portal_key_provider.cc(200)] Keyring unlock cancelled: 2
  
  DevTools listening on ws://127.0.0.1:45737/devtools/browser/52d07959-a982-4337-bc60-04a64f840e41
  [2016838:2016838:0103/163222.429873:INFO:CONSOLE(7705)] "Dart test runner browser host running", source: http://localhost:36579/w2faCQjCET8=/packages/test/src/runner/browser/static/host.dart.js (7705)
  [2016838:2016838:0103/163222.494359:INFO:CONSOLE(7733)] "Starting suite http://localhost:36579/w2faCQjCET8=/test/widget_test.html", source: http://localhost:36579/w2faCQjCET8=/packages/test/src/runner/browser/static/host.dart.js (7733)
  [2016838:2016838:0103/163222.567196:INFO:CONSOLE(47)] "Uncaught (in promise) CompileError: WebAssembly.compileStreaming(): Compiling function #5610:"repro" failed: br_on_non_null[0] expected subtype of ((ref null any), (ref null extern) or (ref null func)), found f64.const of type f64 @+646856", source: http://localhost:36579/w2faCQjCET8=/test/widget_test.dart.browser_test.dart.js (47)
  [2016838:2016861:0103/163222.606587:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: noondiphcddnnabmjcihcjfbhfklnnep,
  [2016838:2016861:0103/163222.606675:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: noondiphcddnnabmjcihcjfbhfklnnep
  [2016838:2016861:0103/163222.606745:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: hhheaakmbdonmcgdokhcdbeimelhgdfc
  [2016838:2016861:0103/163222.606794:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: ndakideadaglgpbblmppfonobpdgggin
  [2016838:2016861:0103/163222.606856:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: hnfdmhafkkbkjolmkgocidhgoioildpg
  [2016838:2016861:0103/163222.606938:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: mkmaajnfmpmpebdcpfnjbkgaloeidlfa
  [2016838:2016861:0103/163222.607003:INFO:component_cloud_policy_updater.cc(110)] Fetching policy for component: eemhhnpbjkhgacmkcieenkokbiancmic
  [2016838:2016861:0103/163223.004991:ERROR:external_policy_data_updater.cc(282)] The fetched data doesn't match the expected hash.
  [2016838:2016861:0103/163223.355453:ERROR:external_policy_data_updater.cc(282)] The fetched data doesn't match the expected hash.
  [2016838:2016838:0103/163224.226922:ERROR:policy_conversions_client.cc(322)] AutoSelectCertificateForUrls has an error of type: Error at AutoSelectCertificateForUrls[38]: Error while parsing JSON value: expected value at line 1 column 1
  Error at AutoSelectCertificateForUrls[49]: Error while parsing JSON value: expected value at line 1 column 1
  [2016838:2016838:0103/163224.226975:ERROR:policy_conversions_client.cc(322)] AutoSelectCertificateForUrls has an error of type: Error at AutoSelectCertificateForUrls[38]: Error while parsing JSON value: expected value at line 1 column 1
  Error at AutoSelectCertificateForUrls[49]: Error while parsing JSON value: expected value at line 1 column 1
  [2016838:2016838:0103/163224.227004:ERROR:policy_conversions_client.cc(322)] CloudUserPolicyMerge has an error of type: This policy is ignored because the user is unaffiliated. For this policy to be applied, the Chrome browser and profile must be managed through the Admin console by the same organization.
  [2016838:2016838:0103/163224.227020:ERROR:policy_conversions_client.cc(322)] CloudUserPolicyOverridesCloudMachinePolicy has an error of type: This policy is ignored because the user is unaffiliated. For this policy to be applied, the Chrome browser and profile must be managed through the Admin console by the same organization.
  [2016838:2016838:0103/163224.227040:ERROR:policy_conversions_client.cc(322)] DeveloperToolsDisabled has an error of type: Ignored because it was overridden by DeveloperToolsAvailability.
  [2016838:2016838:0103/163224.228547:ERROR:policy_conversions_client.cc(322)] ExtensionSettings has an error of type: Error at ExtensionSettings.aekbdcbnfangjdakfjdemmhpfkjlipeo.runtime_blocked_hosts: This field should not have more than 100 entries. All further entries will be discarded.
  [2016838:2016838:0103/163224.228642:ERROR:policy_conversions_client.cc(322)] RemoteAccessHostTokenUrl has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228671:ERROR:policy_conversions_client.cc(322)] RemoteAccessHostTokenValidationCertificateIssuer has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228681:ERROR:policy_conversions_client.cc(322)] RemoteAccessHostTokenValidationUrl has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228732:ERROR:policy_conversions_client.cc(322)] _comment has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228746:ERROR:policy_conversions_client.cc(322)] _comment has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228754:ERROR:policy_conversions_client.cc(322)] _comment has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228766:ERROR:policy_conversions_client.cc(322)] _comment has an error of type: Unknown policy.
  [2016838:2016838:0103/163224.228775:ERROR:policy_conversions_client.cc(322)] _ssh-fe has an error of type: Unknown policy.
  [2016838:2016866:0103/163224.434426:ERROR:registration_request.cc(291)] Registration response error message: DEPRECATED_ENDPOINT
  [2016838:2016838:0103/163232.400059:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:5155
  [2016838:2016838:0103/163232.400512:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:265059
  [2016838:2016838:0103/163232.434666:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:883094
  [2016838:2016838:0103/163232.435331:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:2200227
  [2016838:2016838:0103/163232.466635:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:45161
  [2016838:2016838:0103/163232.467033:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:2747168
  [2016838:2016838:0103/163232.512307:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:4680
  [2016838:2016838:0103/163232.512712:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:5378640
  [2016838:2016838:0103/163232.525774:WARNING:controller_impl.cc(1192)] Background download complete, client: 6, completion type: 0, file size:118577
  Created TensorFlow Lite XNNPACK delegate for CPU.
  [2016838:2016866:0103/163248.599943:ERROR:registration_request.cc(291)] Registration response error message: DEPRECATED_ENDPOINT
  Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#58 is a dynamic-sized tensor).

I'd expect my code to work. It works normally with --compiler dart2js.

Versions:

Dart

$ dart --version
Dart SDK version: 3.7.0-266.0.dev (dev) (Wed Dec 18 08:02:48 2024 -0800) on "linux_x64"

Chrome

$ chrome --version
Google Chrome 131.0.6778.204 unknown

Workarounds

The following workarounds can be used to mitigate this issue:

  1. Remove the assert call, or
  2. Add a null check to other so we don't need other!
      if (something != null && other != null) {
        print(something);
        print(other); // Doesn't crash!
      }

I guess the assert is promoting both something and other to non-null, but the Dart analysis isn't?

@ditman ditman added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jan 4, 2025
@ditman
Copy link
Member Author

ditman commented Jan 4, 2025

As suggested by @natebiggs, this also prevents the crash:

  test('does not crash', () {
    repro();
    repro(something: 1.0, other: 1.0);
  });

@sigmundch sigmundch added the area-dart2wasm Issues for the dart2wasm compiler. label Jan 6, 2025
@biggs0125 biggs0125 self-assigned this Jan 6, 2025
copybara-service bot pushed a commit that referenced this issue Jan 6, 2025
Bug: #59840
Change-Id: Ifaac6430eabfee21e4971b3dd864e22f65c80adf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402980
Reviewed-by: Martin Kustermann <[email protected]>
Commit-Queue: Nate Biggs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart2wasm Issues for the dart2wasm compiler. area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.
Projects
None yet
Development

No branches or pull requests

3 participants