[Xlib] nsDeviceContextXlib / nsGCCacheXlib destroyed twice

RESOLVED WORKSFORME

Status

Core Graveyard
GFX: Xlib
--
critical
RESOLVED WORKSFORME
15 years ago
9 years ago

People

(Reporter: Roland Mainz, Assigned: Roland Mainz)

Tracking

({crash})

Trunk
mozilla1.4beta
Sun
Solaris
crash

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: needs port to gtk?)

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

15 years ago
2003-03-11-08-trunk, Xlib port on Solaris 2.7/SPARC - the |nsDeviceContextXlib|
is destroyed twice at shutdown, causing confusion - and sometimes crashes.

The following output from the Xlib port shows that nsGCCacheXlib is being
destroyed twice, indicating the problem:
-- snip --
got a delete window event
nsWidget::OnDeleteWindow()
WARNING: NS_ENSURE_TRUE(presShell) failed, file
../../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/content/html/content/src/nsGenericHTMLElement.cpp,
line 2686
WEBSHELL- = 3
nsPluginHostImpl::Observe "quit-application"
WARNING: requested removal of nonexistent window
, file
../../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp,
line 937
WEBSHELL- = 2
WEBSHELL- = 1
WEBSHELL- = 0
GC Cache:
        hits:  492  422  210  204   36   16    5    2    0    7   21   14  
10    0    1    1    0    1    3    4    4   13    1    0    0    0    0    0   
1    0    1    2
        hits: 1471, misses: 215, hit percent: 87.247925%
### nsCacheProfilePrefObserver::Observe [topic=profile-before-change
data=shutdown-persist]
WARNING: not writing prefs because they haven't changed, file
../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/modules/libpref/src/nsPrefService.cpp,
line 225
###!!! ASSERTION: already initialized: '!sWidget', file
../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/widget/src/xlib/nsClipboard.cpp,
line 104
Break: at file
../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/widget/src/xlib/nsClipboard.cpp,
line 104
### nsCacheProfilePrefObserver::Observe [topic=xpcom-shutdown data=]
nsPluginHostImpl::Observe "xpcom-shutdown"
WARNING: nsExceptionService ignoring thread destruction after shutdown, file
../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/xpcom/base/nsExceptionService.cpp,
line 189
+++ JavaScript debuging hooks removed.
GC Cache:
        hits:    0    0    0    0    0    0    0    0    0    0    0    0   
0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0   
0    0    0    0
        hits: 0, misses: 0, hit percent: NaN%
nsPluginHostImpl dtor
JS engine warning: 1 atoms remain after destroying the JSRuntime.
                   These atoms may point to freed memory. Things reachable
                   through them have not been finalized.
-- snip --

Placing a conditional breakpoint in the nsGCCacheXlib code returns the following
stacktrace:
-- snip --
(dbx) where
current thread: t@1
=>[1] nsGCCacheXlib::ReportStats(this = 0x4b4210), line 112 in "nsGCCache.cpp"
  [2] nsGCCacheXlib::~nsGCCacheXlib(this = 0x4b4210), line 75 in "nsGCCache.cpp"
  [3] nsRenderingContextXlibContext::~nsRenderingContextXlibContext(0x4b4210,
0xff2bc7d4, 0x9, 0x8, 0x0, 0x0), at 0xfadf218c
  [4] DeleteRenderingContextXlibContext(aContext = 0x4b4210), line 102 in
"nsRenderingContextXlib.cpp"
  [5] nsDeviceContextXlib::~nsDeviceContextXlib(this = 0x77ed98), line 116 in
"nsDeviceContextXlib.cpp"
  [6] __SLIP.DELETER__C(0x77ed98, 0x1, 0xfdbe73cc, 0x7ff, 0x5f5f31, 0x5f5f31),
at 0xfadb76b0
  [7] DeviceContextImpl::Release(this = 0x77ed98), line 38 in
"nsDeviceContext.cpp"
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/widget/src/xlib/nsBaseWidget.o"
dbx: warning: see `help finding-files'
  [8] nsBaseWidget::OnDestroy(0x468770, 0xa000177, 0x3, 0xff3e4270, 0xff35ca24,
0xff3c5af0), at 0xfb552be0
  [9] nsWidget::OnDestroy(this = 0x468770), line 1044 in "nsWidget.cpp"
  [10] nsWidget::Destroy(this = 0x468770), line 379 in "nsWidget.cpp"
  [11] nsWidget::~nsWidget(this = 0x468770), line 163 in "nsWidget.cpp"
  [12] __SLIP.DELETER__D(0x468770, 0x1, 0xfb5875df, 0xff3e4270, 0xff35ca24,
0xff3c5af0), at 0xfb5460e8
  [13] nsBaseWidget::Release(0x468770, 0xfe361730, 0x1, 0xff3e4270, 0xfb50b18a,
0x86), at 0xfb550668
  [14] nsWidget::Release(this = 0x468770), line 699 in "nsWidget.cpp"
  [15] nsClipboard::~nsClipboard(this = 0x833dc0), line 94 in "nsClipboard.cpp"
  [16] __SLIP.DELETER__A(0x833dc0, 0x1, 0xfb583a74, 0x1, 0x0, 0x0), at
0xfb52d918
  [17] nsClipboard::Release(this = 0x833dc0), line 85 in "nsClipboard.cpp"
  [18] nsCOMPtr_base::assign_assuming_AddRef(this = 0x105e1c, newPtr = (nil)),
line 440 in "nsCOMPtr.h"
  [19] nsCOMPtr_base::assign_with_AddRef(this = 0x105e1c, rawPtr = (nil)), line
74 in "nsCOMPtr.cpp"
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/xpcom/build/nsComponentManager.o"
  [20] nsCOMPtr<nsISupports>::operator=(0x105e1c, 0x0, 0x3, 0xff3e4270,
0xff35ca24, 0xff3c5af0), at 0xfe1a2fd8
  [21] FreeServiceContractIDEntryEnumerate(0xcf70c, 0x11ea08, 0x152, 0x0,
0xfe02c83c, 0x37), at 0xfe1969bc
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/xpcom/build/pldhash.o"
  [22] PL_DHashTableEnumerate(0xcf70c, 0xfe196928, 0x0, 0xffbef190, 0x0, 0x0),
at 0xfe09307c
  [23] nsComponentManagerImpl::FreeServices(0xcf6c0, 0x0, 0xffbef18c, 0x0, 0x0,
0x0), at 0xfe196acc
  [24] NS_ShutdownXPCOM(servMgr = (nil)), line 724 in "nsXPComInit.cpp"
  [25] NS_ShutdownXPCOM(servMgr = (nil)), line 144 in "nsXPCOMGlue.cpp"
  [26] GRE_Shutdown(), line 255 in "nsXPCOMGlue.cpp"
  [27] main(argc = 1, argv = 0xffbef36c), line 1648 in "nsAppRunner.cpp"
-- snip --
(Assignee)

Comment 1

15 years ago
Further investigation shows a "nice" detail. Looking at the stacktrace when
nsGCCacheXlib is destroyed the first time...
-- snip --
nsPluginHostImpl::Observe "quit-application"
WARNING: requested removal of nonexistent window
, file
../../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp,
line 937
WEBSHELL- = 2
WEBSHELL- = 1
WEBSHELL- = 0
GC Cache:
        hits:  398  261   94   57   20    9    7    0    0    0    0    0   
0    0    1    1    2    9    1    2    0    0    1    0    1    1    0    3   
0    0    0    0
        hits: 868, misses: 121, hit percent: 87.765419%
nsGCCacheXlib::ReportStats at line 112 in file "nsGCCache.cpp"
  105                fprintf(stderr, "\n\thits: %d, misses: %d, hit percent:
%f%%\n", hits, GCCacheStats.misses, percent);
(dbx) where
current thread: t@1
=>[1] nsGCCacheXlib::ReportStats(this = 0x192a78), line 112 in "nsGCCache.cpp"
  [2] nsGCCacheXlib::~nsGCCacheXlib(this = 0x192a78), line 75 in "nsGCCache.cpp"
  [3] nsRenderingContextXlibContext::~nsRenderingContextXlibContext(0x192a78,
0xff2bc7b4, 0xff2b5eec, 0xff2b5eec, 0x941ee0, 0x11), at 0xfdd7218c
  [4] DeleteRenderingContextXlibContext(aContext = 0x192a78), line 102 in
"nsRenderingContextXlib.cpp"
  [5] nsDeviceContextXlib::~nsDeviceContextXlib(this = 0x64ab78), line 116 in
"nsDeviceContextXlib.cpp"
  [6] __SLIP.DELETER__C(0x64ab78, 0x1, 0xfdc673cc, 0x7, 0xfa91bf4a, 0x1d6), at
0xfdd376b0
  [7] DeviceContextImpl::Release(this = 0x64ab78), line 38 in
"nsDeviceContext.cpp"
  [8] nsCOMPtr_base::~nsCOMPtr_base(this = 0x852438), line 65 in "nsCOMPtr.cpp"
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/layout/build/nsPresContext.o"
dbx: warning: see `help finding-files'
  [9] nsCOMPtr<nsIDeviceContext>::~nsCOMPtr(0x852438, 0xfd157fb5, 0xfc168bb8,
0x852410, 0x0, 0x0), at 0xfc179f2c
  [10] nsPresContext::~nsPresContext(0x852410, 0x4, 0xff344570, 0xff140ae0, 0x0,
0xf7771), at 0xfc169d80
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/layout/build/nsGalleyContext.o"
  [11] GalleyContext::~GalleyContext(0x852410, 0x1, 0xfd256d56, 0xffbee894, 0x0,
0x0), at 0xfc15b7b4
  [12] __SLIP.DELETER__A(0x852410, 0x1, 0xfd158119, 0xff140ae0, 0x74cf08, 0x20),
at 0xfc15c4b8
  [13] nsPresContext::Release(0x852410, 0xffbee97c, 0xff35ca24, 0xffbee97c,
0x5fe378, 0x21), at 0xfc16aa98
  [14] nsCOMPtr_base::~nsCOMPtr_base(this = 0xfd3a316c), line 65 in
"nsCOMPtr.cpp"
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/layout/build/nsDOMEvent.o"
  [15] nsCOMPtr<nsIPresContext>::~nsCOMPtr(0xfd3a316c, 0xfd17184e, 0xff2b5eec,
0xff3e4270, 0xfda04483, 0x1), at 0xfc2934bc
  [16] nsDOMEvent::~nsDOMEvent(0xfd3a3144, 0x0, 0x0, 0x0, 0x0, 0x0), at
0xfc289cf0
  [17] __SLIP.DELETER__C(0xfd3a3144, 0x1, 0xfd1719be, 0x7, 0x0, 0x0), at
0xfc2930b8
  [18] nsDOMEvent::Release(0xfd3a3144, 0x3, 0x1, 0x1, 0x0, 0xf7771), at
0xfc28a020
dbx: internal warning: Typeid already exists with different
name:__1nKnsACString_ or symclass:struct, ignore current
stab:./components/libxpconnect.so:../../../../../../../../../home/mozilla/src/2003-03-11-08-trunk_cvs/mozilla/js/src/xpconnect/src/xpcjsruntime.cpp
stab #1555 __1nKnsACString_:U(0,516)
  [19] XPCJSRuntime::GCCallback(cx = 0x9987b8, status = JSGC_END), line 546 in
"xpcjsruntime.cpp"
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/dom/src/build/nsJSEnvironment.o"
  [20] DOMGCCallback(0x9987b8, 0x1, 0xffbeeeb8, 0x9987b8, 0xfffffff8, 0x95feef),
at 0xfa96394c
  [21] js_GC(cx = 0x9987b8, gcflags = 0), line 1404 in "jsgc.c"
  [22] js_ForceGC(cx = 0x9987b8, gcflags = 0), line 994 in "jsgc.c"
  [23] JS_GC(cx = 0x9987b8), line 1661 in "jsapi.c"
dbx: warning: can't find file
"/shared/bigtmp2/mozilla/2003-03-11-08-trunk_cvs/objdir_ws7_xlib/profile/build/nsProfile.o"
  [24] nsProfile::ShutDownCurrentProfile(0x16bf08, 0x1, 0xffbef260, 0x0, 0x0,
0x0), at 0xfb0960bc
  [25] DoOnShutdown(), line 775 in "nsAppRunner.cpp"
  [26] main(argc = 1, argv = 0xffbef36c), line 1644 in "nsAppRunner.cpp"
-- snip --

The device is being properly shut-down - but it looks a new nsDeviceContextXlib
instance is created (during shutdown) and then destroyed again... ewwww... ;-(
(Assignee)

Comment 2

15 years ago
Looks the following code in
http://lxr.mozilla.org/seamonkey/source/xpfe/bootstrap/nsAppRunner.cpp causes
the problem at shutdown:
-- snip --
779   // at this point, all that is on the clipboard is a proxy object, but that
object
780   // won't be valid once the app goes away. As a result, we need to force
the data
781   // out of that proxy and properly onto the clipboard. This can't be done
in the
782   // clipboard service's shutdown routine because it requires the parser/etc
which
783   // has already been shutdown by the time the clipboard is shut down.
784   {
785     // scoping this in a block to force release
786     nsCOMPtr<nsIClipboard>
clipService(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
787     if (NS_SUCCEEDED(rv))
788       clipService->ForceDataToClipboard(nsIClipboard::kGlobalClipboard);
789   }
-- snip --
This code triggers the creation of a new nsClipboard object which needs a new
nsDeviceContextXlib object, too... ;-/
(Assignee)

Comment 3

15 years ago
Created attachment 117238 [details] [diff] [review]
Possible solution - patch for 2003-03-11-08-trunk

The attached patch creates a (dummy) nsIDeviceContext in |nsAppShell| which
gets hold until the |nsAppShell| object gets destroyed

Advantages:
- This bug gets fixed :)
- We could use the return value of |mContext->Init(nsnull)| to check for
failure for setting-up the gfx fontmetrics system - a condition we do not catch
yet(=we crash in that case (GTK+/Qt/Xlib) - and catching the issue outside
nsAppShell is very very difficult).
- We _may_ we able to reuse the nsIDeviceContext elsewhere (needs some
investigation) in widget/
(Assignee)

Updated

15 years ago
Status: NEW → ASSIGNED
Summary: nsDeviceContextXlib destroyed twice → [Xlib] nsDeviceContextXlib destroyed twice
Target Milestone: --- → mozilla1.4alpha
(Assignee)

Comment 4

15 years ago
Created attachment 118365 [details] [diff] [review]
Patch for 2003-03-20-08-trunk
Attachment #117238 - Attachment is obsolete: true
(Assignee)

Comment 5

15 years ago
Comment on attachment 118365 [details] [diff] [review]
Patch for 2003-03-20-08-trunk

roc+moz:
Wanna take a look at the patch and check if it is...
a) correct
b) whether a port to widget/src/gtk&widget/src/gtk2 makes sense
..., please ?
Attachment #118365 - Flags: review?(roc+moz)
Comment on attachment 118365 [details] [diff] [review]
Patch for 2003-03-20-08-trunk

This seems good.
Attachment #118365 - Flags: superreview+
Attachment #118365 - Flags: review?(roc+moz)
Attachment #118365 - Flags: review+
(Assignee)

Comment 7

15 years ago
Robert O'Callahan wrote:
> (From update of attachment 118365 [details] [diff] [review])
> This seems good.

Thanks!

Should I port that to widget/src/gtk/ and widget/src/gtk2/, too ?
That would solve the issue that we can exit cleanly (instead of crashing) when
we fail to create the first device context (for example: missing fonts or wrong
font config) ?
Severity: normal → critical
Target Milestone: mozilla1.4alpha → mozilla1.4beta
sure.

Updated

11 years ago
Keywords: crash
Summary: [Xlib] nsDeviceContextXlib destroyed twice → [Xlib] nsDeviceContextXlib / nsGCCacheXlib destroyed twice
Whiteboard: needs port to gtk?

Comment 9

11 years ago
Gtk1/xlib widget code has been removed on trunk and the cause of the
crash (ForceDataToClipboard(), see comment 2) does not exist anymore.

-> WORKSFORME
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → WORKSFORME
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.