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

"Abort trap: 6" instead of NoSuchMethodError (null access) #35887

Closed
gothamgasworks opened this Issue Feb 8, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@gothamgasworks
Copy link

gothamgasworks commented Feb 8, 2019

  • Dart SDK Version: Dart VM version: 2.1.1-dev.3.2 (Thu Jan 24 11:50:07 2019 +0100) on "macos_x64"

When I run the following code:

class Value {
  const Value(this.val);

  final int val;
}

const int limit = 50000;

Value maybeWrap(int i) => i < limit ? new Value(i) : null;

void main() async {
  for (int i = 0; i < 65536; ++i) {
    if (maybeWrap(i).val == -1) {
      // never mind we just do something with it
      print(i);
    }
  }
}

Expected output:

Unhandled exception:
NoSuchMethodError: The getter 'val' was called on null.
... etc ...

Actual output:

libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
Abort trap: 6

I get the expected output if I decrease the value of limit to 5000, so I'm guessing this is a JIT bug.

@mraleph

This comment has been minimized.

Copy link
Contributor

mraleph commented Feb 8, 2019

@mkustermann @sjindel-google Martin or Samir could you take a look at this? My suspicion would be that something is wrong with lazy deoptimization (used to compute try/catch sync moves) which occurs on the slow-path that uses shared stubs.

@sjindel-google

This comment has been minimized.

Copy link
Contributor

sjindel-google commented Feb 12, 2019

The issue is that CheckNull (which was originally created for AOT) doesn't work in JIT because it doesn't create an deoptimization info. This example is easy to fix in the call specializer, but unfortunately we have other uses of CheckNull in JIT-mode which require more work to fix.

@sjindel-google

This comment has been minimized.

dart-bot pushed a commit that referenced this issue Feb 13, 2019

[vm] Fix ThrowErrorSlowPath-derived instructions (e.g. CheckNull) in …
…JIT mode.

Previously these instructions were not safe to use on JIT, because they
crated catch-entry moves which are not used in JIT.

Now we assign deopt-infos to these slow paths so they can handle exceptions
correctly in JIT.

I considered removing uses of CheckNull in JIT mode, but I did not find a simple
replacement for all the existing uses.

Fixes #35887.

Change-Id: I05dfb46200679934d0ff6114cae8723f4908af8e
Reviewed-on: https://dart-review.googlesource.com/c/92783
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
Auto-Submit: Samir Jindel <sjindel@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment