W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2010

[whatwg] Race condition in media load algorithm

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 2 Aug 2010 09:17:55 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1008020908200.3056@ps20323.dreamhostps.com>
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

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:59 UTC