Re: Race conditions in HTML 5?

Bonner, Matt wrote:
> I see several places in the HTML 5 spec, where a UA is required
> to start executing something once all other scripts have stopped
> executing. It seems possible that this could lead to race 
> conditions, or deadlock, depending on use.

Matt, for that to happen you have to have some code that blocks on the result of 
the script execution, right?  Given the primitives available to web script (no 
synchronization primitives of any kind), that basically means busy-looping on a 
boolean that's modified outside of the loop.

But since the model exposed to JS is single-threaded, the value of the boolean 
can't change during such a loop, so this technique doesn't work either (no 
matter what HTML5 specifies in terms of waiting for scripts to finish executing).

This lack of ways to block script execution means it's very hard for web authors 
to shoot themselves in the foot here.

I suppose you could get more complicated situations in which one script's 
execution immediately causes another script's execution, I suppose, but I think 
part of the goal here is to prevent that: if a script adds more scripts to the 
DOM, they won't execute until all currently executing scripts are done.

-Boris

Received on Tuesday, 10 June 2008 04:50:47 UTC