Bug 222434 - Add some exception checks to the bindings generator
Summary: Add some exception checks to the bindings generator
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-02-25 13:01 PST by Saam Barati
Modified: 2021-02-25 17:57 PST (History)
4 users (show)

See Also:


Attachments
patch (81.63 KB, patch)
2021-02-25 13:55 PST, Saam Barati
ysuzuki: review+
Details | Formatted Diff | Diff
patch for landing (88.23 KB, patch)
2021-02-25 14:40 PST, Saam Barati
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2021-02-25 13:01:05 PST
...
Comment 1 Saam Barati 2021-02-25 13:37:27 PST
<rdar://69066130>
Comment 2 Saam Barati 2021-02-25 13:55:35 PST
Created attachment 421560 [details]
patch
Comment 3 Yusuke Suzuki 2021-02-25 14:03:07 PST
Comment on attachment 421560 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=421560&action=review

r=me, looks good!

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1261
>          push(@$outputArray, "    if (pluginElementCustomPut(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot, putResult))\n");
>          push(@$outputArray, "        return putResult;\n\n");
> +        push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, false);\n");

I wonder if we need to put `RETURN_IF_EXCEPTION(throwScope, false)` even in `true` case of pluginElementCustomPut.

bool success = pluginElementCustomPut(...);
RETURN_IF_EXCEPTION(throwScope, false);
if (success)
    return putResult;

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1266
>      push(@$outputArray, "    return JSObject::put(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot);\n");

How about using this instead?

RELEASE_AND_RETURN(throwScope, JSObject::put(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot));

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1342
>          push(@$outputArray, "    if (pluginElementCustomPut(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot, putResult))\n");
>          push(@$outputArray, "        return putResult;\n\n");
> +        push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, false);\n");

Ditto.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1348
>          push(@$outputArray, "    return JSObject::putByIndex(cell, lexicalGlobalObject, index, value, shouldThrow);\n");

Ditto about RELEASE_AND_RETURN.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1506
>      push(@$outputArray, "    return JSObject::defineOwnProperty(object, lexicalGlobalObject, propertyName, newPropertyDescriptor, shouldThrow);\n");

Ditto about RELEASE_AND_RETURN.
Comment 4 Saam Barati 2021-02-25 14:27:43 PST
Comment on attachment 421560 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=421560&action=review

>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1261
>> +        push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, false);\n");
> 
> I wonder if we need to put `RETURN_IF_EXCEPTION(throwScope, false)` even in `true` case of pluginElementCustomPut.
> 
> bool success = pluginElementCustomPut(...);
> RETURN_IF_EXCEPTION(throwScope, false);
> if (success)
>     return putResult;

yeah, I think this is the right way to do it. I'll fix.

>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1266
>>      push(@$outputArray, "    return JSObject::put(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot);\n");
> 
> How about using this instead?
> 
> RELEASE_AND_RETURN(throwScope, JSObject::put(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot));

yeah, I can do that.
Comment 5 Saam Barati 2021-02-25 14:40:30 PST
Created attachment 421567 [details]
patch for landing
Comment 6 EWS 2021-02-25 17:57:27 PST
Committed r273524: <https://commits.webkit.org/r273524>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 421567 [details].