xref: /illumos-gate/usr/src/test/util-tests/tests/awk/gnu/nasty.awk (revision d8849d7dee03b84a3fa281ec65eb9e3d86d3756b)
1#From hankedr@manatee.dms.auburn.edu  Tue Oct 13 22:15:59 1998
2#Return-Path: <hankedr@manatee.dms.auburn.edu>
3#Received: from cssun.mathcs.emory.edu (cssun.mathcs.emory.edu [170.140.150.1])
4#	by dmx.netvision.net.il (8.9.0.Beta5/8.8.6) with ESMTP id PAA03924
5#	for <arobbins@netvision.net.il>; Tue, 13 Oct 1998 15:32:13 +0200 (IST)
6#Received: from mescaline.gnu.org (we-refuse-to-spy-on-our-users@mescaline.gnu.org [158.121.106.21]) by cssun.mathcs.emory.edu (8.7.5/8.6.9-940818.01cssun) with ESMTP id KAA11644 for <arnold@mathcs.emory.edu>; Tue, 13 Oct 1998 10:22:32 -0400 (EDT)
7#Received: from manatee.dms.auburn.edu (manatee.dms.auburn.edu [131.204.53.104])
8#	by mescaline.gnu.org (8.9.1a/8.9.1) with ESMTP id KAA03250
9#	for <arnold@gnu.org>; Tue, 13 Oct 1998 10:25:32 -0400
10#Received: (from hankedr@localhost)
11#	by manatee.dms.auburn.edu (8.9.1a/8.9.1) id JAA13348;
12#	Tue, 13 Oct 1998 09:22:29 -0500 (CDT)
13#Date: Tue, 13 Oct 1998 09:22:29 -0500 (CDT)
14#Message-Id: <199810131422.JAA13348@manatee.dms.auburn.edu>
15#From: Darrel Hankerson <hankedr@dms.auburn.edu>
16#To: arnold@gnu.org
17#In-reply-to: <199810131313.QAA31784@alpha.netvision.net.il> (message from
18#	Aharon Robbins on Tue, 13 Oct 1998 16:10:36 +0200)
19#Subject: Re: full text of bug report?
20#Mime-Version: 1.0
21#Content-Type: text/plain; charset=US-ASCII
22#X-UIDL: bf3fce492dad4ab030c561e7b2f27d0a
23#Status: RO
24#
25#   Do you have the full text of the	a = a "\n" f() 	bug report?
26#   I can't find it.... I'm not sure there really is a bug.
27#
28#Yes, see below.
29#
30#His example has unnecessary fragments (in particular, the use of
31#gensub is irrelevant).  As I wrote to you earlier, the interesting
32#question for me is:
33#
34#   Is the concatenation result undefined?  If the result is defined or
35#   implementation-dependent, then gawk has a bug.
36#
37#
38#=== Original report =====================================================
39#From: Attila Torcsvari <arcdev@mail.matav.hu>
40#To: "'bug-gnu-utils@prep.ai.mit.edu'" <bug-gnu-utils@gnu.org>
41#Subject: gawk 3.0.3 bug
42#Date: Thu, 17 Sep 1998 18:12:13 +0200
43#MIME-Version: 1.0
44#Content-Transfer-Encoding: 7bit
45#Resent-From: bug-gnu-utils@gnu.org
46#X-Mailing-List: <bug-gnu-utils@gnu.org> archive/latest/3396
47#X-Loop: bug-gnu-utils@gnu.org
48#Precedence: list
49#Resent-Sender: bug-gnu-utils-request@gnu.org
50#Content-Transfer-Encoding: 7bit
51#Content-Type: text/plain; charset="us-ascii"
52#Content-Length: 618
53#
54#Bug-gnuers,
55#please pass it to the responsible.
56#
57#The following generates something interesting:
58#
59BEGIN{
60a="aaaaa"
61a=a a #10
62a=a a #20
63a=a a #40
64a=a a #80
65a=a a #160
66a=a a # i.e. a is long enough
67
68a=a"\n"f() # this causes the trouble
69print a # guess the result
70}
71
72function f()
73{
74#print "a before: ", a
75#a=gensub("a","123,","g",a) # 'a' will be just a bit longer (4 times, but still should fit: 4*160=640)
76gsub(/a/, "123", a)
77#print "a after: ", a
78return "X"
79}
80#
81#Possible reason:
82#during f the a is modified,
83#it can be even freed, because gensub modifies its size
84#the printout contains trash.
85#
86#Used version: VC compiled WinNT 32 bit Intel.
87#
88#Regards,
89#
90#Attila Torcsvari
91#Arcanum Development
92#
93