xpcshell-tests: add a fake shutdown function

RESOLVED WONTFIX

Status

Testing
XPCShell Harness
--
enhancement
RESOLVED WONTFIX
9 years ago
6 months ago

People

(Reporter: sgautherie, Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [needs testing on Mac])

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

9 years ago
Bug 489585 Comment 2:
{
From  Serge Gautherie (:sgautherie)   2009-04-22 10:08:52 PDT

could [...] the fake shutdown function move to <testing/xpcshell/head.js>.
I guess it could be used in other tests...
}

Bug 489585 Comment 4:
{
From  Ehsan Akhgari [:ehsan]   2009-04-22 10:13:40 PDT

That's a good idea [...]
Can you please file a new bug for that and assign it to me?
}

This function should be available to tests which need to use this feature.
Should the harness call it after each test?
What does the fake shutdown function do?
(Reporter)

Comment 2

9 years ago
Something like
{
+  // simulate shutdown
+  var obs = Cc["@mozilla.org/observer-service;1"].
+            getService(Ci.nsIObserverService);
+  obs.notifyObservers(null, "quit-application", "shutdown");
+  obs.notifyObservers(null, "profile-change-net-teardown", "shutdown");
+  obs.notifyObservers(null, "profile-change-teardown", "shutdown");
+  obs.notifyObservers(null, "profile-before-change", "shutdown-cleanse");
+  obs.notifyObservers(null, "xpcom-shutdown", "");
}
Ok. I think this can live in head.js, but it should be an optional function call, not something that all tests have to run.

Comment 4

9 years ago
Created attachment 396134 [details] [diff] [review]
Patch (v1)
Attachment #396134 - Flags: review?(ted.mielczarek)
(Reporter)

Comment 5

9 years ago
Comment on attachment 396134 [details] [diff] [review]
Patch (v1)

>+  var obs = Cc["@mozilla.org/observer-service;1"].
>+            getService(Ci.nsIObserverService);

Does 'Cc' and 'Ci' actually exist here?

It would be good to add a test for this function.
I guess the tests in the tree can be switched in follow-up patches.

Updated

9 years ago
Blocks: 512444

Updated

9 years ago
Blocks: 512445

Updated

9 years ago
Blocks: 512446

Comment 6

9 years ago
Created attachment 396421 [details] [diff] [review]
Patch (v2)

(In reply to comment #5)
> (From update of attachment 396134 [details] [diff] [review])
> >+  var obs = Cc["@mozilla.org/observer-service;1"].
> >+            getService(Ci.nsIObserverService);
> 
> Does 'Cc' and 'Ci' actually exist here?

Oh, of course not.  Silly me.  I fixed that.

> It would be good to add a test for this function.

Done.

> I guess the tests in the tree can be switched in follow-up patches.

I was going to do that, but considering that the number of places this can be used in the tree is not much, I merged those into this patch as well.

There were three places where do_shutdown might be useful but using it wasn't either obvious or lead to crashes.  I filed bug 512444, bug 512445 and bug 512446 for them.
Attachment #396134 - Attachment is obsolete: true
Attachment #396421 - Flags: review?(ted.mielczarek)
Attachment #396134 - Flags: review?(ted.mielczarek)

Comment 7

9 years ago
The try server runs on Mac turned out some (intermittent) failures.  Here's the first log:

<http://tinderbox.mozilla.org/showlog.cgi?log=MozillaTry/1251204541.1251211830.30514.gz>

and here's the second log:

<http://tinderbox.mozilla.org/showlog.cgi?log=MozillaTry/1251211956.1251220507.5725.gz>

These seem like xpcshell crashes after the shutdown notifications being dispatched.  Can someone with a Mac give a shot at debugging these?
Comment on attachment 396421 [details] [diff] [review]
Patch (v2)

Thanks for adding the test, that looks good. I'd like to have some followup on the intermittent crashes here before landing this, though. I'll see if I can find time to test this patch on my mac.
Attachment #396421 - Flags: review?(ted.mielczarek) → review+

Comment 9

9 years ago
(In reply to comment #8)
> (From update of attachment 396421 [details] [diff] [review])
> Thanks for adding the test, that looks good. I'd like to have some followup on
> the intermittent crashes here before landing this, though. I'll see if I can
> find time to test this patch on my mac.

That would be great, thanks!
Whiteboard: [needs testing on Mac]
Ok, found time to run this, and got you a stack:
TEST-UNEXPECTED-FAIL | /Users/luser/build/obj-firefox/_tests/xpcshell/test_privatebrowsing/unit/test_privatebrowsing_exit.js | application crashed (minidump found)
Operating system: Mac OS X
                  10.5.8 9L30
CPU: x86
     GenuineIntel family 6 model 15 stepping 6
     2 CPUs

Crash reason:  EXC_BAD_ACCESS / KERN_PROTECTION_FAILURE
Crash address: 0x5

Thread 0 (crashed)
 0  CoreFoundation + 0x75354
    eip = 0x95bc6354   esp = 0xbfffeda0   ebp = 0xbfffedb8   ebx = 0x95bc633a
    esi = 0x00000000   edi = 0x029a7a53   eax = 0x00000000   ecx = 0x0053ef80
    edx = 0x0000010e   efl = 0x00010246
 1  XUL!nsNetworkLinkService::Observe(nsISupports*, char const*, unsigned short const*) [nsNetworkLinkService.mm:960c4a6b5b23 : 160 + 0xd]
    eip = 0x01ebe861   esp = 0xbfffedc0   ebp = 0xbfffee08
 2  XUL!nsObserverList::NotifyObservers(nsISupports*, char const*, unsigned short const*) [nsObserverList.cpp:960c4a6b5b23 : 128 + 0x19]
    eip = 0x0287690e   esp = 0xbfffee10   ebp = 0xbfffee48
 3  XUL!nsObserverService::NotifyObservers(nsISupports*, char const*, unsigned short const*) [nsObserverService.cpp:960c4a6b5b23 : 182 + 0x19]
    eip = 0x02876cca   esp = 0xbfffee50   ebp = 0xbfffee78
 4  XUL!mozilla::ShutdownXPCOM(nsIServiceManager*) [nsXPComInit.cpp:960c4a6b5b23 : 766 + 0x20]
    eip = 0x0286dbbd   esp = 0xbfffee80   ebp = 0xbfffeee8
 5  xpcshell!main [xpcshell.cpp:960c4a6b5b23 : 1795 + 0xb]
    eip = 0x0000457a   esp = 0xbfffeef0   ebp = 0xbffff028
 6  xpcshell + 0xb45
    eip = 0x00001b46   esp = 0xbffff030   ebp = 0xbffff04c
 7  0x10
    eip = 0x00000011   esp = 0xbffff054   ebp = 0x00000000

That top frame is in "CFRelease". This makes sense, as you're crashing right here:
http://mxr.mozilla.org/mozilla-central/source/netwerk/system/mac/nsNetworkLinkService.mm#160

We have the network detection stuff disabled in xpcshell, so I guess that's why this crashes, although we also have it disabled in Mochitest etc, so I'm not sure why it's only crashing here. We could probably just add NULL checks there, or figure out a better solution, I'm not sure. Might want to ask someone who's reviewed that code, dcamp wrote it but he's not around now.

Comment 11

8 years ago
Updating to reality: I won't have enough time to look into this in the near future.
Assignee: ehsan → nobody

Updated

8 years ago
Status: ASSIGNED → NEW
Mass closing bugs with no activity in 2+ years. If this bug is important to you, please re-open.
Status: NEW → RESOLVED
Last Resolved: 6 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.