Iterating object properties in a function that has a try...catch produces incorrect result
Reported by
ba...@techfg.com,
Sep 17 2016
|
||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 Steps to reproduce the problem: 1. Go to https://jsfiddle.net/Lqxhy4ev/ 2. Run the fiddle What is the expected behavior? isNotPlain should be 100,000 What went wrong? The return result from the isPlainObject function is inconsistent. It should always be false but it intermittently returns true. Did this work before? Yes Version 52.0.2743.116 Chrome version: 53.0.2785.116 Channel: stable OS Version: 10.0 Flash Version: Shockwave Flash 23.0 r0 1) The problem does not occur if you remove the try..catch block from inside of isPlainObject 2) The problem seems to have been introduced in version 53 as it does not repro in 52 (I specifically tested with Version 52.0.2743.116 most recently)
,
Sep 19 2016
This bug is triggered by code inside of the isPlainObject function of jQuery 1.x. So it could be quite widespread.
,
Sep 19 2016
hablich@ can you investigate this?
,
Sep 20 2016
That sounds like it is related to TF.
,
Sep 20 2016
,
Sep 20 2016
Also reproduces fine in D8 btw
,
Sep 20 2016
Reduced repro:
---
// Flags: --allow-natives-syntax
function isPlainObject(obj) {
var key;
for (key in obj) { }
return key === undefined;
};
var Widget = function() {};
Widget.prototype = { foo: function() {} };
var item = new Widget();
%OptimizeFunctionOnNextCall(isPlainObject);
assertFalse(isPlainObject(item));
---
Seems to be a bug in the AstGraphBuilder; the initial graph already has undefined for the key use outside the for-in loop.
,
Sep 20 2016
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/4dab7b5a1d6722002d47d0be2481cb65602a2451 commit 4dab7b5a1d6722002d47d0be2481cb65602a2451 Author: mstarzinger <mstarzinger@chromium.org> Date: Tue Sep 20 12:36:51 2016 [turbofan] Fix loop assignment analysis on ForInStatements. The implicit assignment to the induction variable in a ForInStatement has been ignored by the AST loop assignment analysis. This was hidden for cases where the parser introduced a ".for" temporary, but triggers when the variable is declared outside the loop. R=bmeurer@chromium.org TEST=mjsunit/regress/regress-crbug-647887 BUG= chromium:647887 Review-Url: https://codereview.chromium.org/2356733002 Cr-Commit-Position: refs/heads/master@{#39551} [modify] https://crrev.com/4dab7b5a1d6722002d47d0be2481cb65602a2451/src/compiler/ast-loop-assignment-analyzer.cc [add] https://crrev.com/4dab7b5a1d6722002d47d0be2481cb65602a2451/test/mjsunit/regress/regress-crbug-647887.js
,
Sep 20 2016
The above fix should address the issue. We probably want to merge that back after sufficient backing time in Canary.
,
Sep 20 2016
Agreed, this should be on the next Stable push.
,
Sep 20 2016
,
Sep 20 2016
Adding milestone tracking labels...
,
Sep 20 2016
All - Thanks for the quick attention and fix for this, greatly appreciated! In reviewing the fix (assigning key when variable is proxied), I'm curious why this issue presents intermittently and only with try..catch as opposed to every time. Just trying to better understand. Appreciate any insight you can provide. Thanks again!
,
Sep 21 2016
Re #13: The underlying reason is that V8 contains multiple compilers. This bug is specific to the TurboFan compiler. So it only triggers when the function is determined to be hot and gets optimized (hence only intermittently) and only for functions that the compiler pipeline decides to optimize with TurboFan and not with Crankshaft (the latter doesn't support exception handling, the former does, hence only with try-catch).
,
Sep 21 2016
[Automated comment] Request affecting a post-stable build (M53), manual review required.
,
Sep 21 2016
Your change meets the bar and is auto-approved for M54 (branch: 2840)
,
Sep 21 2016
@mstarzinger - Thanks for the additional info, greatly appreciated!
,
Sep 21 2016
Please confirm whether this change is baked/verified in Canary and safe to merge?If yes, merge your change to M54 (branch: 2840) ASAP so that we could take this for next Beta Release.
,
Sep 22 2016
Please reply to comment #18 (Please confirm whether this change is baked/verified in Canary and safe to merge?).
,
Sep 23 2016
Tested the same on win10, mac 10.11.6 and Linux 14.04 chrome version 55.0.2868.0 - isNotPlain is 100,000 as expected Please find the screenshot Adding the TE-Verified labels
,
Sep 23 2016
,
Sep 23 2016
Re #19/#18: Yes this had baking time in Canary by now. I will do the merge to M54 (V8 5.4 branch) now.
,
Sep 23 2016
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/e6ff184457db4d7726639c61d69dd80f44a8ad5e commit e6ff184457db4d7726639c61d69dd80f44a8ad5e Author: Michael Starzinger <mstarzinger@google.com> Date: Fri Sep 23 08:31:50 2016 Merged: [turbofan] Fix loop assignment analysis on ForInStatements. Revision: 4dab7b5a1d6722002d47d0be2481cb65602a2451 BUG= chromium:647887 LOG=N NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true R=bmeurer@chromium.org, hablich@chromium.org Review URL: https://codereview.chromium.org/2364843002 . Cr-Commit-Position: refs/branch-heads/5.4@{#55} Cr-Branched-From: 5ce282769772d94937eb2cb88eb419a6890c8b2d-refs/heads/5.4.500@{#2} Cr-Branched-From: ad07b49d7b47b40a2d6f74d04d1b76ceae2a0253-refs/heads/master@{#38841} [modify] https://crrev.com/e6ff184457db4d7726639c61d69dd80f44a8ad5e/src/compiler/ast-loop-assignment-analyzer.cc [add] https://crrev.com/e6ff184457db4d7726639c61d69dd80f44a8ad5e/test/mjsunit/regress/regress-crbug-647887.js
,
Sep 23 2016
,
Sep 23 2016
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/ebc2b13efeec46fa4e47884d0dc41bd118d3d033 commit ebc2b13efeec46fa4e47884d0dc41bd118d3d033 Author: Michael Starzinger <mstarzinger@google.com> Date: Fri Sep 23 08:48:17 2016 Merged: [turbofan] Fix loop assignment analysis on ForInStatements. Revision: 4dab7b5a1d6722002d47d0be2481cb65602a2451 BUG= chromium:647887 LOG=N NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true R=hablich@chromium.org, bmeurer@chromium.org Review URL: https://codereview.chromium.org/2354333006 . Cr-Commit-Position: refs/branch-heads/5.3@{#73} Cr-Branched-From: 820a23aade5e74a92d794e05a0c2b3597f0da4b5-refs/heads/5.3.332@{#2} Cr-Branched-From: 37538cb2c1b4d75c41af386cb4fedbe5566f5608-refs/heads/master@{#37308} [modify] https://crrev.com/ebc2b13efeec46fa4e47884d0dc41bd118d3d033/src/compiler/ast-loop-assignment-analyzer.cc [add] https://crrev.com/ebc2b13efeec46fa4e47884d0dc41bd118d3d033/test/mjsunit/regress/regress-crbug-647887.js
,
Sep 23 2016
Per comment #25, this is already merged to M53, so removing "Merge-Approved-53" label.
,
Sep 29 2016
Verified the fix on Windows(7, 10), Mac OSX 10.11.6 and Linux(ubuntu) with Chrome version 53.0.2785.143. Steps followed as mentioned in bug report.
,
Oct 19 2016
No further backport needed for Node.js. |
||||||||||||||||||
►
Sign in to add a comment |
||||||||||||||||||
Comment 1 by ba...@techfg.com
, Sep 19 2016