From xemacs-m  Thu Sep 25 02:30:10 1997
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id CAA15228
	for <xemacs-beta@xemacs.org>; Thu, 25 Sep 1997 02:30:09 -0500 (CDT)
Received: (from steve@localhost)
	by altair.xemacs.org (8.8.7/8.8.7) id AAA26972;
	Thu, 25 Sep 1997 00:36:16 -0700
Mail-Copies-To: never
To: xemacs-beta@xemacs.org
Subject: Re: 20.3-b19-23 dumps core on HP-UX 9.05
References: <of090wmc0e6.fsf@gamgee.ntc.nokia.com> <m2u3fal88k.fsf@altair.xemacs.org> <of067rqaqd7.fsf@gamgee.ntc.nokia.com>
X-Face: (:YAD@JS'&Kz'M}n7eX7gEvPR6U1mJ-kt;asEc2qAv;h{Yw7ckz<7+X_SYeTNAaPui:e~x$
 ,A=gkt*>UPL/}\a/#C~v2%ETiAY_sx;xve0yL??JWTtX_-NUzXyP38UdW#cmN1\4(X!c3m#%IbtB-3
 Z-!xpZi!`E.s{(;aP=b11"!3wQu]1j@^V|;n=B|{l<bZV1.AI`zWV%kPCnUhcgEe\(}/_kNd6,*3ZJ
 Q3o<YQ3^u;7jS=:p0--u3msQO
X-Attribution: sb
From: SL Baur <steve@xemacs.org>
In-Reply-To: Pekka Marjola's message of "25 Sep 1997 08:56:20 +0300"
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
Date: 25 Sep 1997 00:36:15 -0700
Message-ID: <m2n2l13kwg.fsf@altair.xemacs.org>
Lines: 606
X-Mailer: Quassia Gnus v0.10/XEmacs 20.3(beta24) - "Ljubljana"

Pekka Marjola <pema@iki.fi> writes:

>>>>>> "sb" == SL Baur <steve@xemacs.org> writes:

sb> Hmmm, there were some minor cosmetic changes made to glyphs-x.c for
sb> beta19, but they shouldn't cause a core dump.  What happens if you
sb> build glyphs-x.o without optimization?

> No change. (Everything else still compiled using -O2.)

O.K.  If at first you don't succeed ...	

Try applying the attached patch and see if that helps (it reverts this 
file to what it was in 18).

Index: src/glyphs-x.c
===================================================================
RCS file: /usr/local/xemacs/xemacs-20.0/src/glyphs-x.c,v
retrieving revision 1.17
retrieving revision 1.16
diff -u -r1.17 -r1.16
--- glyphs-x.c	1997/09/03 03:39:38	1.17
+++ glyphs-x.c	1997/08/17 03:24:56	1.16
@@ -29,7 +29,7 @@
    subwindow support added by Chuck Thompson
    additional XPM support added by Chuck Thompson
    initial X-Face support added by Stig
-   rewritten/restructured by Ben Wing for 19.12/19.13
+   rewritten/restructured by Ben Wing for 19.12/19.13 
    GIF/JPEG support added by Ben Wing for 19.14
    PNG support added by Bill Perry for 19.14
    Improved GIF/JPEG support added by Bill Perry for 19.14
@@ -58,13 +58,7 @@
 #include "sysfile.h"
 
 #ifdef HAVE_PNG
-#ifdef __cplusplus
-extern "C" {
-#endif
 #include <png.h>
-#ifdef __cplusplus
-}
-#endif
 #else
 #include <setjmp.h>
 #endif
@@ -255,7 +249,7 @@
 x_initialize_pixmap_image_instance (struct Lisp_Image_Instance *ii,
 				    enum image_instance_type type)
 {
-  ii->data = xnew_and_zero (struct x_image_instance_data);
+  ii->data = malloc_type_and_zero (struct x_image_instance_data);
   IMAGE_INSTANCE_TYPE (ii) = type;
   IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
   IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
@@ -376,7 +370,7 @@
   Lisp_Object data;
 
   assert (VECTORP (instantiator));
-
+  
   data = find_keyword_in_vector (instantiator, data_keyword);
   file = find_keyword_in_vector (instantiator, file_keyword);
 
@@ -401,7 +395,7 @@
   Lisp_Object file = Qnil;
   struct gcpro gcpro1, gcpro2;
   Lisp_Object alist = Qnil;
-
+  
   GCPRO2 (file, alist);
 
   /* Now, convert any file data into inline data.  At the end of this,
@@ -445,7 +439,7 @@
   Extbyte *bytes;
   Extcount len;
   FILE *stream;
-
+  
   /* #### This is a definite problem under Mule due to the amount of
      stack data it might allocate.  Need to be able to convert and
      write out to a file. */
@@ -522,7 +516,7 @@
       xfg->pixel = 0;
       xfg->red = xfg->green = xfg->blue = 0;
     }
-
+  
   if (!NILP (*background) && !COLOR_INSTANCEP (*background))
     *background =
       Fmake_color_instance (*background, device,
@@ -604,7 +598,7 @@
   if (!(dest_mask & IMAGE_COLOR_PIXMAP_MASK))
     incompatible_image_types (instantiator, dest_mask,
 			      IMAGE_COLOR_PIXMAP_MASK);
-
+  
   pixmap = XCreatePixmap (dpy, d, ximage->width,
 			  ximage->height, ximage->depth);
   if (!pixmap)
@@ -616,17 +610,17 @@
       XFreePixmap (dpy, pixmap);
       signal_simple_error ("Unable to create GC", instantiator);
     }
-
+  
   XPutImage (dpy, pixmap, gc, ximage, 0, 0, 0, 0,
 	     ximage->width, ximage->height);
-
+  
   XFreeGC (dpy, gc);
 
   x_initialize_pixmap_image_instance (ii, IMAGE_COLOR_PIXMAP);
 
   IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
     find_keyword_in_vector (instantiator, Q_file);
-
+  
   IMAGE_INSTANCE_X_PIXMAP (ii) = pixmap;
   IMAGE_INSTANCE_X_MASK (ii) = 0;
   IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = ximage->width;
@@ -694,7 +688,7 @@
       return Qt.
    -- maybe return an error, or return Qnil.
  */
-
+   
 
 static Lisp_Object
 bitmap_to_lisp_data (Lisp_Object name, int *xhot, int *yhot,
@@ -793,7 +787,7 @@
   Lisp_Object file = Qnil, mask_file = Qnil;
   struct gcpro gcpro1, gcpro2, gcpro3;
   Lisp_Object alist = Qnil;
-
+  
   GCPRO3 (file, mask_file, alist);
 
   /* Now, convert any file data into inline data for both the regular
@@ -1066,14 +1060,8 @@
  *                             JPEG                                   *
  **********************************************************************/
 
-#ifdef __cplusplus
-extern "C" {
-#endif
 #include <jpeglib.h>
 #include <jerror.h>
-#ifdef __cplusplus
-}
-#endif
 
 /* The in-core jpeg code doesn't work, so I'm avoiding it for now.  -sb  */
 /* Late-breaking update, we're going to give it a try, I think it's */
@@ -1249,7 +1237,7 @@
 jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len)
 {
   struct jpeg_source_mgr *src = NULL;
-
+  
   if (cinfo->src == NULL) {	/* first time for this JPEG object? */
     cinfo->src = (struct jpeg_source_mgr *)
       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
@@ -1344,7 +1332,7 @@
 			 list1 (build_string (unwind.tempfile)));
   }
 #endif
-
+  
   /* Step 1: allocate and initialize JPEG decompression object */
 
   /* We set up the normal JPEG error routines, then override error_exit. */
@@ -1361,11 +1349,11 @@
       {
 	Lisp_Object errstring;
 	char buffer[JMSG_LENGTH_MAX];
-
+	
 	/* Create the message */
 	(*cinfo.err->format_message) ((j_common_ptr) &cinfo, buffer);
 	errstring = build_string (buffer);
-
+	
 	signal_simple_error_2 ("JPEG decoding error",
 			       errstring, instantiator);
       }
@@ -1384,7 +1372,7 @@
     Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
     Extbyte *bytes;
     Extcount len;
-
+  
     /* #### This is a definite problem under Mule due to the amount of
        stack data it might allocate.  Need to be able to convert and
        write out to a file. */
@@ -1443,7 +1431,7 @@
 
     /* Just in case the image contains out-of-range pixels, we go
        ahead and allocate space for all of them. */
-    unwind.pixels = xnew_array (unsigned long, 256);
+    unwind.pixels = (unsigned long *) xmalloc (256 * sizeof (unsigned long));
     unwind.npixels = cinfo.actual_number_of_colors;
 
     for (i = 0; i < 256; i++)
@@ -1478,14 +1466,17 @@
     int width = cinfo.output_width;
     int depth;
     int bitmap_pad;
-
+    
     depth = DefaultDepthOfScreen (scr);
-
+    
     /* first get bitmap_pad (from XPM) */
-    bitmap_pad = ((depth > 16) ? 32 :
-		  (depth >  8) ? 16 :
-		  8);
-
+    if (depth > 16)
+      bitmap_pad = 32;
+    else if (depth > 8)
+      bitmap_pad = 16;
+    else
+      bitmap_pad = 8;
+    
     unwind.ximage = XCreateImage (dpy, DefaultVisualOfScreen (scr),
 				  depth, ZPixmap, 0, 0, width, height,
 				  bitmap_pad, 0);
@@ -1508,7 +1499,7 @@
      * output image dimensions available, as well as the output colormap
      * if we asked for color quantization.
      * In this example, we need to make an output work buffer of the right size.
-     */
+     */ 
     /* JSAMPLEs per row in output buffer.
        Since we asked for quantized output, cinfo.output_components
        will always be 1. */
@@ -1517,7 +1508,7 @@
        with image */
     row_buffer = ((*cinfo.mem->alloc_sarray)
 		  ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1));
-
+    
     /* Here we use the library's state variable cinfo.output_scanline as the
      * loop counter, so that we don't have to keep track ourselves.
      */
@@ -1671,7 +1662,7 @@
   GifPixelType *ScreenBuffer =
     (GifPixelType *) xmalloc (GifFile->SHeight * GifFile->SWidth *
 			      sizeof (GifPixelType));
-  GifFile->SavedImages = xnew (SavedImage);
+  GifFile->SavedImages = (SavedImage *) xmalloc (sizeof(SavedImage));
 
   for (i = 0; i < GifFile->SHeight * GifFile->SWidth; i++)
     ScreenBuffer[i] = GifFile->SBackGroundColor;
@@ -1699,7 +1690,7 @@
 
 	  sp->RasterBits = (GifPixelType*) xmalloc(Width * Height *
 						   sizeof (GifPixelType));
-
+	  
 	  if (GifFile->Image.Interlace)
 	    {
 	      /* Need to perform 4 passes on the images: */
@@ -1809,7 +1800,7 @@
     if (our_own_dgif_slurp_from_gif2x11_c(unwind.giffile) != GIF_OK)
 #else
     /* DGifSlurp() doesn't handle interlaced files. */
-    /* Actually, it does, sort of.  It just sets the Interlace flag
+    /* Actually, it does, sort of.  It just sets the Interlace flag 
        and stores RasterBits in interlaced order.  We handle that below. */
     if (DGifSlurp (unwind.giffile) != GIF_OK)
 #endif
@@ -1822,7 +1813,7 @@
     ColorMapObject *cmap = unwind.giffile->SColorMap;
     /* Just in case the image contains out-of-range pixels, we go
        ahead and allocate space for all of them. */
-    unwind.pixels = xnew_array (unsigned long, 256);
+    unwind.pixels = (unsigned long *) xmalloc (256 * sizeof (unsigned long));
     unwind.npixels = cmap->ColorCount;
 
     for (i = 0; i < 256; i++)
@@ -1855,14 +1846,17 @@
     static int InterlacedOffset[] = { 0, 4, 2, 1 };
     static int InterlacedJumps[] = { 8, 8, 4, 2 };
 
-
+    
     depth = DefaultDepthOfScreen (scr);
-
+    
     /* first get bitmap_pad (from XPM) */
-    bitmap_pad = ((depth > 16) ? 32 :
-		  (depth >  8) ? 16 :
-		  8);
-
+    if (depth > 16)
+      bitmap_pad = 32;
+    else if (depth > 8)
+      bitmap_pad = 16;
+    else
+      bitmap_pad = 8;
+    
     unwind.ximage = XCreateImage (dpy, DefaultVisualOfScreen (scr),
 				  depth, ZPixmap, 0, 0, width, height,
 				  bitmap_pad, 0);
@@ -1883,8 +1877,8 @@
        to be a bottleneck here, maybe we should just copy the
        optimization routines from XPM (they're in turn mostly
        copied from the Xlib source code). */
-
-    /* Note: We just use the first image in the file and ignore the rest.
+    
+    /* Note: We just use the first image in the file and ignore the rest. 
              We check here that that image covers the full "screen" size.
 	     I don't know whether that's always the case.
              -dkindred@cs.cmu.edu  */
@@ -2059,8 +2053,8 @@
   dpy = DEVICE_X_DISPLAY (XDEVICE (device));
   scr = DefaultScreenOfDisplay (dpy);
 
-  png_ptr  = xnew (png_struct);
-  info_ptr = xnew (png_info);
+  png_ptr = (png_struct *) xmalloc (sizeof (png_struct));
+  info_ptr = (png_info *) xmalloc (sizeof (png_info));
 
   memset (&unwind, 0, sizeof (unwind));
   unwind.png_ptr = png_ptr;
@@ -2117,9 +2111,9 @@
     Extbyte *bytes;
     Extcount len;
     struct png_memory_storage tbr; /* Data to be read */
-
+    
     assert (!NILP (data));
-
+    
     /* #### This is a definite problem under Mule due to the amount of
        stack data it might allocate.  Need to be able to convert and
        write out to a file. */
@@ -2155,9 +2149,9 @@
     png_color static_color_cube[216];
 
     /* Wow, allocate all the memory.  Truly, exciting. */
-    unwind.pixels = xnew_array (unsigned long, 256);
-    png_pixels    = xnew_array (png_byte, linesize * height);
-    row_pointers  = xnew_array (png_byte *, height);
+    unwind.pixels = (unsigned long *) xmalloc (256 * sizeof (unsigned long));
+    png_pixels = (png_byte *) xmalloc (linesize * height * sizeof (png_byte*));
+    row_pointers = (png_byte **) xmalloc (height * sizeof (png_byte *));
 
     for (y = 0; y < 256; y++)
       unwind.pixels[y] = 0;
@@ -2201,7 +2195,7 @@
 			    info_ptr->num_palette, info_ptr->hist, 1);
 	  }
       }
-
+    
     png_read_image (png_ptr, row_pointers);
     png_read_end (png_ptr, info_ptr);
 
@@ -2260,14 +2254,17 @@
 #endif
 
     /* Now create the image */
-
+    
     depth = DefaultDepthOfScreen (scr);
-
+    
     /* first get bitmap_pad (from XPM) */
-    bitmap_pad = ((depth > 16) ? 32 :
-		  (depth >  8) ? 16 :
-		  8);
-
+    if (depth > 16)
+      bitmap_pad = 32;
+    else if (depth > 8)
+      bitmap_pad = 16;
+    else
+      bitmap_pad = 8;
+    
     unwind.ximage = XCreateImage (dpy, DefaultVisualOfScreen (scr),
 				  depth, ZPixmap, 0, 0, width, height,
 				  bitmap_pad, 0);
@@ -2287,7 +2284,7 @@
 	  XPutPixel (unwind.ximage, j, i,
 		     unwind.pixels[png_pixels[i * width + j]]);
     }
-
+    
     xfree (row_pointers);
     xfree (png_pixels);
   }
@@ -2349,7 +2346,7 @@
 check_valid_xpm_color_symbols (Lisp_Object data)
 {
   Lisp_Object rest;
-
+  
   for (rest = data; !NILP (rest); rest = XCDR (rest))
     {
       if (!CONSP (rest) ||
@@ -2488,7 +2485,7 @@
   Lisp_Object color_symbols;
   struct gcpro gcpro1, gcpro2;
   Lisp_Object alist = Qnil;
-
+  
   GCPRO2 (file, alist);
 
   /* Now, convert any file data into inline data.  At the end of this,
@@ -2606,7 +2603,7 @@
 
   if (i == 0) return 0;
 
-  symbols = xnew_array (XpmColorSymbol, i);
+  symbols = (XpmColorSymbol *) xmalloc (i * sizeof (XpmColorSymbol));
   xpmattrs->valuemask |= XpmColorSymbols;
   xpmattrs->colorsymbols = symbols;
   xpmattrs->numsymbols = i;
@@ -2704,7 +2701,7 @@
       xpmattrs.closeness = 65535;
       xpmattrs.valuemask |= XpmCloseness;
     }
-
+  
   color_symbols = extract_xpm_color_names (&xpmattrs, device, domain,
 					   color_symbol_alist);
 
@@ -2774,15 +2771,15 @@
 
   {
     int npixels = xpmattrs.npixels;
-    Pixel *pixels;
+    Pixel *pixels = 0;
 
     if (npixels != 0)
       {
-	pixels = xnew_array (Pixel, npixels);
+	pixels = xmalloc (npixels * sizeof (Pixel));
 	memcpy (pixels, xpmattrs.pixels, npixels * sizeof (Pixel));
       }
     else
-      pixels = NULL;
+      pixels = 0;
 
     IMAGE_INSTANCE_X_PIXMAP (ii) = pixmap;
     IMAGE_INSTANCE_X_MASK (ii) = mask;
@@ -2852,7 +2849,7 @@
 	       and which is background, or rather, it's implicit: in
 	       an XBM file, a 1 bit is foreground, and a 0 bit is
 	       background.
-
+	 
 	       XCreatePixmapCursor() assumes this property of the
 	       pixmap it is called with as well; the `foreground'
 	       color argument is used for the 1 bits.
@@ -2864,25 +2861,25 @@
 	       background.  We do it by comparing RGB and assuming
 	       that the darker color is the foreground.  This works
 	       with the result of xbmtopbm|ppmtoxpm, at least.
-
+	 
 	       It might be nice if there was some way to tag the
 	       colors in the XPM file with whether they are the
 	       foreground - perhaps with logical color names somehow?
-
+	 
 	       Once we have decided which color is the foreground, we
 	       need to ensure that that color corresponds to a `1' bit
 	       in the Pixmap.  The XPM library wrote into the (1-bit)
 	       pixmap with XPutPixel, which will ignore all but the
 	       least significant bit.
-
+	 
 	       This means that a 1 bit in the image corresponds to
 	       `fg' only if `fg.pixel' is odd.
-
+	 
 	       (This also means that the image will be all the same
 	       color if both `fg' and `bg' are odd or even, but we can
 	       safely assume that that won't happen if the XPM file is
 	       sensible I think.)
-
+	 
 	       The desired result is that the image use `1' to
 	       represent the foreground color, and `0' to represent
 	       the background color.  So, we may need to invert the
@@ -2927,7 +2924,7 @@
 		  bg = swap;
 		}
 	    }
-
+      
 	    /* If the fg pixel corresponds to a `0' in the bitmap, invert it.
 	       (This occurs (only?) on servers with Black=0, White=1.)
 	       */
@@ -2961,7 +2958,7 @@
     default:
       abort ();
     }
-
+  
   xpm_free (&xpmattrs);	/* after we've read pixels and hotspot */
 }
 
@@ -2987,7 +2984,7 @@
   Lisp_Object file = Qnil, mask_file = Qnil;
   struct gcpro gcpro1, gcpro2, gcpro3;
   Lisp_Object alist = Qnil;
-
+  
   GCPRO3 (file, mask_file, alist);
 
   /* Now, convert any file data into inline data for both the regular
@@ -3046,13 +3043,7 @@
 /* We have to define SYSV32 so that compface.h includes string.h
    instead of strings.h. */
 #define SYSV32
-#ifdef __cplusplus
-extern "C" {
-#endif
 #include <compface.h>
-#ifdef __cplusplus
-}
-#endif
 /* JMP_BUF cannot be used here because if it doesn't get defined
    to jmp_buf we end up with a conflicting type error with the
    definition in compface.h */
@@ -3160,7 +3151,7 @@
 	 if the given file is not a valid XPM file.  Instead, they
 	 just seg fault.  It is definitely caused by passing a
 	 bitmap.  To try and avoid this we check for bitmaps first.  */
-
+      
       data = bitmap_to_lisp_data (filename, &xhot, &yhot, 1);
 
       if (!EQ (data, Qt))
@@ -3550,7 +3541,7 @@
   /* This is stolen from frame.c.  Subwindows are strange in that they
      are specific to a particular frame so we want to print in their
      description what that frame is. */
-
+  
   write_c_string (" on #<", printcharfun);
   if (!FRAME_LIVE_P (frm))
     write_c_string ("dead", printcharfun);
@@ -3650,8 +3641,8 @@
     }
 
   {
-    struct Lisp_Subwindow *sw =
-      alloc_lcrecord_type (struct Lisp_Subwindow, lrecord_subwindow);
+    struct Lisp_Subwindow *sw = alloc_lcrecord (sizeof (struct Lisp_Subwindow),
+						lrecord_subwindow);
     Lisp_Object val;
     sw->frame = frame;
     sw->xscreen = xs;
@@ -3907,7 +3898,7 @@
   IIFORMAT_VALID_KEYWORD (png, Q_data, check_valid_string);
   IIFORMAT_VALID_KEYWORD (png, Q_file, check_valid_string);
 #endif
-
+  
 #ifdef HAVE_TIFF
   INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (tiff, "tiff");
 
@@ -3947,7 +3938,7 @@
   IIFORMAT_VALID_KEYWORD (xface, Q_hotspot_y, check_valid_int);
   IIFORMAT_VALID_KEYWORD (xface, Q_foreground, check_valid_string);
   IIFORMAT_VALID_KEYWORD (xface, Q_background, check_valid_string);
-#endif
+#endif 
 
   INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (autodetect,
 					"autodetect");
@@ -3974,7 +3965,7 @@
 #ifdef HAVE_PNG
   Fprovide (Qpng);
 #endif
-
+  
 #ifdef HAVE_TIFF
   Fprovide (Qtiff);
 #endif
@@ -3994,15 +3985,15 @@
 \"foreground\" and \"background\" to be the colors of the `default' face.
 */ );
   Vxpm_color_symbols = Qnil; /* initialized in x-faces.el */
-#endif
+#endif 
 
 #ifdef HAVE_XFACE
   Fprovide (Qxface);
-#endif
+#endif 
 
   DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path /*
 A list of the directories in which X bitmap files may be found.
-If nil, this is initialized from the "*bitmapFilePath" resource.
+If nil, this is initialized from the \"*bitmapFilePath\" resource.
 This is used by the `make-image-instance' function (however, note that if
 the environment variable XBMLANGPATH is set, it is consulted first).
 */ );

