Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Sep 15, 2023

Fixes: #20264

@RReverser
Copy link
Collaborator

The tsst looks good but I'll defer to someone else to review the actual change.

addToLibrary({
foo__proxy: 'sync',
foo: () => setTimeout(() => {
console.log('should not see this');
Copy link
Member

Choose a reason for hiding this comment

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

Why should this not be seen? foo is called.

Copy link
Collaborator Author

@sbc100 sbc100 Sep 18, 2023

Choose a reason for hiding this comment

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

But the timeout here is 1000 seconds.. and the program exits before we even return to the event loop.

The bug here was that the outer setTimeout(() => { was being stripped by the jsifier code.. resulting in the console.log running directly rather than on a timeout.

Copy link
Member

Choose a reason for hiding this comment

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

It's 1000 ms, not seconds, so I can see a VM stall cause it to print.

I guess I'd be ok with 1000*60*15 (15 minutes) or such, as that is the timeout of CI anyhow...

Copy link
Member

@kripken kripken Sep 19, 2023

Choose a reason for hiding this comment

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

(lgtm with that, or more edit: with a comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah.. well in that case maybe we should make the value zero, assuming the test passes.

I removed the timeout completely and test still passes. Also added a comment.

Copy link
Member

Choose a reason for hiding this comment

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

(Was that change pushed? I still see a timeout, and don't see a comment about the timeout duration of 1000)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, I'm switching to using my own emscripten branch as origin and it can be confusing.

@sbc100 sbc100 requested a review from kripken September 19, 2023 16:45
@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 19, 2023

ping..

@sbc100 sbc100 enabled auto-merge (squash) September 20, 2023 15:34
@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 20, 2023

Should be good to land now.

foo__proxy: 'sync',
foo: () => setTimeout(() => {
console.log('should not see this before "done"');
}),
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this a little racey? A timeout of 0 means it will run in the next event loop iteration, but the runtime might exit before that? That is, we might get only "main" in the output, sometimes.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, wait, I misread this, done is not from here but from below.

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 problem is that the main thread which calls foo could hit its even loop at print "should not see this before "done"" from the setTimeout before the secondary thread sees that foo is complete and allow itself to continue executing and print "done"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The key here is that "foo" is proxied to the main thread.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes... it must be the proxying, yeah, good point.

@sbc100 sbc100 merged commit 3134b14 into main Sep 20, 2023
@sbc100 sbc100 deleted the fix_js_arrow_funcs branch September 20, 2023 18:13
sbc100 added a commit to sbc100/emscripten that referenced this pull request Sep 20, 2023
sbc100 added a commit that referenced this pull request Sep 20, 2023
@kripken
Copy link
Member

kripken commented Sep 20, 2023

@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 20, 2023

This errors on Mac and Windows:

https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8769407560182530897/+/u/Emscripten_testsuite__other_/stdout

https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8769407560182530913/+/u/Emscripten_testsuite__other_/stdout

Not sure why it's different on linux here on github?

Is this fixed by #20303?

Yes, it was flaky and #20303 fixes that.

@kripken
Copy link
Member

kripken commented Sep 20, 2023

I don't understand how it could be flakey, since "done" was printed synchronously... strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weird __proxy stripping for arrow functions

4 participants