Bug 222538 - REGRESSION: Object.defineProperties triggering a setter
Summary: REGRESSION: Object.defineProperties triggering a setter
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari Technology Preview
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-01 00:53 PST by Mark S. Miller
Modified: 2021-06-09 21:47 PDT (History)
11 users (show)

See Also:


Attachments
Screenshot of debugger state caught in buggy behavior (561.89 KB, image/png)
2021-03-01 00:53 PST, Mark S. Miller
no flags Details
Screenshot of debugger state caught in buggy behavior (8.36 KB, image/png)
2021-03-01 00:54 PST, Mark S. Miller
no flags Details
Screenshot of debugger state caught in buggy behavior (496.68 KB, image/png)
2021-03-01 00:54 PST, Mark S. Miller
no flags Details
Screenshot of debugger state caught in buggy behavior (547.05 KB, image/png)
2021-03-01 00:55 PST, Mark S. Miller
no flags Details
Screenshot of debugger state caught in buggy behavior (417.72 KB, image/png)
2021-03-01 00:55 PST, Mark S. Miller
no flags Details
Screenshot of debugger state caught in buggy behavior (435.14 KB, image/png)
2021-03-01 00:56 PST, Mark S. Miller
no flags Details
Patch (4.67 KB, patch)
2021-03-01 16:44 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
The call to defineProperties (740.04 KB, image/png)
2021-05-07 15:30 PDT, Mark S. Miller
no flags Details
The call to the setter (691.76 KB, image/png)
2021-05-07 15:33 PDT, Mark S. Miller
no flags Details
Shows about box and full url (859.02 KB, image/png)
2021-05-07 15:34 PDT, Mark S. Miller
no flags Details
Snapshot of built package currently use by page (212.98 KB, text/javascript)
2021-05-07 15:39 PDT, Mark S. Miller
no flags Details
snapshot of html page (1.35 KB, text/html)
2021-05-07 15:40 PDT, Mark S. Miller
no flags Details
snapshot of demo source used by that page (881 bytes, text/javascript)
2021-05-07 15:42 PDT, Mark S. Miller
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark S. Miller 2021-03-01 00:53:18 PST
Created attachment 421790 [details]
Screenshot of debugger state caught in buggy behavior

See https://github.com/Agoric/SES-shim/pull/592

The SES Demo console, after previously having worked on Safari Technology Preview, suddenly started failing with an infinite recursion. This instrumented variation of the PR in which this started failing catches when `Object.defineProperties` causes a setter to be called. The `Object.defineProperties` is attempting to convert `Array.prototype.toString` from a data property to an accessor property, after `Object.prototype.toString` has been similarly converted. Violating the semantics of `defineProperties`, it causes the setter of the `Object.prototype.toString` accessor property to be called. There follows some screenshots examining this state from within the debugger.

This is on Safari Technology Preview
Release 121 (Safari 14.2, WebKit 16612.1.4.3)
Comment 1 Mark S. Miller 2021-03-01 00:54:28 PST
Created attachment 421791 [details]
Screenshot of debugger state caught in buggy behavior
Comment 2 Mark S. Miller 2021-03-01 00:54:53 PST
Created attachment 421792 [details]
Screenshot of debugger state caught in buggy behavior
Comment 3 Mark S. Miller 2021-03-01 00:55:18 PST
Created attachment 421793 [details]
Screenshot of debugger state caught in buggy behavior
Comment 4 Mark S. Miller 2021-03-01 00:55:45 PST
Created attachment 421794 [details]
Screenshot of debugger state caught in buggy behavior
Comment 5 Mark S. Miller 2021-03-01 00:56:07 PST
Created attachment 421795 [details]
Screenshot of debugger state caught in buggy behavior
Comment 6 Radar WebKit Bug Importer 2021-03-01 13:46:16 PST
<rdar://problem/74888939>
Comment 7 Yusuke Suzuki 2021-03-01 14:09:39 PST
(In reply to Mark S. Miller from comment #0)
> Created attachment 421790 [details]
> Screenshot of debugger state caught in buggy behavior
> 
> See https://github.com/Agoric/SES-shim/pull/592
> 
> The SES Demo console, after previously having worked on Safari Technology
> Preview, suddenly started failing with an infinite recursion. This
> instrumented variation of the PR in which this started failing catches when
> `Object.defineProperties` causes a setter to be called. The
> `Object.defineProperties` is attempting to convert
> `Array.prototype.toString` from a data property to an accessor property,
> after `Object.prototype.toString` has been similarly converted. Violating
> the semantics of `defineProperties`, it causes the setter of the
> `Object.prototype.toString` accessor property to be called. There follows
> some screenshots examining this state from within the debugger.
> 
> This is on Safari Technology Preview
> Release 121 (Safari 14.2, WebKit 16612.1.4.3)

Thanks for the report! Is there a instruction reproducing this problem?
Comment 8 Mark S. Miller 2021-03-01 15:39:09 PST
> Thanks for the report! Is there a instruction reproducing this problem?

Yes. I set aside that PR only for the purpose of demonstrating and reproducing this bug. 

Do a git clone of the `https://github.com/Agoric/SES-shim/tree/safari-defProps-bug` branch. (The branch corresponding to that PR)

cd to packages/ses

run any local web browser. I used httpdhere

Visit http://localhost:8080/demos/console/

Set the breakpoint shown

Refresh the page.
Comment 9 Mark S. Miller 2021-03-01 16:07:18 PST
I omitted a step in my instructions to reproduce. After

> cd to packages/ses

do a `yarn build` in that directory. 

You need yarn v1, yes v1, installed. Sorry about that.
Comment 10 Mark S. Miller 2021-03-01 16:09:44 PST
Sigh. Sorry about this. Always hard to remember habits. Before that cd'ing or yarn build, in the root directory of the monorepo, do a `yarn install && yarn build`. Not sure all of that is needed but it is what I've been doing.
Comment 11 Yusuke Suzuki 2021-03-01 16:44:34 PST
Created attachment 421886 [details]
Patch
Comment 12 Keith Miller 2021-03-01 16:46:25 PST
Comment on attachment 421886 [details]
Patch

r=me.
Comment 13 EWS 2021-03-01 18:05:00 PST
Committed r273717: <https://commits.webkit.org/r273717>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 421886 [details].
Comment 14 Yusuke Suzuki 2021-03-01 18:33:14 PST
@Mark Thanks! I think the issue is now fixed.
Comment 15 Mark S. Miller 2021-03-01 21:11:10 PST
Awesomely speedy response! I am impressed. Thanks.
Comment 16 Mark S. Miller 2021-05-07 12:57:18 PDT
I have some evidence that this bug happened again under Safari Version 14.1 (16611.1.21.161.3) *in the debugger* with weaker evidence that it did not happen for the same code not under the debugger. Until I know more I'm not reopening. But posting this anyway it case it rings a bell.
Comment 17 Mark S. Miller 2021-05-07 15:26:05 PDT
Yes, the bug is still there in the latest Safari. I now believe that it is intermittent or at least sensitive to conditions I don't understand. But it seems to happen both inside the debugger and normally, so my previous speculation is wrong. 

I will upload a set of screenshots that make it clear is still happening.
Comment 18 Mark S. Miller 2021-05-07 15:30:03 PDT
Created attachment 428041 [details]
The call to defineProperties

1 of 3

To reproduce yourself, visit https://ses-demo.netlify.app/demos/console/ and open the debugger console. You might already see the error message in the console from the page initializing itself. If not, try refreshing. If not, shut down and relaunch the browser. I really have no better formula.
Comment 19 Mark S. Miller 2021-05-07 15:33:09 PDT
Created attachment 428042 [details]
The call to the setter

At line 5325 is a call to a function named defineProperty. This is actually the defineProperty defined in the first screenshot, which calls defineProperties.
Comment 20 Mark S. Miller 2021-05-07 15:34:34 PDT
Created attachment 428046 [details]
Shows about box and full url
Comment 21 Mark S. Miller 2021-05-07 15:36:51 PDT
Since Safari has this bug, I plan to revise our sources to workaround this bug. When I do so, the website at that url will update. So first I'll indicate the current version of out sources.
Comment 22 Mark S. Miller 2021-05-07 15:39:46 PDT
Created attachment 428049 [details]
Snapshot of built package currently use by page
Comment 23 Mark S. Miller 2021-05-07 15:40:54 PDT
Created attachment 428050 [details]
snapshot of html page
Comment 24 Mark S. Miller 2021-05-07 15:42:49 PDT
Created attachment 428051 [details]
snapshot of demo source used by that page
Comment 25 Mark S. Miller 2021-05-07 15:47:44 PDT
https://github.com/endojs/endo/blob/0b289021eee1256c05ceb4d83318165cb6288844/packages/ses/src/enable-property-overrides.js#L87

https://github.com/endojs/endo/blob/0b289021eee1256c05ceb4d83318165cb6288844/packages/ses/src/commons.js#L50

Github permalinks into the actual sources that lockdown.umd.js is built from. These specific links that the infinite recursion ping pongs between.
Comment 26 Mark S. Miller 2021-05-07 15:50:09 PDT
I just now noticed my old reproduction advice at https://bugs.webkit.org/show_bug.cgi?id=222538#c8

I have not tried it, but nothing relevant has changed. I suspect that will also work.
Comment 27 Mark S. Miller 2021-05-07 15:58:48 PDT
Ignore my last statement. The reproduction instructions from #c8 may not work. Relevant things are different. Use the reproduction instructions I gave you today.
Comment 28 Yusuke Suzuki 2021-06-03 00:04:27 PDT
(In reply to Mark S. Miller from comment #27)
> Ignore my last statement. The reproduction instructions from #c8 may not
> work. Relevant things are different. Use the reproduction instructions I
> gave you today.

Could you test it on Safari Technology Preview?
Comment 29 Yusuke Suzuki 2021-06-09 21:47:06 PDT
> I have some evidence that this bug happened again under Safari Version 14.1 (16611.1.21.161.3) *in the debugger* with weaker evidence that it did not happen for the same code not under the debugger. Until I know more I'm not reopening. But posting this anyway it case it rings a bell.

Safari 14.1 does not include this change. So closing this issue.
Please reopen when you reproduced it with Safari Technology Preview :)
Thanks!