Bug 20093

Summary: JSC shell does not clear exceptions after it executes toString on an expression
Product: WebKit Reporter: Oliver Hunt <oliver>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: sam, zwarich
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
Fix that exposes problem with exceptions and eval
none
Proposed patch
none
Proposed patch (with better ChangeLog) oliver: review+

Description Oliver Hunt 2008-07-18 05:03:20 PDT
The JSC shell doesn't check for toString on the result of an expression throwing, so it will eventually result in incorrect behaviour in some cases.

Trivial reproduction:
1. Start jsc
2. enter eval({toString:function(){throw{};}});
3. goto 2
Comment 1 Alexey Proskuryakov 2008-07-18 07:24:14 PDT
*** Bug 20094 has been marked as a duplicate of this bug. ***
Comment 2 Cameron Zwarich (cpst) 2008-08-24 17:27:24 PDT
I can fix this by checking the completion type, but for your example the completion type is Normal, not Throw, even though there is an exception on the global object's ExecState. This would appear to be a separate bug, so I'll file it.
Comment 3 Cameron Zwarich (cpst) 2008-08-24 17:29:44 PDT
Created attachment 22967 [details]
Fix that exposes problem with exceptions and eval

Here is my proposed fix. The assertions about exceptions on the global ExecState currently fail on Oliver's example.
Comment 4 Cameron Zwarich (cpst) 2008-08-24 18:02:03 PDT
The problem isn't with eval, it is that an exception is thrown while printing the value. A similar issue occurs with the inspector. We should decide what to do in both cases.
Comment 5 Cameron Zwarich (cpst) 2008-08-24 18:24:43 PDT
Created attachment 22970 [details]
Proposed patch

Here's a fix. It doesn't make the user aware of any exceptions that occurred while printing the final value, but we should deal with that problem later, together with the solution for the inspector.
Comment 6 Cameron Zwarich (cpst) 2008-08-24 18:31:31 PDT
Created attachment 22971 [details]
Proposed patch (with better ChangeLog)

I forgot to mention something in the ChangeLog.
Comment 7 Cameron Zwarich (cpst) 2008-08-24 21:08:50 PDT
Committed r35911.