From root@offworld.cqasys.com  Wed Feb  1 02:16:36 2006
Return-Path: <root@offworld.cqasys.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 512C816A422;
	Wed,  1 Feb 2006 02:16:36 +0000 (GMT)
	(envelope-from root@offworld.cqasys.com)
Received: from imf18aec.mail.bellsouth.net (imf18aec.mail.bellsouth.net [205.152.59.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 36C6543D5F;
	Wed,  1 Feb 2006 02:16:29 +0000 (GMT)
	(envelope-from root@offworld.cqasys.com)
Received: from ibm61aec.bellsouth.net ([65.7.181.160])
          by imf18aec.mail.bellsouth.net with ESMTP
          id <20060201021628.FJBN26179.imf18aec.mail.bellsouth.net@ibm61aec.bellsouth.net>;
          Tue, 31 Jan 2006 21:16:28 -0500
Received: from offworld.cqasys.com ([65.7.181.160])
          by ibm61aec.bellsouth.net with ESMTP
          id <20060201021624.PDSO28960.ibm61aec.bellsouth.net@offworld.cqasys.com>;
          Tue, 31 Jan 2006 21:16:24 -0500
Received: by offworld.cqasys.com (Postfix, from userid 0)
	id 92CD93981C; Tue, 31 Jan 2006 21:16:21 -0500 (EST)
Message-Id: <20060201021621.92CD93981C@offworld.cqasys.com>
Date: Tue, 31 Jan 2006 21:16:21 -0500 (EST)
From: Jeffrey H. Johnson <CPE1704TKS@bellsouth.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: kris@obsecurity.org, mnag@FreeBSD.org, ports@FreeBSD.org, ports-amd64@FreeBSD.org, CPE1704TKS@bellsouth.net
Subject: [PATCH] sysutils/heirloom: [Unbreak AMD64 build]
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         92658
>Category:       ports
>Synopsis:       [PATCH] sysutils/heirloom: [Unbreak AMD64 build]
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    vd
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 01 02:20:03 GMT 2006
>Closed-Date:    Tue Feb 07 10:48:23 GMT 2006
>Last-Modified:  Tue Feb 07 10:48:23 GMT 2006
>Originator:     Jeffrey H. Johnson
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD offworld.cqasys.com 6.0-STABLE FreeBSD 6.0-STABLE #21: Wed Jan 18 22:35:45 EST 2006
>Description:

> Subject: heirloom-060122 failed on amd64 6
> [.. snip ..]
> http://pointyhat.freebsd.org/errorlogs/amd64-errorlogs/e.7.2006011605/heirloom-060122.log
> http://portsmon.freebsd.org/portoverview.py?category=&portname=heirloom&wildcard=

This only seems to fail on 6 and 7, not on 5 which is strange!  It
also works on all other 64-bit architectures.  The code in question
is actually code from OpenSolaris.  I see no reason why it would
fail, but I do not have access to an AMD64 machine.  

I had someone who does send me a back trace, and the error is in a 
debugging statement, and apparently it is argv becoming corrupted.

Commenting out the debugging statements fix the port, and it also
produces bit-identical output, verified by sha256.  

I can only assume this is a compiler bug on AMD64 FreeBSD!  This
code also works correctly when compiled for 64-bit PPC Mac OS X.

Someone else can verify?

Again, not compiling-in these two fprintf statements will fix the
build on AMD64.  I wasn't able to test using a non-default compiler.

Thanks.

Added file(s):
- files/patch-spell::spellin.c

Generated with FreeBSD Port Tools 0.63
>How-To-Repeat:
>Fix:

--- heirloom-060122.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/sysutils/heirloom/files/patch-spell::spellin.c /usr/home/trn/heirloom/files/patch-spell::spellin.c
--- /usr/ports/sysutils/heirloom/files/patch-spell::spellin.c	Wed Dec 31 19:00:00 1969
+++ /usr/home/trn/heirloom/files/patch-spell::spellin.c	Tue Jan 31 21:10:33 2006
@@ -0,0 +1,19 @@
+--- spell/spellin.c.orig	Tue Jan 31 20:45:43 2006
++++ spell/spellin.c	Tue Jan 31 21:05:25 2006
+@@ -146,12 +146,16 @@
+ 	for (i = 0; i < wp; i++)
+ 		le32p(table[i], (char *)&table[i]);
+ 	fwrite((char *)table, sizeof (*table), wp, stdout);
++#ifndef __amd64__
+ 	fprintf(stderr,
+ 	    "%s: %ld items, %d ignored, %d extra, %u words occupied\n",
+ 	    argv[0], (long)count, ignore, extra, (unsigned)wp);
++#endif /* !amd64 */
+ 	count -= ignore;
++#ifndef __amd64__
+ 	fprintf(stderr, "%s: %f table bits/item, %f table+index bits\n",
+ 	    argv[0], (((float)BYTE * wp) * sizeof (*table) / count),
+ 	    (BYTE * ((float)wp * sizeof (*table) + sizeof (hindex)) / count));
++#endif /* !amd64 */
+ 	return 0;
+ }
--- heirloom-060122.patch ends here ---

>Release-Note:
>Audit-Trail:
Adding to audit trail from misfiled PR ports/92663:

Date: Tue, 31 Jan 2006 21:19:47 -0600
From: "Larry Rosenman" <ler@lerctr.org>

 I'm not a heirloom user, BUT, I can give you shell(ssh) access
 To an AMD64 box if it would help.  (the box is running 6.0-STABLE from a few
 days
 Ago.)
 
 LER
 -- 
 Larry Rosenman                     http://www.lerctr.org/~ler
 Phone: +1 512-248-2683                 E-Mail: ler@lerctr.org
 US Mail: 430 Valona Loop, Round Rock, TX 78681-3683 US


From: "Jeffrey H. Johnson" <CPE1704TKS@bellsouth.net>
To: Larry Rosenman <ler@lerctr.org>, FreeBSD-gnats-submit@freebsd.org
Cc: kris@obsecurity.org, mnag@FreeBSD.org, ports@FreeBSD.org,
 ports-amd64@FreeBSD.org, CPE1704TKS@bellsouth.net
Subject: Re: ports/92658: [PATCH] sysutils/heirloom: [Unbreak AMD64 build] 
Date: Wed, 01 Feb 2006 17:41:58 -0500

 OK, I have an update here:
 
 -----------------------------------
 --- spell/spellin.c.orig      Wed Feb  1 23:34:58 2006
 +++ spell/spellin.c   Wed Feb  1 23:27:02 2006
 @@ -103,7 +103,7 @@
         z = huff((1L<<HASHWIDTH)/atof(argv[1]));
         fprintf(stderr, "%s: expected code widths = %f\n",
             argv[0], z);
 -       for (count = 0; scanf("%lo", (long *)&h) == 1; ++count) {
 +       for (count = 0; scanf("%o", (long *)&h) == 1; ++count) {
                 if ((t = h >> (HASHWIDTH - INDEXWIDTH)) != u) {
                         if (bp != B)
                                 wp++;
 -----------------------------------
 
 This should work on all architectures where int32_t is the same size
 as int, which I *believe* should cover all current FreeBSD platforms.
 
 If someone has a better solution, I'd be glad to hear it.  I'm also
 puzzled as to why this seems to work on pointyhat without the 
 modifications but I don't have access to AMD64 running 5 to examine. 
 
 If someone who knows what they are doing can apply a more proper fix,
 please do. :p
 
 --
 Jeffrey H. Johnson
 CPE1704TKS@bellsouth.net

From: Kris Kennaway <kris@obsecurity.org>
To: "Jeffrey H. Johnson" <CPE1704TKS@bellsouth.net>
Cc: Larry Rosenman <ler@lerctr.org>, FreeBSD-gnats-submit@freebsd.org,
	kris@obsecurity.org, mnag@FreeBSD.org, ports@FreeBSD.org,
	ports-amd64@FreeBSD.org
Subject: Re: ports/92658: [PATCH] sysutils/heirloom: [Unbreak AMD64 build]
Date: Wed, 1 Feb 2006 17:52:40 -0500

 --8P1HSweYDcXXzwPJ
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Wed, Feb 01, 2006 at 05:41:58PM -0500, Jeffrey H. Johnson wrote:
 > OK, I have an update here:
 >=20
 > -----------------------------------
 > --- spell/spellin.c.orig      Wed Feb  1 23:34:58 2006
 > +++ spell/spellin.c   Wed Feb  1 23:27:02 2006
 > @@ -103,7 +103,7 @@
 >         z =3D huff((1L<<HASHWIDTH)/atof(argv[1]));
 >         fprintf(stderr, "%s: expected code widths =3D %f\n",
 >             argv[0], z);
 > -       for (count =3D 0; scanf("%lo", (long *)&h) =3D=3D 1; ++count) {
 > +       for (count =3D 0; scanf("%o", (long *)&h) =3D=3D 1; ++count) {
 >                 if ((t =3D h >> (HASHWIDTH - INDEXWIDTH)) !=3D u) {
 >                         if (bp !=3D B)
 >                                 wp++;
 > -----------------------------------
 >=20
 > This should work on all architectures where int32_t is the same size
 > as int, which I *believe* should cover all current FreeBSD platforms.
 >=20
 > If someone has a better solution, I'd be glad to hear it.  I'm also
 > puzzled as to why this seems to work on pointyhat without the=20
 > modifications but I don't have access to AMD64 running 5 to examine.=20
 
 It's probably as simple as that the amd64 5 build hasn't been rerun
 since the recent update :)
 
 Kris
 
 --8P1HSweYDcXXzwPJ
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.2 (FreeBSD)
 
 iD8DBQFD4Tu3Wry0BWjoQKURAhZgAKDCLAuyXvbaQm1xGf6sxQHAKy/V9wCfa5oV
 XybmT4SRufpnBoy3Ss0h5Ho=
 =hyVK
 -----END PGP SIGNATURE-----
 
 --8P1HSweYDcXXzwPJ--
Responsible-Changed-From-To: freebsd-ports-bugs->vd 
Responsible-Changed-By: vd 
Responsible-Changed-When: Thu Feb 2 14:17:46 UTC 2006 
Responsible-Changed-Why:  
Grab! 

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

From: Vasil Dimov <vd@FreeBSD.org>
To: "Jeffrey H\. Johnson" <CPE1704TKS@bellsouth.net>
Cc: bug-followup@FreeBSD.org, Larry Rosenman <ler@lerctr.org>, kris@obsecurity.org, mnag@FreeBSD.org, ports@FreeBSD.org
Subject: Re: ports/92658: [PATCH] sysutils/heirloom: [Unbreak AMD64 build]
Date: Fri, 3 Feb 2006 19:34:04 +0200

 --M9NhX3UHpAaciwkO
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Wed, Feb 01, 2006 at 10:50:07PM +0000, Jeffrey H. Johnson wrote:
 > The following reply was made to PR ports/92658; it has been noted by GNAT=
 S.
 >=20
 > From: "Jeffrey H. Johnson" <CPE1704TKS@bellsouth.net>
 > To: Larry Rosenman <ler@lerctr.org>, FreeBSD-gnats-submit@freebsd.org
 > Cc: kris@obsecurity.org, mnag@FreeBSD.org, ports@FreeBSD.org,
 >  ports-amd64@FreeBSD.org, CPE1704TKS@bellsouth.net
 > Subject: Re: ports/92658: [PATCH] sysutils/heirloom: [Unbreak AMD64 build=
 ]=20
 > Date: Wed, 01 Feb 2006 17:41:58 -0500
 >=20
 >  OK, I have an update here:
 > =20
 >  -----------------------------------
 >  --- spell/spellin.c.orig      Wed Feb  1 23:34:58 2006
 >  +++ spell/spellin.c   Wed Feb  1 23:27:02 2006
 >  @@ -103,7 +103,7 @@
 >          z =3D huff((1L<<HASHWIDTH)/atof(argv[1]));
 >          fprintf(stderr, "%s: expected code widths =3D %f\n",
 >              argv[0], z);
 >  -       for (count =3D 0; scanf("%lo", (long *)&h) =3D=3D 1; ++count) {
 >  +       for (count =3D 0; scanf("%o", (long *)&h) =3D=3D 1; ++count) {
 >                  if ((t =3D h >> (HASHWIDTH - INDEXWIDTH)) !=3D u) {
 >                          if (bp !=3D B)
 >                                  wp++;
 >  -----------------------------------
 > =20
 >  This should work on all architectures where int32_t is the same size
 >  as int, which I *believe* should cover all current FreeBSD platforms.
 
 Do you like the following:
 
 --- spellin.c.diff begins here ---
 --- spell/spellin.c.orig	Fri Feb  3 19:13:19 2006
 +++ spell/spellin.c	Fri Feb  3 19:19:20 2006
 @@ -77,6 +77,7 @@
  main(int argc, char **argv)
  {
  	int32_t h, k, d;
 +	unsigned hu;
  	int32_t  i;
  	int32_t count;
  	int32_t w1;
 @@ -103,7 +104,8 @@
  	z =3D huff((1L<<HASHWIDTH)/atof(argv[1]));
  	fprintf(stderr, "%s: expected code widths =3D %f\n",
  	    argv[0], z);
 -	for (count =3D 0; scanf("%lo", (long *)&h) =3D=3D 1; ++count) {
 +	for (count =3D 0; scanf("%o", &hu) =3D=3D 1; ++count) {
 +		h =3D (int32_t)hu;
  		if ((t =3D h >> (HASHWIDTH - INDEXWIDTH)) !=3D u) {
  			if (bp !=3D B)
  				wp++;
 --- spellin.c.diff ends here ---
 
 It is aimed at the sizeof(int) !=3D sizeof(int32_t) case.
 Unfortunately there is no way to scanf int32_t portably.
 
 --=20
 Vasil Dimov
 
 --M9NhX3UHpAaciwkO
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 
 iD8DBQFD45QMFw6SP/bBpCARAszPAKCbpPJMj7WVpQ6p60+v0Y7g0BQptwCgp/Nz
 D4PrPPDo0a9+bZmVczJIKaE=
 =w5Pp
 -----END PGP SIGNATURE-----
 
 --M9NhX3UHpAaciwkO--

From: "Jeffrey H. Johnson" <CPE1704TKS@bellsouth.net>
To: vd@FreeBSD.org
Cc: "Jeffrey H. Johnson" <CPE1704TKS@bellsouth.net>, bug-followup@FreeBSD.org,
 Larry Rosenman <ler@lerctr.org>, kris@obsecurity.org, mnag@FreeBSD.org, ports@FreeBSD.org
Subject: Re: ports/92658: [PATCH] sysutils/heirloom: [Unbreak AMD64 build]
Date: Fri, 03 Feb 2006 14:20:12 -0500

 On February 3, 2006 7:34 PM Vasil Dimov <vd@FreeBSD.org> wrote:
 
 > Do you like the following:
 > [snip]
 >
 > It is aimed at the sizeof(int) != sizeof(int32_t) case.
 > Unfortunately there is no way to scanf int32_t portably.
 
 Seems to look good from here.
 
 --
 Jeffrey H. Johnson
 CPE1704TKS@bellsouth.net
State-Changed-From-To: open->closed 
State-Changed-By: vd 
State-Changed-When: Tue Feb 7 10:47:03 UTC 2006 
State-Changed-Why:  
Reworked patch committed, thanks! 

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