Last Comment Bug 57725 - Webclient (PR3) core dumps when trying to Navigate links on Solaris
: Webclient (PR3) core dumps when trying to Navigate links on Solaris
Product: Core Graveyard
Classification: Graveyard
Component: Java APIs to WebShell (show other bugs)
: Trunk
: Sun Solaris
: P3 critical (vote)
: ---
Assigned To: Ashu Kulkarni
: geetha.vaidyanaathan
Depends on:
Blocks: 49126 52883
  Show dependency treegraph
Reported: 2000-10-23 14:42 PDT by Ashu Kulkarni
Modified: 2012-04-09 22:27 PDT (History)
3 users (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---

cvs diff -u of MotifBrowserControlCanvas.cpp and NativeEventThread.cpp (2.70 KB, patch)
2000-11-01 17:16 PST, Ashu Kulkarni
no flags Details | Diff | Splinter Review
tar of modified files. untar in java/webclient (30.00 KB, application/octet-stream)
2000-11-01 17:36 PST, Ashu Kulkarni
no flags Details

Description Ashu Kulkarni 2000-10-23 14:42:53 PDT
When Webclient is run on Solaris and one tries to navigate links, Mozilla
seg-faults in nsWindow.cpp due to null-ptr dereference.

This is because in Webclient, the top level Window wrapping the WebBrowser
object is not a gtk window, but rather, a motif window (Java native peer). In
mozilla/widget/src/gtk/nsWindow.cpp::SetFocus, when the code tries to get a
nsWindow from the GtkWidget, a null is returned. When this is dereferenced,
without checking whether nsWindow is null, a seg fault occurs.

The fix for this, is to check if the nsWindow returned by the
gtk_object_get_data(GTK_OBJECT(top_mozarea), "nsWindow");
call is null.

The cvs diff -u for the fix is as follows -

Index: nsWindow.cpp
RCS file: /cvsroot/mozilla/widget/src/gtk/nsWindow.cpp,v
retrieving revision 1.305
diff -u -r1.305 nsWindow.cpp
--- nsWindow.cpp        2000/09/22 06:48:56     1.305
+++ nsWindow.cpp        2000/10/23 16:30:46
@@ -1085,15 +1085,17 @@
     if (!GTK_WIDGET_HAS_FOCUS(top_mozarea))
       nsWindow *mozAreaWindow = (nsWindow
*)gtk_object_get_data(GTK_OBJECT(top_mozarea), "nsWindow");
-      mozAreaWindow->mBlockMozAreaFocusIn = PR_TRUE;
+      if (mozAreaWindow) {
+        mozAreaWindow->mBlockMozAreaFocusIn = PR_TRUE;
-      printf("mozarea grabbing focus!\n");
+        printf("mozarea grabbing focus!\n");
-      gtk_widget_grab_focus(top_mozarea);
-      // this will show the window if it's minimized and bring it to
-      // the front of the stacking order.
-      GetAttention();
-      mozAreaWindow->mBlockMozAreaFocusIn = PR_FALSE;
+        gtk_widget_grab_focus(top_mozarea);
+        // this will show the window if it's minimized and bring it to
+        // the front of the stacking order.
+        GetAttention();
+        mozAreaWindow->mBlockMozAreaFocusIn = PR_FALSE;
+      }

Since in the normal browser operation, the GtkWidget is an actual gtk window,
the call to gtk_object_get_data never returns a null. 

This fix is required to get Webclient working with Mozilla PR3 codebase.

Comment 1 Ashu Kulkarni 2000-10-23 14:43:45 PDT
I filed, I accept.

Comment 2 edburns 2000-10-24 14:40:13 PDT
Looks good to me r=edburns.  Let's get r=blizzard and sr= someone and get this
into the trunk.
Comment 3 Christopher Blizzard (:blizzard) 2000-10-25 08:46:18 PDT
Are you guys creating the mozarea object and passing it in as the parent as part
of the Create() call?  I do something similar in the embedding widget and I
never get crashes where you do.
Comment 4 Ashu Kulkarni 2000-10-25 09:59:22 PDT

We are creating the MozArea and passing it to the Create call just as you are in
yout gtkembed example. Check out
in lxr.

The reason our MozArea is diff from yours is that our top level window is a
native motif window (what Java uses as its native peers) while yours is a gtk

Comment 5 Christopher Blizzard (:blizzard) 2000-10-25 10:24:09 PDT
Acutally, in the gtk embedding example I pass in a standard GtkContainer, not a
mozarea as the parent of the top mozilla window.  The mozarea object is created
and managed by mozilla.  Have a look at:

To be honest, I'm not sure what the effect of having a mozarea object that's not
managed by mozilla will be.  I would expect other bugs to crop up.  Would you be
willing to pass in a GtkContainer instead of creating the mozarea yourself?
Comment 6 Ashu Kulkarni 2000-10-25 11:32:59 PDT
Take a look at
to see how I create the GtkWidget and mozArea. What is returned in this function
is passed to the BaseWindow->Create call in

I tried passing the top level GtkContainer, but nothing was being displayed, not
even the Java Window.

Only if I create the MozArea myself and pass it in like I do here, does the
embedded Browser come up.
Comment 7 timeless 2000-10-30 18:31:57 PST
Blizzard: please read and comment.
Comment 8 Christopher Blizzard (:blizzard) 2000-10-31 08:23:08 PST
You really want to create something like a GtkBin class and pass that into the
CreateNative() call.  If you look at the CreateNative() all in nsWindow.cpp

you can see that it looks to see if the parent is a GtkContainerClass or child
thereof.  If it is, then it will create the mozArea which is really what you
want.  Just make sure that the widget that you pass in is realized first.
Comment 9 Ashu Kulkarni 2000-10-31 10:03:14 PST
I create a mozArea, and pass it's SuperWin to the Create call. In
nsWindow::CreateNative, it checks to see if the widget is a SuperWin and handles
it correctly.

Look at

From looking at nsWindow.cpp, this seems to be a valid approach. If I just
create a GtkContainer and pass it to the Create call, nothing gets drawn and it
does not complain about the widget not being realised first (I suppose Gtk would
complain if the Widget hadn't been realised).
Comment 10 Christopher Blizzard (:blizzard) 2000-10-31 10:30:02 PST
The code supports that because that's how the native child windows are created.
 However, the code doesn't deal with the case where the mozarea widget that is
passed was not created by the mozilla code itself, like you are doing.

Are you passing in a GtkContainer or a GtkBin?  The GtkContainer is a base class
that doesn't have a lot of functionality on its own.  The GtkBin class is a
container that holds exactly one child which is what you want.
Comment 11 Ashu Kulkarni 2000-11-01 17:16:05 PST
Created attachment 18511 [details] [diff] [review]
cvs diff -u of MotifBrowserControlCanvas.cpp and NativeEventThread.cpp
Comment 12 Ashu Kulkarni 2000-11-01 17:18:23 PST
Creating a GtkBin object and passing it to BaseWindow->Init fixed the problem.
The patch for Webclient is attached. With this fix no changes are needed in the
mozilla code.

thanks for your help in this Chris!

Comment 13 Ashu Kulkarni 2000-11-01 17:24:06 PST

Pls verify fix so I can close this Bug.

Comment 14 Ashu Kulkarni 2000-11-01 17:36:53 PST
Created attachment 18514 [details]
tar of modified files. untar in java/webclient
Comment 15 Ashu Kulkarni 2000-11-01 17:43:07 PST
Patch modifies

Comment 16 edburns 2000-11-01 18:31:08 PST
The fix is not checked in, correct?
Comment 17 Ashu Kulkarni 2000-11-02 09:15:26 PST
it's not checked in. I'm waiting for r=a=edburns

Comment 18 edburns 2000-11-02 10:25:43 PST
This looks good.  r=a=edburns.  Just remove the printfs.
Comment 19 Ashu Kulkarni 2000-11-06 10:07:28 PST
Fix checked in. Closing this Bug.
Comment 20 Alexei V. Mokeev 2001-09-24 06:46:05 PDT
Work now. Mark VERIFIED

Note You need to log in before you can comment on or make changes to this bug.