Skip to content

VM crash on "await x++". #22634

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
lrhn opened this issue Mar 3, 2015 · 10 comments
Closed

VM crash on "await x++". #22634

lrhn opened this issue Mar 3, 2015 · 10 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@lrhn
Copy link
Member

lrhn commented Mar 3, 2015

Example code:
  main() async {
    var x = 0;
    await x++;
  }
yields:

runtime/vm/scopes.h:62: error: expected: HasIndex()
Aborted (core dumped)

@iposva-google
Copy link
Contributor

cc @crelier.
Set owner to @mhausner.
Added this to the 1.9 milestone.
Removed Priority-Unassigned label.
Added Priority-High, Accepted labels.

@DartBot
Copy link

DartBot commented Mar 3, 2015

This comment was originally written by @mhausner


The VM clearly should not crash.

What does await x++ mean? is it the same as x++; await x?

@lrhn
Copy link
Member Author

lrhn commented Mar 3, 2015

  await x++
should be the same as
  await (x++)
or
  var tmp = x++;
  await tmp;
since the grammar is equivalent to :
  unaryExpression : ... | 'await' unaryExpression | postfixExpression | ...
and postfixExpression produces "x++".

@iposva-google
Copy link
Contributor

Adding Gilad for the interpretation of the language spec. Thanks!


cc @gbracha.

@gbracha
Copy link
Contributor

gbracha commented Mar 3, 2015

It is the same as await (x++);
which in turn means

await ( (){var r = v; v= r + 1; return r;}() );

@lrhn
Copy link
Member Author

lrhn commented Mar 5, 2015

It no longer crashes, but it fails to work. The code
    f() async {
      var x = 42;
      return await x++;
    }
gives:

ERROR: await expression unary postfix operator
  Test failed: Caught Closure call with mismatched arguments: function '+'
  
  NoSuchMethodError: incorrect number of arguments passed to method named '+'
  Receiver: Closure: ([dynamic, dynamic, dynamic]) => dynamic
  Tried calling: +(1)
  Found: +(:async_result, :async_error_param, :async_stack_trace_param)
  dart:core-patch/object_patch.dart 42:35 Object._noSuchMethod
  dart:core-patch/object_patch.dart 45:25 Object.noSuchMethod
  ../tests/language/async_await_test.dart 1549:22 main.<fn>.<fn>.f.<async>

@DartBot
Copy link

DartBot commented Mar 5, 2015

This comment was originally written by @mhausner


Nothing has changed for me. I still get the same assertion error. It's not an easy fix. The problem are LetNode ast nodes, which in at least two ways do not fit well into the ast transformation we do for await.

@lrhn
Copy link
Member Author

lrhn commented Mar 9, 2015

ACK, I was running a non-debug build, hence the missing C++ assertion.

@DartBot
Copy link

DartBot commented Mar 9, 2015

This comment was originally written by @mhausner


I have a fix for this.


Added Started label.

@DartBot
Copy link

DartBot commented Mar 10, 2015

This comment was originally written by @mhausner


Fixed in r44337


Added Fixed label.

@lrhn lrhn added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Mar 10, 2015
@lrhn lrhn added this to the 1.9 milestone Mar 10, 2015
This issue was closed.
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. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

4 participants