xref: /illumos-gate/usr/src/test/util-tests/tests/awk/gnu/arynocls.awk (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
1#To: bug-gnu-utils@gnu.org
2#From: Kristj�n J�nasson <kristjan@decode.is>
3#Subject: Gawk bug
4#Cc: arnold@gnu.org
5#
6#Hi!
7#
8#The following seems to be a bug in gawk. I have tried as I could to
9#minimize the bug-causing program, so of course it does not seem to do
10#anything useful in its present form. The error message received is:
11#
12#gawk: test.awk:15: fatal error: internal error
13#Aborted
14#
15#Note that there is an attached file that the program reads, called "a". I
16#played with the program a fair bit and my feeling is that the error is
17#related with the delete statement, and not the reading of the file and the
18#close statement. At one point I was able to remove the file reading and
19#still obtain the error. If, for example, I remove the close statement and
20#make two copies of the file instead, (reading one copy in sub1 and the
21#other in sub2), the error still occurs.
22#
23#The operating system is Red Hat Linux, version 6.0, the gawk is version
24#3.0.4, and the gawk was obtained from an rpm file gawk-3.0.4-1.i386.rpm.
25#
26#The program is:
27#
28
29# Wed Mar  8 13:41:34 IST 2000
30# ADR: modified to use INPUT, so can set it from command line.
31#      When run, no output is produced, but it shouldn't core
32#      dump, either.
33#
34# The program bug is to not close the file in sub2.
35
36function sub1(x) {
37# while (getline < "a" == 1) i++
38  while (getline < INPUT == 1) i++
39# close("a")
40  close(INPUT)
41}
42
43function sub2(x) {
44  i=0
45  delete y
46# while (getline < "a" == 1) z[++i] = $1
47  while (getline < INPUT == 1) z[++i] = $1
48  for(i in z) y[i] = x[i] + z[i]
49}
50
51function sub3(x, y, z) {
52  sub2(x)
53  for(i=1; i<=4; i++) z[i] = y[i]
54}
55
56BEGIN {
57  # Changes for illumos:
58  #   - Set INPUT
59  #   - Print out z, so that we know we read the right data.
60  INPUT = "arynocls.data"
61
62  sub1(x)
63  sub2(x)
64  sub3(x, y, z)
65
66  for(i=1; i<=4; i++) print z[i]
67}
68#
69#And the data file is:
70#
71# 32.440    3.830    3.383700000000000    10.08    298  865
72# 32.440    3.830    3.383700000000000    10.08    298  865
73# 32.440    3.830    3.383700000000000    10.08    298  865
74# 32.440    3.830    3.383700000000000    10.08    298  865
75# 32.440    3.830    3.383700000000000    10.08    298  865
76# 32.440    3.830    3.383700000000000    10.08    298  865
77# 32.440    3.830    3.383700000000000    10.08    298  865
78# 32.440    3.830    3.383700000000000    10.08    298  865
79# 32.440    3.830    3.383700000000000    10.08    298  865
80# 32.440    3.830    3.383700000000000    10.08    298  865
81# 32.440    3.830    3.383700000000000    10.08    298  865
82# 32.440    3.830    3.383700000000000    10.08    298  865
83# 32.440    3.830    3.383700000000000    10.08    298  865
84# 32.440    3.830    3.383700000000000    10.08    298  865
85# 32.440    3.830    3.383700000000000    10.08    298  865
86# 32.440    3.830    3.383700000000000    10.08    298  865
87# 32.440    3.830    3.383700000000000    10.08    298  865
88# 32.440    3.830    3.383700000000000    10.08    298  865
89# 32.440    3.830    3.383700000000000    10.08    298  865
90# 32.440    3.830    3.383700000000000    10.08    298  865
91# 32.440    3.830    3.383700000000000    10.08    298  865
92# 32.440    3.830    3.383700000000000    10.08    298  865
93# 32.440    3.830    3.383700000000000    10.08    298  865
94# 32.440    3.830    3.383700000000000    10.08    298  865
95# 32.440    3.830    3.383700000000000    10.08    298  865
96# 32.440    3.830    3.383700000000000    10.08    298  865
97# 32.440    3.830    3.383700000000000    10.08    298  865
98# 32.440    3.830    3.383700000000000    10.08    298  865
99# 32.440    3.830    3.383700000000000    10.08    298  865
100# 32.440    3.830    3.383700000000000    10.08    298  865
101#
102#
103