Closed Bug 1511318 Opened 6 years ago Closed 5 years ago

Shutdown leaks in socket process

Categories

(Core :: Networking, enhancement, P2)

enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1513059

People

(Reporter: kershaw, Assigned: kershaw)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 obsolete file)

I just found out that we have some shutdown leaks in socket process.

0:43.42 INFO == BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS, socket process 99832
 0:43.42 INFO
 0:43.42 INFO      |<----------------Class--------------->|<-----Bytes------>|<----Objects---->|
 0:43.42 INFO      |                                      | Per-Inst   Leaked|   Total      Rem|
 0:43.42 INFO    0 |TOTAL                                 |       50    89601|    8181     1401|
 0:43.42 INFO    7 |AsyncFreeSnowWhite                    |       40       40|       1        1|
 0:43.42 INFO   14 |CacheObserver                         |       48       48|       1        1|
 0:43.42 INFO   21 |CondVar                               |       80       80|      47        1|
 0:43.42 INFO   26 |CycleCollectedJSContext               |    20424    20424|       1        1|
 0:43.42 INFO   27 |CycleCollectedJSRuntime               |      408      408|       1        1|
 0:43.42 INFO   32 |DR_State                              |       48       48|       1        1|
 0:43.42 INFO   38 |FallbackEncoding                      |       48       48|       1        1|
 0:43.42 INFO   49 |IdlePeriod                            |       24       24|       1        1|
 0:43.42 INFO   52 |JSRuntime                             |    22640    22640|       1        1|
 0:43.42 INFO   55 |LineBreaker                           |       16       16|       1        1|
 0:43.42 INFO   61 |Mutex                                 |      104      728|     340        7|
 0:43.42 INFO   64 |NullPrincipalURI                      |      104      208|       2        2|
 0:43.42 INFO   91 |PollableEvent                         |       32       32|       1        1|
 0:43.42 INFO   96 |ProtoAndIfaceCache                    |       16       16|       1        1|
 0:43.42 INFO  107 |SandboxPrivate                        |      128      128|       1        1|
 0:43.42 INFO  110 |SharedFontList                        |       16      112|       7        7|
 0:43.42 INFO  118 |StorageObserver                       |       72       72|       1        1|
 0:43.42 INFO  122 |TRRService                            |      312      312|       1        1|
 0:43.42 INFO  126 |ThreadEventTarget                     |       48       48|       6        1|
 0:43.42 INFO  129 |ThreadTargetSink                      |       16       16|       6        1|
 0:43.42 INFO  139 |WordBreaker                           |       16       16|       1        1|
 0:43.42 INFO  140 |XPCJSContext                          |      112      112|       1        1|
 0:43.42 INFO  141 |XPCJSRuntime                          |      864      864|       1        1|
 0:43.42 INFO  142 |XPCLocaleCallbacks                    |       40       40|       1        1|
 0:43.42 INFO  144 |XPCWrappedNativeScope                 |      112      112|       1        1|
 0:43.42 INFO  152 |mozJSComponentLoader                  |      232      232|       1        1|
 0:43.42 INFO  171 |nsContentUtils::UserInteractionObserve|       32       32|       1        1|
 0:43.42 INFO  176 |nsDNSService                          |      272      272|       1        1|
 0:43.42 INFO  181 |nsFocusManager                        |      120      120|       1        1|
 0:43.42 INFO  182 |nsHTMLDNSPrefetch::nsDeferrals        |     8264     8264|       1        1|
 0:43.42 INFO  183 |nsHTMLDNSPrefetch::nsListener         |       24       24|       1        1|
 0:43.42 INFO  187 |nsHtml5AttributeName                  |       32    15776|     493      493|
 0:43.42 INFO  188 |nsHtml5ElementName                    |       40     8320|     208      208|
 0:43.42 INFO  189 |nsHtml5HtmlAttributes                 |      384      384|       1        1|
 0:43.42 INFO  199 |nsIDNService                          |      184      184|       1        1|
 0:43.42 INFO  200 |nsIOService                           |      304      304|       1        1|
 0:43.42 INFO  204 |nsJSPrincipals                        |       24       72|       3        3|
 0:43.42 INFO  205 |nsLayoutStatics                       |        1        1|       1        1|
 0:43.42 INFO  221 |nsPrefBranch                          |      112      112|       3        1|
 0:43.42 INFO  224 |nsRect                                |       16       16|       1        1|
 0:43.42 INFO  226 |nsScriptSecurityManager               |       64       64|       1        1|
 0:43.42 INFO  229 |nsSocketTransportService              |      360      360|       1        1|
 0:43.42 INFO  232 |nsStaticCaseInsensitiveNameTable      |       64      256|       4        4|
 0:43.42 INFO  234 |nsStringBuffer                        |       12     6768|    2635      564|
 0:43.42 INFO  239 |nsTArray_base                         |        8      536|    2086       67|
 0:43.42 INFO  240 |nsThread                              |      192      192|      15        1|
 0:43.42 INFO  246 |nsTimer                               |       32       32|      45        1|
 0:43.42 INFO  248 |nsTimerImpl                           |      240      240|      45        1|
 0:43.42 INFO  251 |nsUUIDGenerator                       |      128      128|       1        1|
 0:43.42 INFO  252 |nsWeakReference                       |       40       80|      33        2|
 0:43.43 INFO  254 |nsXBLService                          |       32       32|       1        1|
 0:43.43 INFO  255 |nsXPConnect                           |       40       40|       1        1|
 0:43.43 INFO  256 |nsXULPopupManager                     |      120      120|       1        1|
 0:43.43 INFO  257 |xpc::CompartmentPrivate               |       48       48|       1        1|
 0:43.43 INFO
 0:43.43 INFO nsTraceRefcnt::DumpStatistics: 257 entries
 0:43.43 INFO TEST-INFO | leakcheck | socket process: leaked 1 AsyncFreeSnowWhite
TEST-INFO | leakcheck | socket process: leaked 1 CacheObserver
TEST-INFO | leakcheck | socket process: leaked 1 CondVar
TEST-INFO | leakcheck | socket process: leaked 1 CycleCollectedJSContext
TEST-INFO | leakcheck | socket process: leaked 1 CycleCollectedJSRuntime
TEST-INFO | leakcheck | socket process: leaked 1 DR_State
TEST-INFO | leakcheck | socket process: leaked 1 FallbackEncoding
TEST-INFO | leakcheck | socket process: leaked 1 IdlePeriod
TEST-INFO | leakcheck | socket process: leaked 1 JSRuntime
TEST-INFO | leakcheck | socket process: leaked 1 LineBreaker
TEST-INFO | leakcheck | socket process: leaked 7 Mutex
TEST-INFO | leakcheck | socket process: leaked 2 NullPrincipalURI
TEST-INFO | leakcheck | socket process: leaked 1 PollableEvent
TEST-INFO | leakcheck | socket process: leaked 1 ProtoAndIfaceCache
TEST-INFO | leakcheck | socket process: leaked 1 SandboxPrivate
TEST-INFO | leakcheck | socket process: leaked 7 SharedFontList
TEST-INFO | leakcheck | socket process: leaked 1 StorageObserver
TEST-INFO | leakcheck | socket process: leaked 1 TRRService
TEST-INFO | leakcheck | socket process: leaked 1 ThreadEventTarget
TEST-INFO | leakcheck | socket process: leaked 1 ThreadTargetSink
TEST-INFO | leakcheck | socket process: leaked 1 WordBreaker
TEST-INFO | leakcheck | socket process: leaked 1 XPCJSContext
TEST-INFO | leakcheck | socket process: leaked 1 XPCJSRuntime
TEST-INFO | leakcheck | socket process: leaked 1 XPCLocaleCallbacks
TEST-INFO | leakcheck | socket process: leaked 1 XPCWrappedNativeScope
TEST-INFO | leakcheck | socket process: leaked 1 mozJSComponentLoader
TEST-INFO | leakcheck | socket process: leaked 1 nsContentUtils::UserInteractionObserve
TEST-INFO | leakcheck | socket process: leaked 1 nsDNSService
TEST-INFO | leakcheck | socket process: leaked 1 nsFocusManager
TEST-INFO | leakcheck | socket process: leaked 1 nsHTMLDNSPrefetch::nsDeferrals
TEST-INFO | leakcheck | socket process: leaked 1 nsHTMLDNSPrefetch::nsListener
TEST-INFO | leakcheck | socket process: leaked 493 nsHtml5AttributeName
TEST-INFO | leakcheck | socket process: leaked 208 nsHtml5ElementName
TEST-INFO | leakcheck | socket process: leaked 1 nsHtml5HtmlAttributes
TEST-INFO | leakcheck | socket process: leaked 1 nsIDNService
TEST-INFO | leakcheck | socket process: leaked 1 nsIOService
TEST-INFO | leakcheck | socket process: leaked 3 nsJSPrincipals
TEST-INFO | leakcheck | socket process: leaked 1 nsLayoutStatics
TEST-INFO | leakcheck | socket process: leaked 1 nsPrefBranch
TEST-INFO | leakcheck | socket process: leaked 1 nsRect
TEST-INFO | leakcheck | socket process: leaked 1 nsScriptSecurityManager
TEST-INFO | leakcheck | socket process: leaked 1 nsSocketTransportService
TEST-INFO | leakcheck | socket process: leaked 4 nsStaticCaseInsensitiveNameTable
TEST-INFO | leakcheck | socket process: leaked 564 nsStringBuffer
TEST-INFO | leakcheck | socket process: leaked 67 nsTArray_base
TEST-INFO | leakcheck | socket process: leaked 1 nsThread
TEST-INFO | leakcheck | socket process: leaked 1 nsTimer
TEST-INFO | leakcheck | socket process: leaked 1 nsTimerImpl
TEST-INFO | leakcheck | socket process: leaked 1 nsUUIDGenerator
TEST-INFO | leakcheck | socket process: leaked 2 nsWeakReference
TEST-INFO | leakcheck | socket process: leaked 1 nsXBLService
TEST-INFO | leakcheck | socket process: leaked 1 nsXPConnect
TEST-INFO | leakcheck | socket process: leaked 1 nsXULPopupManager
TEST-INFO | leakcheck | socket process: leaked 1 xpc::CompartmentPrivate
 0:43.44 ERROR TEST-UNEXPECTED-FAIL | leakcheck | socket process: 89601 bytes leaked (AsyncFreeSnowWhite, CacheObserver, CondVar, CycleCollectedJSContext, CycleCollectedJSRuntime, ...)
Assignee: nobody → kershaw
Blocks: socket-proc
Priority: -- → P2
Whiteboard: [necko-triaged]
Actually, we don't need layout module in socket process, I think we should not load it.
This patch also fixes another shutdown crash in nsStandardURL.cpp. The crash is caused because |gAllURLsMutex| is not initialized. So, simply initialized it in nsStandardURL::InitGlobalObjects.
Should this block socket-proc-webrtc?
(In reply to Kershaw Chang [:kershaw] from comment #1)
> The leak is caused because the layout module is initialized at [1], but the
> unload function [2] is not called at shutdown.
> 

The reason why unload function is not called is at [1]. Layout module is not even loaded in socket process, although nsLayoutModuleInitialize() is still called.



[1] https://searchfox.org/mozilla-central/rev/8f0db72fb6e35414fb9a6fc88af19c69f332425f/xpcom/components/nsComponentManager.h#202
I found another crash [1] caused by not initializing layout module in socket process.
Please see the stack below.

Assertion failure: sInstance, at /Users/changkershaw/work/gecko/layout/xul/nsXULPopupManager.cpp:205
#01: nsBaseWidget::GetActiveRollupListener()[/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x3888416]
#02: -[AppShellDelegate beginMenuTracking:][/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x392c444]
#03: __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__[/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation +0x9aedc]
#04: ___CFXRegistrationPost_block_invoke[/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation +0x9ae5f]
#05: __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__[/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation +0xa387c]
#06: __CFRunLoopDoBlocks[/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation +0x86253]
#07: __CFRunLoopRun[/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation +0x86018]
#08: CFRunLoopRunSpecific[/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation +0x85153]
#09: RunCurrentEventLoopInMode[/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox +0x2fd96]
#10: ReceiveNextEventCommon[/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox +0x2fb06]
#11: _BlockUntilNextEventMatchingListInModeWithFilter[/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox +0x2f884]
#12: _DPSNextEvent[/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit +0x41a73]
#13: -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:][/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit +0x7d7e34]
#14: -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:][/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x392a170]
#15: -[NSApplication run][/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit +0x36885]
#16: nsAppShell::Run()[/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x392baf2]
#17: XRE_RunAppShell()[/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x51def03]
#18: mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*)[/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x7efd12]
#19: MessageLoop::Run()[/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x79a0e7]
#20: XRE_InitChildProcess(int, char**, XREChildData const*)[/Users/changkershaw/work/gecko/obj-x86_64-apple-darwin17.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x51de941]

Note that this crash only happens on OSX when I open a popup menu somewhrere else.
The |sInstance| is null because nsXULPopupManager::Init [2] is not called.

I think maybe we still need to load and initialize the whole layout module in socket process just for safe. We can try to optimzlize later.
What do you think, Dragana?

[1] https://searchfox.org/mozilla-central/rev/fd62b95c187a40b328d9e7fd9d848833a6942b57/layout/xul/nsXULPopupManager.cpp#183
[2] https://searchfox.org/mozilla-central/rev/fd62b95c187a40b328d9e7fd9d848833a6942b57/layout/build/nsLayoutStatics.cpp#214
Flags: needinfo?(dd.mozilla)
We may take approach from bug 1513059 and try to load mininal XPCOM + what is needed.

nsXULPopupManager::Init should be called for other processes, we do not need it on the socket process.
Flags: needinfo?(dd.mozilla)
(In reply to Dragana Damjanovic [:dragana] from comment #6)
> We may take approach from bug 1513059 and try to load mininal XPCOM + what
> is needed.
> 
> nsXULPopupManager::Init should be called for other processes, we do not need
> it on the socket process.

Agree. I've tried to run minimal xpcom on osx and it seems to work fine.

However, I am under the impression that minimal xpcom might have some issues on windows.
Honza, could you try to apply the patch in bug 1513059 and see if minimal xpcom works?

Thanks.
Flags: needinfo?(honzab.moz)
I looked into the rdd process that use the minimal xpcom and I tried to copy it. It is not much additional things we need to do.
(In reply to Kershaw Chang [:kershaw] from comment #7)
> (In reply to Dragana Damjanovic [:dragana] from comment #6)
> > We may take approach from bug 1513059 and try to load mininal XPCOM + what
> > is needed.
> > 
> > nsXULPopupManager::Init should be called for other processes, we do not need
> > it on the socket process.
> 
> Agree. I've tried to run minimal xpcom on osx and it seems to work fine.
> 
> However, I am under the impression that minimal xpcom might have some issues
> on windows.
> Honza, could you try to apply the patch in bug 1513059 and see if minimal
> xpcom works?
> 
> Thanks.

I think I can use try server to figure this out. Sorry if I bothered you.
Flags: needinfo?(honzab.moz)
(In reply to Dragana Damjanovic [:dragana] from comment #8)
> I looked into the rdd process that use the minimal xpcom and I tried to copy
> it. It is not much additional things we need to do.

Close this bug since we want to use minimal xpcom.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Attachment #9028920 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: