Bug 20093 - JSC shell does not clear exceptions after it executes toString on an expression
Summary: JSC shell does not clear exceptions after it executes toString on an expression
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
: 20094 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-18 05:03 PDT by Oliver Hunt
Modified: 2008-08-24 21:08 PDT (History)
2 users (show)

See Also:


Attachments
Fix that exposes problem with exceptions and eval (1.98 KB, patch)
2008-08-24 17:29 PDT, Cameron Zwarich (cpst)
no flags Details | Formatted Diff | Diff
Proposed patch (2.52 KB, patch)
2008-08-24 18:24 PDT, Cameron Zwarich (cpst)
no flags Details | Formatted Diff | Diff
Proposed patch (with better ChangeLog) (2.67 KB, patch)
2008-08-24 18:31 PDT, Cameron Zwarich (cpst)
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.