Closed Bug 335734 Opened 19 years ago Closed 19 years ago

threadsafety problems in fix for bug 334605

Categories

(Core :: XPCOM, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8.1beta1

People

(Reporter: dbaron, Assigned: dbaron)

Details

(Keywords: fixed1.8.1, Whiteboard: [patch])

Attachments

(1 file)

There are threadsafety problems in the fix to bug 334605; see bug 334605 comment 10.
One solution is to make non-permanent atoms aware of REFCNT_PERMANENT_SENTINEL and not touch the refcount if it has that value. Another solution is to simply not promote atoms to permanent, it is just a perf optimization anyway. It'd be interesting to know how many atoms actually do get promoted during an average startup.
Flags: blocking1.9a1?
Flags: blocking1.8.1?
Another solution would be to use the old code but set the sentinel value only in the destructor.
Attached patch patchSplinter Review
This should fix it (a bunch of the changes are restoring the old code), although I'm not sure how valuable that is, since the atom table itself isn't threadsafe (it could return an atom that's in the process of being destroyed).
Attachment #220958 - Flags: superreview?(brendan)
Attachment #220958 - Flags: review?(bugmail)
Attachment #220958 - Flags: approval-branch-1.8.1?(brendan)
Status: NEW → ASSIGNED
Whiteboard: [patch]
Target Milestone: --- → mozilla1.8.1beta1
Comment on attachment 220958 [details] [diff] [review] patch Yeah, this looks like a good approach. Though I wonder if we can get away with not doing the IsPermanent check in the dtor at all. We could simply stick a flag on the atom-table saying that we're in the process or killing permanent atoms. r=sicking either way
Attachment #220958 - Flags: review?(bugmail) → review+
Comment on attachment 220958 [details] [diff] [review] patch > enum { REFCNT_PERMANENT_SENTINEL = PR_UINT32_MAX }; >- >- PRBool IsPermanent() { return mRefCnt == REFCNT_PERMANENT_SENTINEL; } >+ virtual PRBool IsPermanent(); >+ // We can't use the virtual function in the base class destructor. >+ PRBool IsPermanentInDestructor() { >+ return mRefCnt == REFCNT_PERMANENT_SENTINEL; >+ } A few blank lines to let this breathe (one before the comment at least, if not between the enum and the virtual method declaration) would be nice. rs=me again, with useless style comments. I'm not sure I'm adding value here. It does look like this fixes the bug. We need a followup bug for real thread safety. /be
Attachment #220958 - Flags: superreview?(brendan)
Attachment #220958 - Flags: superreview+
Attachment #220958 - Flags: approval-branch-1.8.1?(brendan)
Attachment #220958 - Flags: approval-branch-1.8.1+
So there's already a bug on it: bug 12755, although maybe bug 12914 should be reopened since it's a little less distracted.
Checked in to trunk and MOZILLA_1_8_BRANCH.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Flags: blocking1.9a1?
Flags: blocking1.8.1?
Keywords: fixed1.8.1
Priority: -- → P2
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: