New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 644631 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug

Blocking:
issue v8:5267



Sign in to add a comment

Inline calls to runtime functions in TurboFan that throw exceptions result in missing frame state

Project Member Reported by ClusterFuzz, Sep 7 2016

Issue description

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=4872750261075968

Fuzzer: mbarbella_js_mutation
Job Type: linux_v8_d8_tot
Platform Id: linux

Crash Type: CHECK failure
Crash Address: 
Crash State:
  Missing deoptimization information for OptimizedFrame::Summarize in frames.cc
  
Regressed: V8: r38677:38693

Minimized Testcase (0.10 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv966VZ_5CpG0HisQ6Z_u5vf0P7VHVNXbYZaMvoEelOFPHET2dEPNriRIGEl5QItrc4o6Y__QS5iBrGjsSCPfkQltKkH59L7cuOQmN2iSiByjPGpzTqp-9-kUqOTFN7q_B7Y8QRNTK23EMunQzlPQHhYjrtlxiA?testcase_id=4872750261075968
__v_4 = this;
__v_5 = new ArrayBuffer(-1 * -2147483648);
  var __v_2 = new __v_4.Int8Array(__v_5);


Issue manually filed by: mstarzinger

See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.
 
Cc: littledan@chromium.org adamk@chromium.org
Owner: bakkot@google.com
Status: Assigned (was: Untriaged)
Bisects to: https://chromium.googlesource.com/v8/v8/+/a3c13435aa822041b1fac25baf0e63c56185e4a1

Reproduces as follows ...

$ ./out/x64.debug/d8 --random-seed=1532034190 --turbo --always-opt ~/Downloads/fuzz-00474.js 

#
# Fatal error in ../src/frames.cc, line 1140
# Missing deoptimization information for OptimizedFrame::Summarize.
#

Comment 2 by adamk@chromium.org, Sep 7 2016

Cc: bakkot@google.com
Owner: adamk@chromium.org
Status: Started (was: Assigned)
Looking into this.

Comment 3 by adamk@chromium.org, Sep 8 2016

Cc: bmeu...@chromium.org
Components: Blink>JavaScript>Compiler
Labels: -OS-Linux OS-All
All this patch did to change how that particular input is handled was move the exception throwing from JS to the runtime function TypedArrayInitialize.

However, what's special is that the call to TypedArrayInitialize is as an inline intrinsic (with a "%_" prefix). If I change it to %TypedArrayInitialize, everything works as expected. So it seems our OptimizedFrame walking code may not properly handle the case of an exception thrown from a runtime function called as an intrinsic (at least for the TurboFan case).

Indeed, I can reproduce elsewhere by taking any runtime call that throws and calling it with a "%_" prefix, e.g.:

d8 -e 'var obj = Object.freeze({}); %_CreateDataProperty(obj, "foo", "bar");' --allow-natives-syntax --always-opt --turbo

This also crashes with the same check failure in OptimizedFrame::Summarize.

Comment 4 by adamk@chromium.org, Sep 8 2016

Cc: jgruber@chromium.org
+jgruber as well, as this may just be due to recent changes in the stack-walking code.

Comment 5 by adamk@chromium.org, Sep 8 2016

Owner: bmeu...@chromium.org
Status: Assigned (was: Started)
Summary: Inline calls to runtime functions in TurboFan that throw exceptions result in missing frame state (was: Missing deoptimization information for OptimizedFrame::Summarize in frames.cc)
Chasing this down further, I think this is a bug in Linkage::NeedsFrameStateInput(). If I modify that code to return true for Runtime::kInlineTypedArrayInitialize, then this test case goes back to not crashing.

I think the right general fix would be for NeedsFrameStateForInput to know which runtime calls that appear inline will actually turn out to be runtime calls; right now I believe that logic is in js-intrinsic-inlining. I'm happy to do the work (it's probably just factoring out some switch statements), but I don't know what the best way to structure that would be.

Assigning to bmeurer for thoughts on how to organize this logic (and retitling).
Blocking: v8:5267
Cc: -adamk@chromium.org
Owner: adamk@chromium.org
I think the idea initially was that intrinsics wouldn't be allowed to throw (or even lazy deopt), while regular runtime functions can do everything. But as far as I can remember that never really worked due to our use of %_ intrinsics in so many interesting ways.

So I think the correct fix nowadays is to explicitly white-list everything that doesn't throw and/or lazy deopt in Linkage::NeedsFrameStateInput, instead of having a blacklist for %_ intrinsics and a white-list for % functions. That seems safer and we can still leave out frame states when we know it's OK to do so.

I'd be happy if you could take a look.

Comment 7 by adamk@chromium.org, Sep 9 2016

Whitelist instead of blacklist seems ok to me (even the whitelist is a little scary, but I agree it's definitely safer than the blacklist).
Project Member

Comment 8 by bugdroid1@chromium.org, Sep 12 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/58325e616d068ab589a91b6f80896e28df395f93

commit 58325e616d068ab589a91b6f80896e28df395f93
Author: adamk <adamk@chromium.org>
Date: Mon Sep 12 16:12:13 2016

[turbofan] Switch from a whitelist to a blacklist for NeedsFrameStateInput

The whitelist is populated with those inline intrinsics that are lowered
in JSIntrinsicInlining and were not previously blacklisted. Thus the only
additional FrameStates this CL adds are those where the caller tries to
call the INLINE version of an intrinsic but ends up calling the RUNTIME
version instead.

R=bmeurer@chromium.org
BUG= chromium:644631 

Review-Url: https://codereview.chromium.org/2331543002
Cr-Commit-Position: refs/heads/master@{#39357}

[modify] https://crrev.com/58325e616d068ab589a91b6f80896e28df395f93/src/compiler/linkage.cc
[add] https://crrev.com/58325e616d068ab589a91b6f80896e28df395f93/test/mjsunit/regress/regress-crbug-644631.js

Comment 9 by adamk@chromium.org, Sep 12 2016

Status: Fixed (was: Assigned)
Project Member

Comment 10 by ClusterFuzz, Sep 13 2016

ClusterFuzz has detected this issue as fixed in range 39347:39359.

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=4872750261075968

Fuzzer: mbarbella_js_mutation
Job Type: linux_v8_d8_tot
Platform Id: linux

Crash Type: CHECK failure
Crash Address: 
Crash State:
  Missing deoptimization information for OptimizedFrame::Summarize in frames.cc
  
Regressed: V8: r38677:38693
Fixed: V8: r39347:39359

Minimized Testcase (0.10 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv966VZ_5CpG0HisQ6Z_u5vf0P7VHVNXbYZaMvoEelOFPHET2dEPNriRIGEl5QItrc4o6Y__QS5iBrGjsSCPfkQltKkH59L7cuOQmN2iSiByjPGpzTqp-9-kUqOTFN7q_B7Y8QRNTK23EMunQzlPQHhYjrtlxiA?testcase_id=4872750261075968
__v_4 = this;
__v_5 = new ArrayBuffer(-1 * -2147483648);
  var __v_2 = new __v_4.Int8Array(__v_5);


See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.

If you suspect that the result above is incorrect, try re-doing that job on the test case report page.
Project Member

Comment 11 by bugdroid1@chromium.org, Oct 12 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/1eaf2927bac050b466f490082e55a2dbf6a2648d

commit 1eaf2927bac050b466f490082e55a2dbf6a2648d
Author: adamk <adamk@chromium.org>
Date: Wed Oct 12 07:33:05 2016

Change TF regression test to not trigger tons of allocation

Instead of allocating an ArrayBuffer in the test, use a different example
from the original bug.

R=bmeurer@chromium.org
BUG= chromium:644631 ,  v8:5504 

Review-Url: https://codereview.chromium.org/2408403002
Cr-Commit-Position: refs/heads/master@{#40195}

[modify] https://crrev.com/1eaf2927bac050b466f490082e55a2dbf6a2648d/test/mjsunit/regress/regress-crbug-644631.js

Project Member

Comment 12 by sheriffbot@chromium.org, Nov 22 2016

Labels: -Restrict-View-EditIssue
Removing EditIssue view restrictions from ClusterFuzz filed bugs. If you believe that this issue should still be restricted, please reapply the label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment