From amdmi3@mail.ru  Mon Jul 17 15:55:38 2006
Return-Path: <amdmi3@mail.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id DC29916A4DD
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jul 2006 15:55:38 +0000 (UTC)
	(envelope-from amdmi3@mail.ru)
Received: from mx27.mail.ru (mx27.mail.ru [194.67.23.65])
	by mx1.FreeBSD.org (Postfix) with ESMTP id F26A943D49
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jul 2006 15:55:37 +0000 (GMT)
	(envelope-from amdmi3@mail.ru)
Received: from [213.148.29.33] (port=33727 helo=nexii.panopticon)
	by mx27.mail.ru with esmtp 
	id 1G2VRY-000E2b-00
	for FreeBSD-gnats-submit@freebsd.org; Mon, 17 Jul 2006 19:55:36 +0400
Received: from hades.panopticon (hades.panopticon [192.168.0.2])
	by nexii.panopticon (Postfix) with ESMTP id 9899A11448
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jul 2006 20:01:46 +0400 (MSD)
Received: by hades.panopticon (Postfix, from userid 1000)
	id 83FFC312; Mon, 17 Jul 2006 19:57:13 +0400 (MSD)
Message-Id: <20060717155713.83FFC312@hades.panopticon>
Date: Mon, 17 Jul 2006 19:57:13 +0400 (MSD)
From: Dmitry Marakasov <amdmi3@mail.ru>
Reply-To: Dmitry Marakasov <amdmi3@mail.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: awk dies with SIGBUS when processing INDEX-6
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         100443
>Category:       bin
>Synopsis:       awk(1) dies with SIGBUS when processing INDEX-6
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 17 16:00:35 GMT 2006
>Closed-Date:    Mon Sep 18 15:31:32 GMT 2006
>Last-Modified:  Tue Sep 19 20:10:35 GMT 2006
>Originator:     Dmitry Marakasov
>Release:        FreeBSD 6.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD hades.panopticon 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Thu May 11 15:07:32 MSD 2006 amdmi3@hades.panopticon:/usr/obj/usr/src/sys/HADES i386

>Description:
Today, after I did `make fetchindex' in my /usr/ports, I've tried to do
some `make pretty-print-build-depends-list', which resulted in SIGBUS.
After some investigation, here's what revealed: simple command

awk -F\| '{print $1}'

dies when processing part of INDEX-6 file, which is attached. I fear that
this bug may be triggered in other places of ports/Mk/bsd.port.mk when
processing INDEX file (though I didn't get any SIGBUS'es when updating
ports today or running pkg_version).

The bug persists on my 3 boxes, all with FreeBSD-6.1-RELEASE, CPUTYPEs
pentium3 and pentium4. Turning off both CPUTYPE and -O* optimisations
doesn't seem to affect the bug.

>How-To-Repeat:
cd /usr/ports && make fetchindex && cd astro/stellarium &&
make pretty-print-build-depends-list
>Fix:
None ATM, but here's piece of INDEX-6 file that kills awk and gdb log.

--- index begins here ---
p5-Task-Catalyst-1.90|/usr/ports/www/p5-Task-Catalyst|/usr/local|All you need to start with Catalyst|/usr/ports/www/p5-Task-Catalyst/pkg-descr|lbr@FreeBSD.org|www perl5|expat-2.0.0_1 gettext-0.14.5_2 gmake-3.81_1 libiconv-1.9.2_2 p5-Algorithm-C3-0.01 p5-AppConfig-1.56 p5-Archive-Tar-1.29 p5-Array-Compare-1.13 p5-Authen-Htpasswd-0.14 p5-Authen-SASL-2.10_1 p5-Bit-Vector-6.4_1 p5-CGI-Simple-0.077_1 p5-Cache-Cache-1.05 p5-Carp-Assert-0.18 p5-Carp-Assert-More-1.12 p5-Carp-Clan-5.3 p5-Catalyst-Action-RenderView-0.04 p5-Catalyst-Devel-1.00 p5-Catalyst-Log-Log4perl-0.4 p5-Catalyst-Model-DBIC-Schema-0.16 p5-Catalyst-Plugin-Authentication-0.07 p5-Catalyst-Plugin-Authentication-Store-DBIC-0.07000 p5-Catalyst-Plugin-Authentication-Store-Htpasswd-0.020 p5-Catalyst-Plugin-Authorization-ACL-0.07 p5-Catalyst-Plugin-Authorization-Roles-0.04 p5-Catalyst-Plugin-ConfigLoader-0.11 p5-Catalyst-Plugin-DefaultEnd-0.06 p5-Catalyst-Plugin-HTML-Widget-1.1 p5-Catalyst-Plugin-I18N-0.05 p5-Catalyst-Plugin
 -Pluggable-0.04 p5-Catalyst-Plugin-Prototype-1.32 p5-Catalyst-Plugin-Session-0.05 p5-Catalyst-Plugin-Session-State-Cookie-0.02 p5-Catalyst-Plugin-Session-State-URI-0.02 p5-Catalyst-Plugin-Session-Store-File-0.07 p5-Catalyst-Plugin-Singleton-0.02 p5-Catalyst-Plugin-StackTrace-0.05 p5-Catalyst-Plugin-Static-Simple-0.14 p5-Catalyst-Plugin-SubRequest-0.10 p5-Catalyst-Plugin-XMLRPC-1.0 p5-Catalyst-Runtime-5.7000 p5-Catalyst-View-TT-0.23 p5-Class-Accessor-0.25 p5-Class-Accessor-Chained-0.01 p5-Class-C3-0.11 p5-Class-Data-Accessor-0.03 p5-Class-Data-Inheritable-0.04 p5-Class-Inspector-1.16 p5-Class-Throwable-0.10 p5-Compress-Zlib-1.41 p5-Crypt-PasswdMD5-1.3 p5-DBD-SQLite-1.12 p5-DBI-1.51 p5-DBIx-Class-0.06003 p5-DBIx-Class-Schema-Loader-0.03004 p5-Data-Dump-1.06 p5-Data-Page-2.00 p5-Data-UUID-0.14 p5-Data-Visitor-0.05 p5-Date-Calc-5.4 p5-Devel-StackTrace-1.13 p5-Digest-1.15 p5-Digest-HMAC-1.01 p5-Digest-MD5-2.36 p5-Digest-SHA1-2.11 p5-Email-Valid-0.175_1 p5-Error-0.15.009 p5-ExtUti
 ls-AutoInstall-0.63 p5-ExtUtils-CBuilder-0.18 p5-ExtUtils-MakeMaker-6.30_1 p5-ExtUtils-ParseXS-2.15 p5-File-Copy-Recursive-0.25 p5-File-Modified-0.07_1 p5-File-Slurp-9999.12 p5-File-Temp-0.16_4 p5-GSSAPI-0.22 p5-HTML-Parser-3.55 p5-HTML-Prototype-1.47 p5-HTML-Scrubber-0.08 p5-HTML-Tagset-3.10 p5-HTML-TokeParser-Simple-3.15 p5-HTML-Tree-3.20 p5-HTML-Widget-1.07 p5-HTTP-Body-0.6 p5-HTTP-Request-AsCGI-0.5 p5-HTTP-Server-Simple-0.20 p5-I18N-LangTags-0.35 p5-IO-LockedFile-0.23 p5-IO-Socket-INET6-2.51_1 p5-IO-Socket-SSL-0.97 p5-IO-String-1.08 p5-IO-Zlib-1.04_1 p5-IPC-ShareLite-0.09 p5-Lingua-EN-Inflect-1.89 p5-Lingua-EN-Inflect-Number-1.1 p5-Locale-Maketext-1.10 p5-Locale-Maketext-Lexicon-0.62 p5-Locale-Maketext-Simple-0.16 p5-Log-Log4perl-1.05 p5-MIME-Base64-3.07 p5-MIME-Types-1.16 p5-Mail-Tools-1.74 p5-Math-BigInt-1.77 p5-Memoize-1.01 p5-Module-Build-0.28.03_1 p5-Module-CoreList-2.05 p5-Module-Find-0.05 p5-Module-Install-0.63 p5-Module-Pluggable-3.01 p5-Module-Pluggable-Fast-0.1
 8 p5-Module-ScanDeps-0.61 p5-NEXT-0.60 p5-Net-1.19,1 p5-Net-DNS-0.58 p5-Net-Domain-TLD-1.65 p5-Net-IP-1.25 p5-Net-SSLeay-1.30_1 p5-Object-Signature-1.04 p5-PAR-Dist-0.10 p5-Params-Validate-0.85 p5-Path-Class-0.15 p5-PathTools-3.19 p5-Pod-Parser-1.34 p5-RPC-XML-0.58 p5-Regexp-Common-2.120 p5-SQL-Abstract-1.21 p5-SQL-Abstract-Limit-0.120 p5-Scalar-List-Utils-1.18,1 p5-Set-Object-1.15 p5-Socket6-0.19 p5-Spiffy-0.30 p5-Storable-2.15 p5-Sub-Override-0.08 p5-Sub-Uplevel-0.13 p5-Template-Timer-0.04 p5-Template-Toolkit-2.15 p5-Test-Base-0.51 p5-Test-Deep-0.095 p5-Test-Exception-0.21_1 p5-Test-Harness-2.62 p5-Test-LongString-0.09 p5-Test-MockObject-1.06 p5-Test-NoWarnings-0.082 p5-Test-Simple-0.64 p5-Test-Tester-0.10.3 p5-Test-WWW-Mechanize-1.08 p5-Test-WWW-Mechanize-Catalyst-0.37 p5-Test-Warn-0.08_1 p5-Test-use-ok-0.01 p5-Text-Balanced-1.98 p5-Text-SimpleTable-0.03 p5-Time-HiRes-1.87,1 p5-Tree-DAG_Node-1.05 p5-Tree-Simple-1.15 p5-Tree-Simple-VisitorFactory-0.10 p5-UNIVERSAL-can-1.12
  p5-UNIVERSAL-isa-0.06 p5-UNIVERSAL-require-0.10 p5-URI-1.35 p5-WWW-Mechanize-1.18 p5-XML-Parser-2.34_2 p5-YAML-0.58 p5-libwww-5.805 p5-version-0.64 perl-5.8.8 pkg-config-0.20_2 sqlite-3.3.6|expat-2.0.0_1 gettext-0.14.5_2 gmake-3.81_1 libiconv-1.9.2_2 p5-Algorithm-C3-0.01 p5-AppConfig-1.56 p5-Archive-Tar-1.29 p5-Array-Compare-1.13 p5-Authen-Htpasswd-0.14 p5-Authen-SASL-2.10_1 p5-Bit-Vector-6.4_1 p5-CGI-Simple-0.077_1 p5-Cache-Cache-1.05 p5-Carp-Assert-0.18 p5-Carp-Assert-More-1.12 p5-Carp-Clan-5.3 p5-Catalyst-Action-RenderView-0.04 p5-Catalyst-Devel-1.00 p5-Catalyst-Log-Log4perl-0.4 p5-Catalyst-Model-DBIC-Schema-0.16 p5-Catalyst-Plugin-Authentication-0.07 p5-Catalyst-Plugin-Authentication-Store-DBIC-0.07000 p5-Catalyst-Plugin-Authentication-Store-Htpasswd-0.020 p5-Catalyst-Plugin-Authorization-ACL-0.07 p5-Catalyst-Plugin-Authorization-Roles-0.04 p5-Catalyst-Plugin-ConfigLoader-0.11 p5-Catalyst-Plugin-DefaultEnd-0.06 p5-Catalyst-Plugin-HTML-Widget-1.1 p5-Catalyst-Plugin-I18N-
 0.05 p5-Catalyst-Plugin-Pluggable-0.04 p5-Catalyst-Plugin-Prototype-1.32 p5-Catalyst-Plugin-Session-0.05 p5-Catalyst-Plugin-Session-State-Cookie-0.02 p5-Catalyst-Plugin-Session-State-URI-0.02 p5-Catalyst-Plugin-Session-Store-File-0.07 p5-Catalyst-Plugin-Singleton-0.02 p5-Catalyst-Plugin-StackTrace-0.05 p5-Catalyst-Plugin-Static-Simple-0.14 p5-Catalyst-Plugin-SubRequest-0.10 p5-Catalyst-Plugin-XMLRPC-1.0 p5-Catalyst-Runtime-5.7000 p5-Catalyst-View-TT-0.23 p5-Class-Accessor-0.25 p5-Class-Accessor-Chained-0.01 p5-Class-C3-0.11 p5-Class-Data-Accessor-0.03 p5-Class-Data-Inheritable-0.04 p5-Class-Inspector-1.16 p5-Class-Throwable-0.10 p5-Compress-Zlib-1.41 p5-Crypt-PasswdMD5-1.3 p5-DBD-SQLite-1.12 p5-DBI-1.51 p5-DBIx-Class-0.06003 p5-DBIx-Class-Schema-Loader-0.03004 p5-Data-Dump-1.06 p5-Data-Page-2.00 p5-Data-UUID-0.14 p5-Data-Visitor-0.05 p5-Date-Calc-5.4 p5-Devel-StackTrace-1.13 p5-Digest-1.15 p5-Digest-HMAC-1.01 p5-Digest-MD5-2.36 p5-Digest-SHA1-2.11 p5-Email-Valid-0.175_1 p5-E
 rror-0.15.009 p5-ExtUtils-AutoInstall-0.63 p5-ExtUtils-CBuilder-0.18 p5-ExtUtils-MakeMaker-6.30_1 p5-ExtUtils-ParseXS-2.15 p5-File-Copy-Recursive-0.25 p5-File-Modified-0.07_1 p5-File-Slurp-9999.12 p5-File-Temp-0.16_4 p5-GSSAPI-0.22 p5-HTML-Parser-3.55 p5-HTML-Prototype-1.47 p5-HTML-Scrubber-0.08 p5-HTML-Tagset-3.10 p5-HTML-TokeParser-Simple-3.15 p5-HTML-Tree-3.20 p5-HTML-Widget-1.07 p5-HTTP-Body-0.6 p5-HTTP-Request-AsCGI-0.5 p5-HTTP-Server-Simple-0.20 p5-I18N-LangTags-0.35 p5-IO-LockedFile-0.23 p5-IO-Socket-INET6-2.51_1 p5-IO-Socket-SSL-0.97 p5-IO-String-1.08 p5-IO-Zlib-1.04_1 p5-IPC-ShareLite-0.09 p5-Lingua-EN-Inflect-1.89 p5-Lingua-EN-Inflect-Number-1.1 p5-Locale-Maketext-1.10 p5-Locale-Maketext-Lexicon-0.62 p5-Locale-Maketext-Simple-0.16 p5-Log-Log4perl-1.05 p5-MIME-Base64-3.07 p5-MIME-Types-1.16 p5-Mail-Tools-1.74 p5-Math-BigInt-1.77 p5-Memoize-1.01 p5-Module-Build-0.28.03_1 p5-Module-CoreList-2.05 p5-Module-Find-0.05 p5-Module-Install-0.63 p5-Module-Pluggable-3.01 p5-Mo
 dule-Pluggable-Fast-0.18 p5-Module-ScanDeps-0.61 p5-NEXT-0.60 p5-Net-1.19,1 p5-Net-DNS-0.58 p5-Net-Domain-TLD-1.65 p5-Net-IP-1.25 p5-Net-SSLeay-1.30_1 p5-Object-Signature-1.04 p5-PAR-Dist-0.10 p5-Params-Validate-0.85 p5-Path-Class-0.15 p5-PathTools-3.19 p5-Pod-Parser-1.34 p5-RPC-XML-0.58 p5-Regexp-Common-2.120 p5-SQL-Abstract-1.21 p5-SQL-Abstract-Limit-0.120 p5-Scalar-List-Utils-1.18,1 p5-Set-Object-1.15 p5-Socket6-0.19 p5-Spiffy-0.30 p5-Storable-2.15 p5-Sub-Override-0.08 p5-Sub-Uplevel-0.13 p5-Template-Timer-0.04 p5-Template-Toolkit-2.15 p5-Test-Base-0.51 p5-Test-Deep-0.095 p5-Test-Exception-0.21_1 p5-Test-Harness-2.62 p5-Test-LongString-0.09 p5-Test-MockObject-1.06 p5-Test-NoWarnings-0.082 p5-Test-Simple-0.64 p5-Test-Tester-0.10.3 p5-Test-WWW-Mechanize-1.08 p5-Test-WWW-Mechanize-Catalyst-0.37 p5-Test-Warn-0.08_1 p5-Test-use-ok-0.01 p5-Text-Balanced-1.98 p5-Text-SimpleTable-0.03 p5-Time-HiRes-1.87,1 p5-Tree-DAG_Node-1.05 p5-Tree-Simple-1.15 p5-Tree-Simple-VisitorFactory-0.1
 0 p5-UNIVERSAL-can-1.12 p5-UNIVERSAL-isa-0.06 p5-UNIVERSAL-require-0.10 p5-URI-1.35 p5-WWW-Mechanize-1.18 p5-XML-Parser-2.34_2 p5-YAML-0.58 p5-libwww-5.805 p5-version-0.64 perl-5.8.8 pkg-config-0.20_2 sqlite-3.3.6|http://search.cpan.org/dist/Task-Catalyst/|perl-5.8.8|perl-5.8.8|
p5-Template-GD-2.66|/usr/ports/www/p5-Template-GD|/usr/local|Template Toolkit plugin to interface with GD modules|/usr/ports/www/p5-Template-GD/pkg-descr|glarkin@sourcehosting.net|www textproc perl5|p5-AppConfig-1.56 p5-File-Temp-0.16_4 p5-PathTools-3.19 p5-Scalar-List-Utils-1.18,1 p5-Template-Toolkit-2.15 perl-5.8.8|p5-AppConfig-1.56 p5-File-Temp-0.16_4 p5-PathTools-3.19 p5-Scalar-List-Utils-1.18,1 p5-Template-Toolkit-2.15 perl-5.8.8|http://search.cpan.org/dist/Template-GD/|perl-5.8.8|perl-5.8.8|
--- index ends here ---

--- log begins here ---
% gdb awk
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) run -F\| '{print $1;}' index
Starting program: /usr/bin/awk -F\| '{print $1;}' index
p5-Task-Catalyst-1.90

Program received signal SIGBUS, Bus error.
0x0805109f in getrec (pbuf=0x8066b34, pbufsize=0x80653a8, isrecord=1)
    at /usr/src/usr.bin/awk/../../contrib/one-true-awk/lib.c:149
149                                     fldtab[0]->sval = buf;  /* buf == record */
(gdb) bt
#0  0x0805109f in getrec (pbuf=0x8066b34, pbufsize=0x80653a8, isrecord=1)
    at /usr/src/usr.bin/awk/../../contrib/one-true-awk/lib.c:149
#1  0x080528d1 in program (a=0x8076250, n=258) at run.c:191
#2  0x0805206e in execute (u=0x8076240) at run.c:156
#3  0x08055e60 in run (a=0x8076240) at run.c:131
#4  0x08051389 in main (argc=2, argv=0x0) at main.c:159
(gdb) display buf
1: buf = 0x8079000 "p5-Template-GD-2.66|/usr/ports/www/p5-Template-GD|/usr/local|Template Toolkit plugin to interface with GD modules|/usr/ports/www/p5-Template-GD/pkg-descr|glarkin@sourcehosting.net|www textproc perl5|p"...
(gdb) display fldtab[0]
2: fldtab[0] = (Cell *) 0x8060000
(gdb) display *fldtab[0]
3: *fldtab[0] = {ctype = 29 '\035', csub = 0 '\0', 
  nval = 0x1e <Error reading address 0x1e: Bad address>, 
  sval = 0x20001f <Error reading address 0x20001f: Bad address>, 
  fval = 1.2095376008502052e-312, tval = 2359296, cnext = 0x260025}
(gdb) quit
The program is running.  Exit anyway? (y or n) y
%
--- log ends here ---
>Release-Note:
>Audit-Trail:
Manually adding to audit trail by linimon:

We have worked around this problem right now by removing the dependencies
from the troublesome port so that the dependency list is less than the
buffer size (8K IIRC).  This keeps 'make search' going but does not fix
the underlying problem.

From: "Devon H. O'Dell" <devon.odell@coyotepoint.com>
To: bug-followup@FreeBSD.org,  amdmi3@mail.ru
Cc:  
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Wed, 13 Sep 2006 17:36:43 -0400

 Good evening,
 
 I cannot duplicate the bus error on my system. I was rather careful to 
 ensure that the cut-and-paste resulted in a file of a single line 
 containing 8694 characters.
 
 FreeBSD dho.coyotepoint.com 6.1-STABLE FreeBSD 6.1-STABLE #0: Tue Sep  5 
 15:32:39 EDT 2006     dho@dho.coyotepoint.com:/usr/obj/usr/src/sys/SMP  i386
 
 Is it still affecting you?
 
 Kind regards,
 
 Devon H. O'Dell

From: "Devon H. O'Dell" <devon.odell@coyotepoint.com>
To: Dmitry Marakasov <amdmi3@mail.ru>,  bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Thu, 14 Sep 2006 14:35:02 -0400

 Dmitry Marakasov wrote:
 > * Devon H. O'Dell (devon.odell@coyotepoint.com) wrote:
 >> I cannot duplicate the bus error on my system. I was rather careful to 
 >> ensure that the cut-and-paste resulted in a file of a single line 
 >> containing 8694 characters.
 >>
 >> FreeBSD dho.coyotepoint.com 6.1-STABLE FreeBSD 6.1-STABLE #0: Tue Sep  5 
 >> 15:32:39 EDT 2006     dho@dho.coyotepoint.com:/usr/obj/usr/src/sys/SMP  i386
 >>
 >> Is it still affecting you?
 > Yep, it does. I have 6.1-RELEASE, not STABLE, but there were no
 > changes in awk for 15 months, so you mush have the same awk. Data
 > and script to reproduce the error are attached.
 
 Ah, that's interesting. Must have been a problem with how I'm doing 
 things, I'm getting SIGBUS now. I'll see what I can do about this.
 
 --Devon

From: "Devon H. O'Dell" <devon.odell@coyotepoint.com>
To: Dmitry Marakasov <amdmi3@mail.ru>,  bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Thu, 14 Sep 2006 15:14:02 -0400

 This is interesting. If you change RECSIZE to a value that is not 8192, 
 it works fine. Probably an off-by-one somewhere in the code, because as 
 it turns out, the first record is exactly RECSIZE (8192) bytes, which 
 probably eats a terminator somewhere. I'll take a deeper look into this 
 shortly and send a patch soon.
 
 --dho

From: "Devon H. O'Dell" <devon.odell@coyotepoint.com>
To: Dmitry Marakasov <amdmi3@mail.ru>,  bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Thu, 14 Sep 2006 17:31:27 -0400

 This is a multi-part message in MIME format.
 --------------050206020800080501080703
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Got it. It was an off-by-one in fldbld(). Using the attached patch, I 
 now get:
 
  > ./run.sh
 p5-Task-Catalyst-1.90
 p5-Template-GD-2.66
 
 The patch is attached, seems to not modify other awk behavior (or crash 
 when the buffer becomes 8193 bytes, which it didn't anyway), and is also 
 available at http://databits.net/~dho/awk.patch
 
 Do we need to send this upstream?
 
 --Devon
 
 --------------050206020800080501080703
 Content-Type: text/plain;
  name="awk.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="awk.patch"
 
 Index: contrib/one-true-awk/lib.c
 ===================================================================
 RCS file: /home/ncvs/src/contrib/one-true-awk/lib.c,v
 retrieving revision 1.1.1.4
 diff -u -r1.1.1.4 lib.c
 --- contrib/one-true-awk/lib.c	16 May 2005 19:11:33 -0000	1.1.1.4
 +++ contrib/one-true-awk/lib.c	14 Sep 2006 21:27:10 -0000
 @@ -266,7 +266,7 @@
  		getsval(fldtab[0]);
  	r = fldtab[0]->sval;
  	n = strlen(r);
 -	if (n > fieldssize) {
 +	if (n >= fieldssize) {
  		xfree(fields);
  		if ((fields = (char *) malloc(n+1)) == NULL)
  			FATAL("out of space for fields in fldbld %d", n);
 
 --------------050206020800080501080703--

From: Maxim Konovalov <maxim@macomnet.ru>
To: "Devon H. O'Dell" <devon.odell@coyotepoint.com>
Cc: Ruslan Ermilov <ru@freebsd.org>, bug-followup@freebsd.org
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Fri, 15 Sep 2006 09:20:20 +0400 (MSD)

 On Thu, 14 Sep 2006, 19:15-0400, Devon H. O'Dell wrote:
 
 > Ruslan Ermilov wrote:
 > > On Thu, Sep 14, 2006 at 09:40:24PM +0000, Devon H. O'Dell wrote:
 > [snip]
 > > >  Do we need to send this upstream?
 > > >
 > > Yes, of course.
 >
 > I sent an email to BWK a couple hours ago -- hopefully he'll get it
 > soon :)
 
 Where did you send it?  There is an annoing misfeature described in
 bin/86514 the patch for which would be nice to incorporate to the
 upstream.  I see patches in bin/72370 too.
 
 -- 
 Maxim Konovalov

From: devon.odell@coyotepoint.com
To: "Maxim Konovalov" <maxim@macomnet.ru>
Cc: "Devon H. O'Dell" <devon.odell@coyotepoint.com>,
     "Ruslan Ermilov" <ru@freebsd.org>,obrien@freebsd.org,
     bug-followup@freebsd.org
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Fri, 15 Sep 2006 02:26:07 -0400 (EDT)

 > On Thu, 14 Sep 2006, 19:15-0400, Devon H. O'Dell wrote:
 >> Ruslan Ermilov wrote:
 >> > On Thu, Sep 14, 2006 at 09:40:24PM +0000, Devon H. O'Dell wrote:
 >> [snip]
 >> > >  Do we need to send this upstream?
 >> > >
 >> > Yes, of course.
 >>
 >> I sent an email to BWK a couple hours ago -- hopefully he'll get it
 >> soon :)
 >
 > Where did you send it?  There is an annoing misfeature described in
 > bin/86514 the patch for which would be nice to incorporate to the
 > upstream.  I see patches in bin/72370 too.
 
 I sent it to the email address listed on his webpage. I also included a
 link to this PR entry. I'm adding obrien@ to the CC list as he grabbed
 72370, so I guess he was the last person to get in touch with BWK.
 
 --dho
 
 > --
 > Maxim Konovalov
 >
 

From: Ruslan Ermilov <ru@FreeBSD.org>
To: "Devon H. O'Dell" <devon.odell@coyotepoint.com>,
        Dmitry Marakasov <amdmi3@mail.ru>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Fri, 15 Sep 2006 14:14:17 +0400

 On Thu, Sep 14, 2006 at 07:15:00PM -0400, Devon H. O'Dell wrote:
 > Ruslan Ermilov wrote:
 > >On Thu, Sep 14, 2006 at 09:40:24PM +0000, Devon H. O'Dell wrote:
 > [snip]
 > >> Do we need to send this upstream?
 > >> 
 > >Yes, of course.
 > 
 > I sent an email to BWK a couple hours ago -- hopefully he'll get it soon :)
 > 
 There's another function, refldbld(), that needs a similar fix.
 Actually, your patch makes it so that if "n == fieldssize" then
 malloc() will be redundantly called, when we enter this function
 again and again.  I think the following should fix it better:
 
 %%%
 Index: lib.c
 ===================================================================
 RCS file: /home/ncvs/src/contrib/one-true-awk/lib.c,v
 retrieving revision 1.1.1.4
 diff -u -p -r1.1.1.4 lib.c
 --- lib.c	16 May 2005 19:11:33 -0000	1.1.1.4
 +++ lib.c	15 Sep 2006 10:10:59 -0000
 @@ -58,7 +58,7 @@ static Cell dollar1 = { OCELL, CFLD, NUL
  void recinit(unsigned int n)
  {
  	if ( (record = (char *) malloc(n)) == NULL
 -	  || (fields = (char *) malloc(n)) == NULL
 +	  || (fields = (char *) malloc(n+1)) == NULL
  	  || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
  	  || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
  		FATAL("out of space for $0 and fields");
 %%%
 
 Could you please send me the code/scripts to reproduce a segfault?
 
 
 Cheers,
 -- 
 Ruslan Ermilov
 ru@FreeBSD.org
 FreeBSD committer

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/100443: commit references a PR
Date: Fri, 15 Sep 2006 13:33:39 +0000 (UTC)

 ru          2006-09-15 13:33:32 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/awk          Makefile 
   Added files:
     usr.bin/awk          lib.c.diff 
   Log:
   Initial memory allocation for fields was off-by-one.
   
   PR:             bin/100443
   MFC after:      3 days
   
   Revision  Changes    Path
   1.13      +1 -1      src/usr.bin/awk/Makefile
   1.1       +18 -0     src/usr.bin/awk/lib.c.diff (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: ru 
State-Changed-When: Fri Sep 15 13:45:27 UTC 2006 
State-Changed-Why:  
Fixed in 7.0-CURRENT. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Fri Sep 15 13:45:27 UTC 2006 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=100443 
State-Changed-From-To: patched->closed 
State-Changed-By: ru 
State-Changed-When: Mon Sep 18 15:31:12 UTC 2006 
State-Changed-Why:  
Fixed in 6.2-PRERELEASE. 

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

From: "David O'Brien" <obrien@freebsd.org>
To: devon.odell@coyotepoint.com
Cc: Maxim Konovalov <maxim@macomnet.ru>, Ruslan Ermilov <ru@freebsd.org>,
        bug-followup@freebsd.org
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Tue, 19 Sep 2006 12:53:26 -0700

 On Fri, Sep 15, 2006 at 02:26:07AM -0400, devon.odell@coyotepoint.com wrote:
 > There is an annoing misfeature described in
 > > bin/86514 the patch for which would be nice to incorporate to the
 > > upstream.
 
 The patch for which should have been sent upstream without bothering
 FreeBSD.  We have BWK awk and that is just how BWK awk acts.  If one
 doesn't like how it acts, one should work with BWK to change it.
 
 I really don't think changes like this should be committed unless they
 also get upstream first.  
 Changes like this simply break portability, making it so that things
 tested on FreeBSD can act differently on other platforms using BWK awk.
 
 -- 
 -- David  (obrien@FreeBSD.org)

From: Ruslan Ermilov <ru@freebsd.org>
To: "David O'Brien" <obrien@freebsd.org>
Cc: devon.odell@coyotepoint.com, Maxim Konovalov <maxim@macomnet.ru>,
        bug-followup@freebsd.org
Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6
Date: Wed, 20 Sep 2006 00:09:37 +0400

 --TybLhxa8M7aNoW+V
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Tue, Sep 19, 2006 at 12:53:26PM -0700, David O'Brien wrote:
 > On Fri, Sep 15, 2006 at 02:26:07AM -0400, devon.odell@coyotepoint.com wro=
 te:
 > > There is an annoing misfeature described in
 > > > bin/86514 the patch for which would be nice to incorporate to the
 > > > upstream.
 >=20
 > The patch for which should have been sent upstream without bothering
 > FreeBSD.  We have BWK awk and that is just how BWK awk acts.  If one
 > doesn't like how it acts, one should work with BWK to change it.
 >=20
 > I really don't think changes like this should be committed unless they
 > also get upstream first. =20
 > Changes like this simply break portability, making it so that things
 > tested on FreeBSD can act differently on other platforms using BWK awk.
 >=20
 Quite the opposite I'd say, since awk(1) is a POSIX application
 which explicitly requires to accept "no space" between an option
 and its argument.  Or course the change will be sent upstream,
 and that's the reason why it was made a temporary patch.  Users
 are happy, upstream integration can take a long time (it's not
 an actively developed application, as you know).
 
 
 Cheers,
 --=20
 Ruslan Ermilov
 ru@FreeBSD.org
 FreeBSD committer
 
 --TybLhxa8M7aNoW+V
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (FreeBSD)
 
 iD8DBQFFEE6BqRfpzJluFF4RAh8uAJ9G/ZCwuYRmVXKIzNhn44gXejSKwwCeIxL+
 HUTdIWgw+DrYncJPESSzO1c=
 =t2rP
 -----END PGP SIGNATURE-----
 
 --TybLhxa8M7aNoW+V--
>Unformatted:
