From mi@aldan.algebra.com  Sun Apr 20 05:18:40 2008
Return-Path: <mi@aldan.algebra.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5FED81065671;
	Sun, 20 Apr 2008 05:18:40 +0000 (UTC)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224])
	by mx1.freebsd.org (Postfix) with ESMTP id 170A38FC13;
	Sun, 20 Apr 2008 05:18:39 +0000 (UTC)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (localhost [127.0.0.1])
	by aldan.algebra.com (8.14.2/8.14.1) with ESMTP id m3K4vKxA078636
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sun, 20 Apr 2008 00:57:21 -0400 (EDT)
	(envelope-from mi@aldan.algebra.com)
Received: (from mi@localhost)
	by aldan.algebra.com (8.14.2/8.14.1/Submit) id m3K4vKBI078635;
	Sun, 20 Apr 2008 00:57:20 -0400 (EDT)
	(envelope-from mi)
Message-Id: <200804200457.m3K4vKBI078635@aldan.algebra.com>
Date: Sun, 20 Apr 2008 00:57:20 -0400 (EDT)
From: "Mikhail T." <mi@aldan.algebra.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: x11@freebsd.org
Subject: XCreateImage fails in most recent XOrg
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         122924
>Category:       ports
>Synopsis:       XCreateImage fails in most recent x11/XOrg
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-x11
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 20 05:20:02 UTC 2008
>Closed-Date:    Thu Mar 19 14:43:21 UTC 2009
>Last-Modified:  Thu Mar 19 14:43:21 UTC 2009
>Originator:     Mikhail T.
>Release:        FreeBSD 7.0-STABLE amd64
>Organization:
Virtual Estates, Inc. (http://sybpipe.com/)
>Environment:
System: FreeBSD aldan.algebra.com 7.0-STABLE FreeBSD 7.0-STABLE #0: Sat Mar 8 16:02:37 EST 2008 root@aldan.algebra.com:/meow/obj/var/src/sys/SILVER-SMP amd64

>Description:
	XCreateImage seems to fail quite often now... The attached
	program, for example, fails for me (depth 24), but succeeds,
	if I hardcode the depth at 8.

	The program reports success, when compiled on RedHat 4 with
	its older X11 build.

	The example below is fairly artificial, but a real-world program
	fails to run -- crashes trying to use the result of
	XCreateImage().

	I'm talking about the editors/xcoral port.

>How-To-Repeat:

#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <ctype.h>

#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>

int
main(int argc, char **argv)
{
	Display *display;
	int screen, depth;
	XImage *xi;
	Visual *visual;

	if ((display = XOpenDisplay(NULL)) == NULL) {
		fprintf(stderr, "Can not connect to Xserver. \n");
		exit(1);
	}
	screen = DefaultScreen(display);
	visual = DefaultVisual(display, screen);
	depth = DefaultDepth(display, screen);

	xi = XCreateImage(display, visual,
	    depth, ZPixmap, 0, 0, 24, 24, 32, 72);

	if (xi == NULL) {
		fprintf(stderr, "XCreateImage failed (depth %d).\n", depth);
		exit(2);
	} else
		fprintf(stderr, "XCreateImage succeeded (depth %d).\n", depth);
	XDestroyImage(xi);
	XCloseDisplay(display);

	exit(0);
}
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->freebsd-x11 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Apr 20 12:10:25 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122924 

From: "Dorr H. Clark" <dclark@engr.scu.edu>
To: bug-followup@FreeBSD.org
Cc: freebsd-x11@FreeBSD.org, freebsd-bugs@FreeBSD.org,
        "Mikhail T." <mi@aldan.algebra.com>
Subject: Re: ports/122924: XCreateImage fails in most recent x11/XOrg
Date: Wed, 8 Oct 2008 01:04:45 -0700 (PDT)

 Bug Number 122924: XcreateImage fails in most recent x11/XOrg
 
 This is actually not a bug in FreeBSD, in fact during the investigation
 of this bug we were able to reproduce it on Linux (although at a higher
 level).
 
 To resolve a bug in XOrg file, we need to have the source files for XOrgalong 
 with the mandatory external dependencies.  Code changes have been made in file 
 ImUtil.c in directory /usr/ports/distfiles/xorg/lib/libX11-1.1.3/src
 and at the bottom of this writeup is an explanation of how to retrieve
 the software needed for investigating this bug.
 
 The function XCreateImage takes image_bytes_per_line as one of the inputs. 
 This parameter determines the value for Number of bytes between a pixel 
 on one line and the pixel with the same X coordinate on the next line.
 In case the calling function sets this parameter to 0, XCreateImage 
 calculates the minimum value for image_bytes_per_line depending upon 
 the format of image and the required depth.
 Thus, if the input value for image_bytes_per_line is zero or less than 
 the minimum value, it is set equal to the minimum value.
 
 Here is the patch:
 
 --- ImUtil_org.c	2008-08-21 12:46:15.000000000 +0000
 +++ ImUtil.c	2008-08-21 12:47:37.000000000 +0000
 @@ -372,10 +372,8 @@
  	    min_bytes_per_line =
  	        ROUNDUP((width + offset), image->bitmap_pad);
  	}
 -	if (image_bytes_per_line == 0 ) {
 +	if (image_bytes_per_line == 0 ||image_bytes_per_line < min_bytes_per_line  ) {
  	    image->bytes_per_line = min_bytes_per_line;
 -	} else if (image_bytes_per_line < min_bytes_per_line) {
 -		return 0;
  	} 
  	else {
  	    image->bytes_per_line = image_bytes_per_line;
 
 
 Shikha Bansal , engineer
 Dorr H. Clark, advisor
 Graduate School of Engineering
 Santa Clara University,
 Santa Clara CA
 
 http://www.cse.scu.edu/~dclark/coen_284_FreeBSD/122924.txt
 
 1) GET THE XORG SOURCES 
 	a)	cd /usr/ports/x11/xorg
 	b)	make (you must be connected to internet)
    This copies the source files into /usr/ports/distfiles
 
 2) GET THE EXTERNAL DEPENDENCIES
 	a)	go to xcb.freedesktop.org/dist/
 	b)	Download libxcb-0.9.93.tar.gz and xcb-proto-0.9.93.tar.gz in directory /usr/ports/distfiles/xorg/lib
 	c)	cd xcb-proto-0.9.93 
 	d)	make
 	e)	cp *.pc /usr/local/libdata/pkgconfig
 	f)	make install
 	g)	similarly install libxcb-0.9.93
 
 3)  INSTALL XORG AS A PORT
 	a)	cd /usr/ports/distfiles/xorg/lib/libX11-1.1.3/include
 	b)	mkdir xcb
 	c)	copy the following 4 headers from libxcb-0.9.93 to xcb folder created in previous step:
 	xcb.h,xproto.h,xcbext.h,xcblib.h
 	d)	make install
 
  
 
 
 
 
State-Changed-From-To: open->closed 
State-Changed-By: pav 
State-Changed-When: Thu Mar 19 14:43:01 UTC 2009 
State-Changed-Why:  
Upstream claims this is a bug in xcoral: 

http://bugs.freedesktop.org/show_bug.cgi?id=15615 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122924 
>Unformatted:
