Bug 169778 - import(arg) crashes when ToString(arg) throws
Summary: import(arg) crashes when ToString(arg) throws
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-16 13:02 PDT by Sathya Gunasekaran
Modified: 2017-03-21 00:43 PDT (History)
8 users (show)

See Also:


Attachments
Patch (3.13 KB, patch)
2017-03-19 00:26 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sathya Gunasekaran 2017-03-16 13:02:47 PDT
Test case:

let x = { get toString() { throw new Error('wat'); } };
import(x);

Expected result :
a new rejected promise is created

Actual result :
Safari crashes and reloads the page
Comment 1 Yusuke Suzuki 2017-03-19 00:12:47 PDT
This is the same issue with https://bugs.webkit.org/show_bug.cgi?id=167585.
We should not reject promises with Exception.
Comment 2 Yusuke Suzuki 2017-03-19 00:26:47 PDT
Created attachment 304893 [details]
Patch
Comment 3 Yusuke Suzuki 2017-03-19 08:12:30 PDT
Comment on attachment 304893 [details]
Patch

r=me
Comment 4 Yusuke Suzuki 2017-03-19 08:13:37 PDT
(In reply to comment #3)
> Comment on attachment 304893 [details]
> Patch
> 
> r=me

oops, i've put incorrect words from my phone.
Comment 5 WebKit Commit Bot 2017-03-19 08:41:40 PDT
Comment on attachment 304893 [details]
Patch

Clearing flags on attachment: 304893

Committed r214143: <http://trac.webkit.org/changeset/214143>
Comment 6 WebKit Commit Bot 2017-03-19 08:41:46 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Saam Barati 2017-03-19 08:51:55 PDT
Is it always wrong to reject a promise with Excetion*?
If so, we've made this mistake twice. Can we add a variant like
reject(Exception*) = delete;
Or
Make reject(Exception*) do the right thing by grabbing the value
Comment 8 Mark Lam 2017-03-19 08:53:10 PDT
(In reply to comment #7)
> Is it always wrong to reject a promise with Excetion*?
> If so, we've made this mistake twice. Can we add a variant like
> reject(Exception*) = delete;
> Or
> Make reject(Exception*) do the right thing by grabbing the value

Either that, or have reject(Exception*) do the unwrapping automatically.
Comment 9 Yusuke Suzuki 2017-03-21 00:43:12 PDT
Opened. https://bugs.webkit.org/show_bug.cgi?id=169908
I think adding reject(ExecState*, Exception*) interface is better since we have similar interface in WebCore::DOMPromise.