[whatwg] Worker feedback

On Tue, Apr 7, 2009 at 1:53 AM, Darin Fisher <darin at chromium.org> wrote:

> OK... so if I am building an API, the consumer of my API might not realize
> that I have stuck a sync XHR in the middle of it.  (People often do that so
> that their API can work during unload.)  So the consumer of such an API now
> has to deal with the cookie lock being released?
>

Yes. If sync XHR spins up a subsidiary event loop, the cookie lock is the
least of your worries, because event handlers may run and mutate arbitrary
script/DOM state. (We're actually tightening up what is allowed to run
during sync XHR in Gecko, but I don't know the details and I don't know what
other browsers do.)

APIs that can cause reentrancy, or block, or yield, need to be carefully
documented. That's why we want to minimize them...


> When deciding how to handle cookies in Chrome, we did not worry about the
>>> problem being debated here.  Our concerns were allayed by recognizing that
>>> IE does not try to solve it (and IE6 is multi-process just like Chrome with
>>> a shared network stack), so clearly web developers must already have to
>>> cope.
>>>
>>
>> You mean IE8.
>>
>
> No, IE6,7,8 (maybe older versions too?) ... you can launch multiple IE6
> processes, and those share cookies.  You can also programmatically access
> the same cookies via WinInet from any application.  It is not uncommon for a
> separate application to be mucking around with cookies for intranet.com.
>

OK, that's interesting.


> How would Web developers cope? There's no way to synchronize. I doubt more
>> than a handful of Web developers even know this problem could exist.
>>
>
> You can synchronize through the origin server...
>
> What I meant was that they "cope" by not expecting document.cookie to
> return the same results each time it is called.  I'd imagine it is not
> uncommon for users to login to a site in multiple windows and perform
> similar operations in each browser window.  That scenario seems like it
> could trigger what we have here.
>

Many sites, such as my bank, detect that and attempt to prohibit it by
refusing to let more than one window work. I wonder if they use a
race-vulnerable cookie protocol to detect it...


>
>> I think it would be best to specify that document.cookie returns a
>>> snapshot.  I think that is consistent with existing implementations
>>> including IE, Firefox, and Chrome.
>>>
>>
>> Not at all. In Firefox, cookies don't change while a script is running, as
>> long as it doesn't call the handful of blocking DOM APIs (such as alert() or
>> sync XHR); we satisfy the current spec.
>>
>
> I don't understand why the sync XHR exception is taken so lightly.  As I
> mention above, that is most frequently used as a
> transparent-to-the-rest-of-the-application way of communicating with the
> server (usually because some APIs cannot be easily changed or need to be
> available during unload).  Yet, here we are saying that that cannot be
> transparent because of this locking issue.
>

Yes. Making sync-XHR "transparent" by reducing all consistency guarantees to
what we can provide around sync-XHR is the wrong direction to go IMHO.


>
>> The insidious part is that almost all the time, IE and Chrome will also be
>> observed to obey the spec; when a quick cookie-read-modify-write script
>> runs, it is very unlikely cookies will change underneath it. (Is it possible
>> people don't write such scripts?)
>>
>
> I'm sure people write cookie-read-modify-write scripts and don't realize
> the potential problems.  But I suspect the incidents of problems related to
> two scripts doing so are extremely low as to not matter enough to
> application developers.  They can just say:  opening our webmail program in
> two browser tabs at the same time is not supported.
>

If they're not aware of the problem, why would they say that?


> Maybe we need dynamic race detection for Web browsers. After a script reads
>> document.cookie, stall for a while to give network transactions or scripts
>> running in other threads a chance to change the cookies so the original
>> script carries on with wrong data.
>>
>
> Sounds interesting, but what happens when the script writes cookies?  Now
> there is a merging problem :(
>

Oh, dynamic race detection is only good for finding bugs more easily, not
fixing them :-).

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090407/5eb18f53/attachment.htm>

Received on Monday, 6 April 2009 19:13:23 UTC