Closed Bug 620194 Opened 14 years ago Closed 14 years ago

"ASSERTION: nsLoadGroup not thread-safe" under nsWyciwygCloseEvent::~nsWyciwygCloseEvent

Categories

(Core :: Networking, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b9
Tracking Status
blocking2.0 --- final+

People

(Reporter: jruderman, Assigned: michal)

References

Details

(Keywords: assertion, regression)

Attachments

(2 files)

Attached file stacks
Seen several times during fuzzing on Linux.  I have stacks but no steps to reproduce.

###!!! ASSERTION: nsLoadGroup not thread-safe: '_mOwningThread.GetThread() == PR_GetCurrentThread()', file netwerk/base/src/nsLoadGroup.cpp, line 204

###!!! ASSERTION: nsSimpleURI not thread-safe: '_mOwningThread.GetThread() == PR_GetCurrentThread()', file netwerk/base/src/nsSimpleURI.cpp, line 77
Is this happening at shutdown?  I can see this happening if the NS_DispatchToMainThread in ~nsWyciwygAsyncEvent fails: note that all the callstacks show the runnable method being destroyed there under the nsCOMPtr destructor.

Looks like a regression from bug 599127.
Blocks: 599127
blocking2.0: --- → ?
Yes, this is happening during shutdown.
Keywords: regression
Sounds like we should leak the channel rather than doing a wrong-thread release, in that situation.  :(  We have to do that a few other places in necko too.  :(
We shutdown the cache IO thread in nsCacheService::Shutdown() which happens on "xpcom-shutdown". It should be possible to post events to the main thread until this point, right? So is there any reason why NS_DispatchToMainThread could fail?


  // ensure we free our ref before event gets released on main thread
  mChannel = 0;
  NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);

We release the reference that is hold by mChannel, but event references the channel too. So is it still possible that the event is dispatched and processed on the main thread while we hold the reference on the background thread? If yes then this concept with MainReleaseNoOp() can't work reliably and we need to find another mechanism to ensure releasing the WyciwygChannel on the main thread.

The other option is to make nsLoadGroup and nsSimpleURI threadsafe.
> The other option is to make nsLoadGroup and nsSimpleURI threadsafe.

In some of my logs for this bug, there are thread-safety warnings for ~5 additional classes.
> So is it still possible that the event is dispatched and processed
> on the main thread while we hold the reference on the background thread?

Oh, hmm.  Yes, it's possible, I suppose; if we post the event and then lose our timeslice and then it runs.

So yes, I think this code is just broken.  Is there a reason you're reinventing NS_ProxyRelease here, btw?
> The other option is to make nsLoadGroup and nsSimpleURI threadsafe.

I don't think that's an option, fwiw.  The channel can entrain lots of other non-threadsafe stuff too; we should just proxy the release to the main thread correctly and be done with it.
Attached patch fixSplinter Review
(In reply to comment #6)
> So yes, I think this code is just broken.  Is there a reason you're reinventing
> NS_ProxyRelease here, btw?

There is no reason to not use NS_ProxyRelease. Attached patch fixes it.
Attachment #499418 - Flags: review?(bzbarsky)
Comment on attachment 499418 [details] [diff] [review]
fix

r=me
Attachment #499418 - Flags: review?(bzbarsky) → review+
Does this change need superreview?
imo, no.
Keywords: checkin-needed
Needs approval or blocking state to land.
Assignee: nobody → michal.novotny
Keywords: checkin-needed
blocking2.0: ? → final+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/840641b4d465
Status: NEW → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b9
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: