viewer crash at exit gBrowsers == NULL

RESOLVED FIXED

Status

RESOLVED FIXED
18 years ago
10 years ago

People

(Reporter: bernd_mozilla, Assigned: attinasi)

Tracking

Trunk
x86
Other

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

18 years ago
steps:
start viewer.exe
exit via menu
crash

solution (quick hack)

Index: nsBrowserWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp,v
retrieving revision 3.350
diff -r3.350 nsBrowserWindow.cpp
583a584,585
>     if(!gBrowsers)
>       return;

It does  not look nice but it fixes the annoying crash

Win98 CVS 2001-02-25
(Reporter)

Comment 1

18 years ago
this bug was introduced by dbaron with his fix for bug 70004. The problem is
that bw->destroy calls RemoveBrowser 
an there 
if (!gBrowsers->Count()) {
    delete gBrowsers;
    gBrowsers = nsnull;
If gBrowser->Count is 1 then we will first remove an element, then we will
recognize in RemoveBroser that we dont have any more elements and destroy
gBrowsers, but we query query gBrowsers->Count and it crashes.
Adding David to CC.

With the proposed patch one could also remove the follwong lines from
CloseAllWindows.
 
  delete gBrowsers;
  gBrowsers = nsnull;

patch follows
 
(Reporter)

Comment 2

18 years ago
Created attachment 26193 [details] [diff] [review]
patch 2nd
Maybe it would be better to just change the condition of the while loop to
|while (gBrowsers && gBrowsers->Count())|, and remove the null check from the
beginning?
Proposed patch:

Index: nsBrowserWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp,v
retrieving revision 3.350
diff -u -d -r3.350 nsBrowserWindow.cpp
--- nsBrowserWindow.cpp	2001/02/24 17:15:50	3.350
+++ nsBrowserWindow.cpp	2001/02/27 03:30:55
@@ -574,16 +574,16 @@
 void
 nsBrowserWindow::CloseAllWindows()
 {
-  if (!gBrowsers)
-    return;
-  while (0 != gBrowsers->Count()) {
+  while (gBrowsers && gBrowsers->Count()) {
     nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers->ElementAt(0);
     NS_ADDREF(bw);
     bw->Destroy();
     NS_RELEASE(bw);
   }
-  delete gBrowsers;
-  gBrowsers = nsnull;
+  if (gBrowsers) {
+    delete gBrowsers;
+    gBrowsers = nsnull;
+  }
 }
 
 static nsEventStatus PR_CALLBACK
Patch looks fine to me, r=jst
OK, I checked in my version of the patch at 2001-02-26 19:26 PST.  Thanks, Bernd,
for reporting this and figuring out the problem.
Status: NEW → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.