Subject: Purify test results

From: Dan Espen <[email-masked]>
Date: Sun, 13 May 2001 15:58:18 -0400

This is the  latest CVS.  The  test  didn't get  very far.  I  haven't
looked at either problem yet.

Cannot parse color "On purpose"
UMR: Uninitialized memory read:
  * This is occurring while in:
	_XcmsLookupColorName [cmsColNm.c]
	_XcmsResolveColorString [cmsColNm.c]
	XParseColor    [ParseCol.c]
	GetSimpleColor [Picture.c:556]
	GetColor       [Picture.c:630]
	CMD_DefaultColors [builtins.c:1220]
	execute_function [functions.c:1091]
	old_execute_function [functions.c:1160]
	execute_complex_function [functions.c:1654]
	execute_function [functions.c:1108]
	old_execute_function [functions.c:1160]
	execute_complex_function [functions.c:1654]
	execute_function [functions.c:1108]
	do_menu        [menus.c:832]
	menu_func      [menus.c:5509]
	CMD_Menu       [menus.c:5525]
	execute_function [functions.c:1091]
	old_execute_function [functions.c:1160]
	HandleButtonPress [events.c:1644]
	DispatchEvent  [events.c:2764]
  * Reading 1 byte from 0xffbec5dd on the stack.
  * Address 0xffbec5dd is       35 bytes below frame pointer in function _XcmsLookupColorName.

...

### Sun May 13 15:42:09 EDT 2001: Test Resize ###
COR: Fatal core dump:
  * This is occurring while in:
	.div           [rtlib.o]
	DrawButton     [borders.c:421]
	RedrawTitle    [borders.c:1279]
	draw_clipped_decorations [borders.c:1648]
	DrawDecorations [borders.c:1672]
	CMD_Resize     [move_resize.c:1928]
	execute_function [functions.c:1091]
	old_execute_function [functions.c:1160]
	CMD_Next       [conditional.c:455]
	execute_function [functions.c:1091]
	old_execute_function [functions.c:1160]
	execute_complex_function [functions.c:1654]
	execute_function [functions.c:1108]
	old_execute_function [functions.c:1160]
	execute_complex_function [functions.c:1654]
	execute_function [functions.c:1108]
	do_menu        [menus.c:832]
	menu_func      [menus.c:5509]
	CMD_Menu       [menus.c:5525]
	execute_function [functions.c:1091]
  * Received signal 8 (SIGFPE - Arithmetic Exception)
  * Signal mask: (SIGFPE) 
  * Pending signals: 

-- 
Dan Espen
444 Hoes Lane  Room RRC 1C-214             E-mail: [email-masked]
Piscataway, NJ 08854                       Phone: (732) 699-5570
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Sun, 13 May 2001 19:16:58 -0400

> 	GetSimpleColor [Picture.c:556]

I don't see anything wrong here, I suspect something in the Solaris
X library.

> 	DrawButton     [borders.c:421]

Both Purify and gcc seem to be confused about where the real problem
is.  "where" gave me one thing, and "list" gave me another.

The problem is in this code in Graphics.c:

    case S_GRADIENT:
      {
        register int w = t_width - 1;
        register int h = t_height - 1;
	register int t_scale = w * h;
	register int myncolors = ncolors * 2;
        for (i = 0; i <= w; i++) {
          register int pi = min(i, w - i) * h;
          for (j = 0; j <= h; j++) {
            register int pj = min(j, h - j) * w;
            XPutPixel(image, i, j,
		      pixels[(min(pi, pj) * myncolors - 1) / t_scale]);
          }
        }
      }

In this case, t_width = 1 and t_height = 18.
Since it subtracts 1 from t_width, it ends up with w=0.  Then t_scale
= 0.  Then the division dies.

The fix eludes me right now...did Sir Boris write this too, or just
the Y Gradient?

---

From: Tim Phipps <[email-masked]>
Date: Mon, 14 May 2001 16:22:26 +0100

> The fix eludes me right now...did Sir Boris write this too, or just

He did and here's a patch that I think fixes it. It works over the small
number ranges and I guess it works over large ones too but I'm not a
mathematician. The original gradient codes in Graphics.c were designed
to have fixed pixmap sizes to draw in, they were later generalized to
work with arbitrary sizes and this core dump is the result. A square
gradient in a 18x1 pixmap does not make sense. I think you can have a
similar core dump with Cgrads and YGrads.

Cheers,
Tim.

Index: libs/Graphics.c
===================================================================
RCS file: /u/phippst/cvsroot/fvwm/libs/Graphics.c,v
retrieving revision 1.3
diff -u -r1.3 Graphics.c
--- libs/Graphics.c	2001/05/08 10:50:30	1.3
+++ libs/Graphics.c	2001/05/14 15:13:00
@@ -654,7 +654,6 @@
   /* create space for drawing the image locally */
   image->data = safemalloc(image->bytes_per_line * t_height);
   /* now do the fancy drawing */
-  /* draw one pixel further than expected in case line style is CapNotLast */
   switch (type)
   {
     case H_GRADIENT:
@@ -696,14 +695,12 @@
       }
     case S_GRADIENT:
       {
-        register int w = t_width - 1;
-        register int h = t_height - 1;
-	register int t_scale = w * h;
+	register int t_scale = t_width * t_height;
 	register int myncolors = ncolors * 2;
-        for (i = 0; i <= w; i++) {
-          register int pi = min(i, w - i) * h;
-          for (j = 0; j <= h; j++) {
-            register int pj = min(j, h - j) * w;
+        for (i = 0; i < t_width; i++) {
+          register int pi = min(i, t_width - 1 - i) * t_height;
+          for (j = 0; j < t_height; j++) {
+            register int pj = min(j, t_height - 1 - j) * t_width;
             XPutPixel(image, i, j,
 		      pixels[(min(pi, pj) * myncolors - 1) / t_scale]);
           }

---

From: Dan Espen <[email-masked]>
Date: Mon, 14 May 2001 19:40:29 -0400

Tim Phipps <[email-masked]> writes:
> He did and here's a patch that I think fixes it.

Thanks Tim.  I extended what you supplied to cover the other
two gradient types you mentioned.

I lack test cases that give me visual confirmation that the gradients
still look the way they should.  They wouldn't do me any good anyway
since I haven't used them enough to know what they should look like.
I guess I could figure that out, but right now, I have some other things
I should be doing.

With those fixes, the Purify tests run under Purify with no problems
being detected.