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

Debug VM assert in DoubleToFloatInstr::Canonicalize #45547

Closed
fuzzybinary opened this issue Apr 1, 2021 · 8 comments
Closed

Debug VM assert in DoubleToFloatInstr::Canonicalize #45547

fuzzybinary opened this issue Apr 1, 2021 · 8 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@fuzzybinary
Copy link

I build Dart from source to use it as an embedding scripting language and I've come across a weird assertion. After running my code for a few seconds, the compiler asserts with the following message:

../../runtime/vm/compiler/backend/il.cc: 2214: error: expected: use->instruction()->IsPhi() || use->instruction()->IsFloatToDouble() || (use->instruction()->IsStoreIndexed() && (use->instruction()->AsStoreIndexed()->class_id() == kTypedDataFloat32ArrayCid))

It appears the instruction failing the use assertion is a MaterializeObjectInstr instruction (see screenshot here):
https://twitter.com/fuzzybinary/status/1377418669567791104?s=20

I was asked to provide a dump from FlowGraphPrinter, which is here:
https://gist.github.com/fuzzybinary/2a6f82d9a358c886356e3de53eb1caa5

This is building Dart from the current 2.12.2 label on Windows

@gmpassos
Copy link
Contributor

gmpassos commented Apr 1, 2021

Can you test it at Linux too? Just to confirm if happens in other platforms.

@gmpassos
Copy link
Contributor

gmpassos commented Apr 1, 2021

The called method with the assertion error:
https://github.com/dart-lang/sdk/blob/master/runtime/vm/compiler/backend/il.cc#L2239

@fuzzybinary
Copy link
Author

Can you test it at Linux too? Just to confirm if happens in other platforms.

Unfortunately not easily. I can maybe try to get my MacOS build running but it might take a few days.

It looks like the assertion is likely caused by this line in the FlowGraph:

 v1597 <- MaterializeObject(_Float32List, :array_element: v586, :array_element: v578, :array_element: v570) T{*?}

Which I think relates to this line in the provided code:

var tracking = Vector3(diff.x * parallax.trackCamera.x, diff.y * parallax.trackCamera.y, 0.0);

I can potentially try to reproduce using that code only, but I'm not entirely sure what's causing the recompile? Is it attempting to optimize a hotspot after several iterations?

@mraleph mraleph added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Apr 1, 2021
@mraleph
Copy link
Member

mraleph commented Apr 1, 2021

Related to recently implemented allocation sinking of the arrays. Probably benign (assertion just needs an adjustment) but we should check that we materialize correct array on deopt

@fuzzybinary
Copy link
Author

For what it's worth, since I'm building from source I commented out the assertion for now and I'm not seeing any adverse effects.

@gmpassos
Copy link
Contributor

gmpassos commented Apr 1, 2021

Try a Linux VM with Virtual Box. I do this in my mac to test some code with Linux.

@fuzzybinary
Copy link
Author

Try a Linux VM with Virtual Box. I do this in my mac to test some code with Linux.

My embedding use case is as a scripting language for a homegrown game engine. Reproducing in Linux would require porting the engine 😁

@alexmarkov
Copy link
Contributor

In addition to an overly strict assertion, there was a bug in materialization of Float32List elements in case of deoptimization.
The bug is not platform-specific and may appear on any OS/CPU.

Fix: https://dart-review.googlesource.com/c/sdk/+/193831.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

4 participants