Closed Bug 1295349 Opened 3 years ago Closed 3 years ago

Calling UDPSocketParent::Init() on IPDL Background asserts

Categories

(Core :: Networking, defect)

51 Branch
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: drno, Assigned: jduell.mcbugs)

Details

(Whiteboard: [necko-active])

Attachments

(1 file)

When executing a webrtc test page from an external third party I'm hitting this. Looks like the Preference code doesn't like to be executed on the IPDL Background thread.

2016-08-15 22:45:48.006495 UTC - [mtransport]: D/UDPSocket Bind: 10.0.1.3:0
Assertion failure: NS_IsMainThread(), at /Users/nohlmeier/src/mozilla-central/modules/libpref/Preferences.cpp:233
#01: mozilla::HaveExistingCacheFor(void*)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x265580]
#02: mozilla::AssertNotAlreadyCached(char const*, char const*, void*)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x25656d]
#03: mozilla::Preferences::AddBoolVarCache(bool*, char const*, bool)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x25db75]
#04: mozilla::net::UsingNeckoIPCSecurity()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x7f1f9d]
#05: mozilla::dom::UDPSocketParent::Init(IPC::Principal const&, nsACString_internal const&)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x43f520e]
#06: mozilla::ipc::BackgroundParentImpl::RecvPUDPSocketConstructor(mozilla::net::PUDPSocketParent*, mozilla::ipc::OptionalPrincipalInfo const&, nsCString const&)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xb79c3e]
#07: mozilla::ipc::PBackgroundParent::OnMessageReceived(IPC::Message const&)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x11ac196]
#08: mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xb9f5c9]
#09: mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message&&)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xb9e3b4]
#10: mozilla::ipc::MessageChannel::OnMaybeDequeueOne()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xb97372]
#11: decltype(*(fp).*fp0(Get<>(fp1).PassAsParameter())) mozilla::detail::RunnableMethodArguments<>::applyImpl<mozilla::ipc::MessageChannel, bool (mozilla::ipc::MessageChannel::*)()>(mozilla::ipc::MessageChannel*, bool (mozilla::ipc::MessageChannel::*)(), mozil[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xbc4e7a]
#12: _ZN7mozilla6detail23RunnableMethodArgumentsIJEE5applyINS_3ipc14MessageChannelEMS5_FbvEEEDTcl9applyImplfp_fp0_dtdefpT10mArgumentscvNS_13IndexSequenceIJEEE_EEEPT_T0_[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xbc4de9]
#13: mozilla::detail::RunnableMethodImpl<bool (mozilla::ipc::MessageChannel::*)(), false, true>::Run()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xbc4bb2]
#14: mozilla::ipc::MessageChannel::RefCountedTask::Run()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xbc1912]
#15: mozilla::ipc::MessageChannel::DequeueTask::Run()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xbc16a8]
#16: nsThread::ProcessNextEvent(bool, bool*)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x1c15b9]
#17: NS_ProcessNextEvent(nsIThread*, bool)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x24cfac]
#18: mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xba35bd]
#19: MessageLoop::RunInternal()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xaab895]
#20: MessageLoop::RunHandler()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xaab7f5]
#21: MessageLoop::Run()[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xaab79d]
#22: nsThread::ThreadFunc(void*)[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x1bee78]
#23: _pt_root[/Users/nohlmeier/src/mozilla-central/obj-x86_64-apple-darwin15.6.0/dist/NightlyDebug.app/Contents/MacOS/libnss3.dylib +0x2956ed]
#24: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x399d]
#25: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x391a]
Process 28776 stopped
* thread #36: tid = 0x72d0e2, 0x0000000102897590 XUL`mozilla::HaveExistingCacheFor(aPtr=0x000000010d10c7f0) + 80 at Preferences.cpp:233, name = 'IPDL Background', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000102897590 XUL`mozilla::HaveExistingCacheFor(aPtr=0x000000010d10c7f0) + 80 at Preferences.cpp:233
   230 	static bool
   231 	HaveExistingCacheFor(void* aPtr)
   232 	{
-> 233 	  MOZ_ASSERT(NS_IsMainThread());
   234 	  if (gCacheData) {
   235 	    for (size_t i = 0, count = gCacheData->Length(); i < count; ++i) {
   236 	      if ((*gCacheData)[i]->cacheLocation == aPtr) {
--DOMWINDOW == 2 (0x126e51c00) [pid = 28790] [serial = 2] [o
Jason - looks like you're responsible for the code in question. I guess you never assumed UsingNeckoIPCSecurity would be called off-main-thread :) Not sure where the right fix for this lies, but maybe you'll know/remember better. If not, we can just keep this as a next item.
Flags: needinfo?(jduell.mcbugs)
Whiteboard: [necko-next]
cc'd dragana since she's touched UDP/TCPSocket
Attached patch v1Splinter Review
So IIUC this can only happen if the very first channel at startup is a UDP socket.

This ought to fix it--I moved the code to NeckoParent init time.
Assignee: nobody → jduell.mcbugs
Status: NEW → ASSIGNED
Flags: needinfo?(jduell.mcbugs)
Attachment #8782762 - Flags: review?(hurley)
Nils,

Can you confirm that this patch fixes your issue?  If you need a build, one should be showing up soon in

   https://ftp.mozilla.org/pub/firefox/try-builds/

with a name like "jduell@mozilla-64406cb5d662"
Flags: needinfo?(drno)
Whiteboard: [necko-next] → [necko-active]
I loaded the test case about 15 times on a local debug build with the patch applied and I never got any assertion (where before I would get the assertion 75% of time).
So this appears to fix the problem.

Thanks a bunch for the super quick turn around time.
Flags: needinfo?(drno)
Attachment #8782762 - Flags: review?(hurley) → review+
2nd try run (comment 8) looks good.
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5e4e6204c222
Assert in UDPSocketParent::Init(). r=hurley
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/5e4e6204c222
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.