Proposal: Disallow main thread blocking by default

33 views
Skip to first unread message

Alon Zakai

unread,
Oct 18, 2019, 2:12:59 PM10/18/19
to emscripte...@googlegroups.com
See


in which we propose to throw when doing a pthread_join or another operation on the main thread which can block for a nontrivial amount of time. The possible deadlocks that can hit have been a serious problem for new users of pthreads on the Web.

You can still use pthread_join etc. on the main thread, you just need to flip a flag. The error by default points people to the docs that explain the possible risks, and hopefully encourages people to use alternatives (like not blocking, or using PROXY_TO_PTHREAD, etc., all mentioned in those docs).

This will slightly inconvenience existing users (that will see an error and must then flip the flag) but should help new users avoid confusing deadlocks, which I think is a reasonable tradeoff.

Thoughts?

- Alon

Gabriel Cuvillier

unread,
Oct 18, 2019, 5:07:25 PM10/18/19
to emscripte...@googlegroups.com

Thoughts that's OK, even if there's an inconvenience for existing users. At least, we know in advance that something might break, so that's fine :)

Maybe instead of "throwing", just reporting an error in the web console would be sufficient though.  If "STRICT=1" is set (which should be probably encouraged in the doc btw), then it would really throw, unless a flag is explicitly set. Well, that's just an idea..

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpTYBTZfZXOEDKJ%3DeStJePW1WbU%3Dtu4jKZJpyPushKMgTA%40mail.gmail.com.

Alon Zakai

unread,
Oct 21, 2019, 3:57:28 PM10/21/19
to emscripte...@googlegroups.com
Just warning in the console is another option, yeah, which is less disruptive. It might be less noticeable, though, and a specific problem is that if the main thread blocks then the console logging might not be visible (at least in chrome, if the devtools were not already open). So I'm not sure which is better overall.

Reply all
Reply to author
Forward
0 new messages