[whatwg] Race condition in media load algorithm

On Mon, 2 Aug 2010, Chris Pearce wrote:
>
> There's a race condition in the media load algorithm. When the resource 
> selection algorithm begins, it sets a task to complete the rest of the 
> resource selection algorithm asynchronously.

Not quite. It awaits a stable state and then runs a synchronous section, 
which means that it will run the subsequent steps as soon as the current 
task has finished, before anything else that is queued.

Thus:

> In the asynchronous task, we set the delaying-the-load-event flag to 
> true at step 4. But between the resource selection algorithm setting the 
> task to asynchronously continue the algorithm, and the task actually 
> running, the load event could fire

...the load event couldn't fire, because the load event is queued as a 
task, which will execute at the earliest _after_ the synchronous section 
has run (unless the task was queued before the task in which the resource 
selection algorithm was invoked started, of course). I don't think there's 
anything defined that delays the load event which can finish without a 
task executing. (And even if there was, moving this particular step around 
wouldn't change things other than theoretically making the race condition 
window a bit smaller.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 2 August 2010 02:17:55 UTC