Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec percent-scripts-timeout #1341

Merged
merged 41 commits into from
Nov 26, 2024
Merged

Spec percent-scripts-timeout #1341

merged 41 commits into from
Nov 26, 2024

Conversation

morlovich
Copy link
Collaborator

@morlovich morlovich commented Nov 20, 2024

Also fixes a bug where script timeout wasn't applied to top-level execution.


Preview | Diff

@morlovich morlovich added the spec Relates to the spec label Nov 20, 2024
@morlovich
Copy link
Collaborator Author

Pretty small one this time.


1. [=Assert=] that these steps are running [=in parallel=].

1. If |timeout| ≤ 0, [=immediately=] interrupt the execution and set |finalCompletion| to a
new [=ECMAScript/throw completion=] given null.
1. If |timeout| ≤ 0, return (new [=ECMAScript/throw completion=] given null, true).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update line 5745 below as well to return an extra false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.... good catch, though this needs more work: the timeout applies to top-level execution as well. I am gonna need an extra moment on that.

(Actually it also affects WebIDL conversions of return values, since otherwise one could smuggle entire computation into them, but I am not sure how one even hooks that)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, but kinda hand-wavish. PTAL.

Copy link
Collaborator

@qingxinwu qingxinwu Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for webIDL conversion you mentioned, is it https://github.com/WICG/turtledove/blob/main/spec.bs#L5620, or something else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. That can run arbitrary code[1] (so it probably ought to be explicit about what context it runs in).
Same for scoreAd. Compare to:

https://source.chromium.org/chromium/chromium/src/+/main:content/services/auction_worklet/seller_worklet.cc;drc=b41d6ee12deac18fac89f4d27c2a662e311406fc;l=1232

(which I think I owe refactor of, but it's a little easier to read for this purpose than the bidder equivalent since the business stuff isn't hidden in the binding. Notice how it uses the same time limit; the v8_helper also provides the context).

[1] We have a couple other places this used where we start with more restricted types (sometimes infra types) where nothing funky can happen, as it's doing some sort of "round a double to int" type deals. It's where the source is an Object that JS gets... JS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@qingxinwu qingxinwu Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the js->idl conversion need the script's context? It does not seem so, IIUC. Then we can probably return the remaining timeout after script execution, and apply it to the js->IDL conversion step?
Not suggesting to do it in this PR, but wondering whether and how we fix it in spec.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the context isn't explicit in the way the WebIDL and ES262 specs works, e.g. it calls ops like this:
https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tonumber

Compare to:
https://source.chromium.org/chromium/chromium/src/+/main:v8/include/v8-value.h;drc=6ac7875f61c72fa111bc501039e4673693be6b64;l=384

...so I suppose returning the remaining timeout and having a similar thing about timeouts on those spec is appropriate.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good.

spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
Copy link
Collaborator

@qingxinwu qingxinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % one question


1. [=Assert=] that these steps are running [=in parallel=].

1. If |timeout| ≤ 0, [=immediately=] interrupt the execution and set |finalCompletion| to a
new [=ECMAScript/throw completion=] given null.
1. If |timeout| ≤ 0, return (new [=ECMAScript/throw completion=] given null, true).
Copy link
Collaborator

@qingxinwu qingxinwu Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for webIDL conversion you mentioned, is it https://github.com/WICG/turtledove/blob/main/spec.bs#L5620, or something else?

@JensenPaul JensenPaul merged commit 4a5cbfb into WICG:main Nov 26, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Nov 26, 2024
SHA: 4a5cbfb
Reason: push, by JensenPaul

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to morlovich/turtledove that referenced this pull request Nov 26, 2024
SHA: 4a5cbfb
Reason: push, by morlovich

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec Relates to the spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants