Closed Bug 372565 Opened 18 years ago Closed 18 years ago

"Assertion failure: top < ss->printer->script->depth" decompiling a function where a const identifier is used as a for-loop variable

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
critical

Tracking

()

VERIFIED FIXED

People

(Reporter: jruderman, Assigned: mrbkap)

References

Details

(4 keywords)

Attachments

(1 file, 1 obsolete file)

js> function() { for each(x in y) { } const x; } Assertion failure: top < ss->printer->script->depth, at jsopcode.c:845
Flags: blocking1.9?
Attached patch Proposed fix (obsolete) — Splinter Review
Because we rely on the JSOP_FOR* to call the current iterator's next method, the current code, which emits a JSOP_GETVAR in place of the JSOP_FORVAR breaks not only decompilation, but actually goes into an infinite loop. Here's a testcase: (function() { const x = 3; for each(x in {1:1,2:2}) { print(x); } })() My proposed solution is to add a JSOP_FORCONST which knows to not actually update the slot given, but does call the iterator's next method. The testcase correctly decompiles and runs with this patch.
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Attachment #258148 - Flags: review?(brendan)
How about eliminating the useless JSOP_STARTITER while you are at it, and reclaiming that bytecode? (Be careful to set pos = blockpos + 1; in the JSOP_ARRAYPUSH case of Decompile.) /be
Blocks: js1.7src
Attached patch With thatSplinter Review
Attachment #258148 - Attachment is obsolete: true
Attachment #258152 - Flags: review?(brendan)
Attachment #258148 - Flags: review?(brendan)
Comment on attachment 258152 [details] [diff] [review] With that Great, thanks! /be
Attachment #258152 - Flags: review?(brendan) → review+
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
/cvsroot/mozilla/js/tests/js1_6/Regress/regress-372565.js,v <-- regress-372565.js initial revision: 1.1
Flags: in-testsuite+
verified fixed 1.9.0 20070320 win/mac*/linux
Status: RESOLVED → VERIFIED
This bug also exists on the MOZILLA_1_8_BRANCH and I backported the patch above in bug 437288.
Blocks: 437288
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: