[comp.windows.x] Xaw bug that can cause Xsun to crash!

duanev@kauai.ACA.MCC.COM (Duane Voth) (05/12/89)

This Xaw bug has been causing the Xsun server on our systems to
belly up with an "Out of memory" error!  I suspect that "server
robustness" has been an issue here before so let me simply add
my vote to the "lets not AbortServer on Xmalloc errors".  Not at
all friendly.  Makes you want to go out and by an Amiga.  :)

                          X Window System Bug Report
                            xbugs@expo.lcs.mit.edu




VERSION:
    R3

CLIENT MACHINE and OPERATING SYSTEM:
    Sun 3/60 running SunOS 3.5, fixes 1-9

DISPLAY:
    Sun bw2

WINDOW MANAGER:
    awm

AREA:
    Xaw

SYNOPSIS:
    List.c and VPaned.c pass int instead of Dimension to XtMakeResizeRequest

DESCRIPTION:
    Sun cc (for 3.5 at least) makes Dimension (short int) 16 bits and ints
    32 bits.  Functions ChangeSize() in List.c and ChangeManaged() in VPaned.c
    call XtMakeResizeRequest() with width and height as ints where
    XtMakeResizeRequest() expects Dimensions.  XtMakeResizeRequest() gets
    trash for width and height and passes these all the way to the Server
    who may or may not crash depending on the phase of the moon.

REPEAT BY:
    XtCreateWidget a List widget with a null list and then XtListChange()
    the list with strings of real length.

SAMPLE FIX:

*** lib/Xaw/List.c      Thu May 11 20:23:50 1989
--- lib/Xaw/List.c.00   Thu May 11 20:22:01 1989
***************
*** 240,251 ****
  Widget w;
  int width, height;
  {
!     Dimension w_ret, h_ret;

      (void) Layout(w, FALSE, FALSE, &width, &height);

!     switch ( XtMakeResizeRequest(w, (Dimension)width, (Dimension)height,
!                                &w_ret, &h_ret) ) {
      case XtGeometryYes:
      case XtGeometryNo:
          break;
--- 240,250 ----
  Widget w;
  int width, height;
  {
!     int w_ret, h_ret;

      (void) Layout(w, FALSE, FALSE, &width, &height);

!     switch ( XtMakeResizeRequest(w, width, height, &w_ret, &h_ret) ) {
      case XtGeometryYes:
      case XtGeometryNo:
          break;
*** lib/Xaw/VPaned.c    Thu May 11 20:29:35 1989
--- lib/Xaw/VPaned.c.00 Thu May 11 20:27:02 1989
***************
*** 740,747 ****

     if (vpw->core.width == 0) {        /* can only happen before Realize */
         /* use width of widest child */
!        Dimension width = 0;
!        Dimension height = vpw->core.height;
         for (childP = children, i = 0; i < num_children; childP++, i++)
           if (XtIsManaged(*childP) && (*childP)->core.width > width)
               width = (*childP)->core.width;
--- 740,747 ----

     if (vpw->core.width == 0) {        /* can only happen before Realize */
         /* use width of widest child */
!        int width = 0;
!        int height = vpw->core.height;
         for (childP = children, i = 0; i < num_children; childP++, i++)
           if (XtIsManaged(*childP) && (*childP)->core.width > width)
               width = (*childP)->core.width;



(so does this help redeem my reputation a little?)