potential race on idFunc and idFuncClosure in plevent.c




13 years ago
12 years ago


(Reporter: Jeffrey J. Cook, Assigned: dougt)



Firefox Tracking Flags

(Not tracked)




13 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050616 Firefox/1.0+

In xpcom/threads/plevent.c, there is a potential race condition that could cause
badness on variables idFunc and idFuncClosure.  This occurs between functions
PL_PostEvent and PL_RegisterEventIDFunc.  PL_RegisterEventIDFunc could update
the idFunc function pointer but not have updated the idFuncClosure data when
PL_PostEvent performs the function invocation idFunc(idFuncClosure), since only
the non-NULLness of idFunc is tested before executing the function pointer.

From plevent.c:PL_PostEvent:

#if defined(XP_UNIX) && !defined(XP_MACOSX)
    if (self->idFunc && event)
        event->id = self->idFunc(self->idFuncClosure);

From plevent.c:PL_RegisterEventIDFunc

PL_RegisterEventIDFunc(PLEventQueue *aSelf, PLGetEventIDFunc aFunc,
                       void *aClosure)
    aSelf->idFunc = aFunc;
    aSelf->idFuncClosure = aClosure;

Solution that has a safe race:

PL_RegisterEventIDFunc(PLEventQueue *aSelf, PLGetEventIDFunc aFunc,
                        void *aClosure)
    aSelf->idFunc = 0; /* guard update so that incorrect closure is not applied */
    aSelf->idFuncClosure = aClosure; /* this must precede assigning idFunc */
    aSelf->idFunc = aFunc;

Reproducible: Always

Comment 1

13 years ago
I should add that I do not know if these two functions can execute in parallel
as I don't fully understand this module.  This bug was reported to me with Intel
Thread Checker and upon non-trivial inspection, I could not classify this as a
false positive.
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Last Resolved: 12 years ago
Resolution: --- → EXPIRED
Reopening for examination by someone who can yay/nay this.
Resolution: EXPIRED → ---

Comment 5

12 years ago
The code in question no longer exists.  See bug 326273.
Last Resolved: 12 years ago12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.