1*e6d6c189SCody Peter MelloBEGIN {
2*e6d6c189SCody Peter Mello	file = (ENVIRON["WORKDIR"] "/seq")
3*e6d6c189SCody Peter Mello	print "000800" > file
4*e6d6c189SCody Peter Mello	close(file)
5*e6d6c189SCody Peter Mello	ARGV[1] = file
6*e6d6c189SCody Peter Mello	ARGC = 2
7*e6d6c189SCody Peter Mello}
8*e6d6c189SCody Peter Mello
9*e6d6c189SCody Peter Mello{ printf "%06d", $1 + 1 > file;
10*e6d6c189SCody Peter Mello  printf "%06d", $1 + 1 }
11*e6d6c189SCody Peter Mello# Date: Mon, 20 Jan 1997 15:14:06 -0600 (CST)
12*e6d6c189SCody Peter Mello# From: Dave Bodenstab <emory!synet.net!imdave>
13*e6d6c189SCody Peter Mello# To: bug-gnu-utils@prep.ai.mit.edu
14*e6d6c189SCody Peter Mello# Subject: GNU awk 3.0.2 core dump
15*e6d6c189SCody Peter Mello# Cc: arnold@gnu.ai.mit.edu
16*e6d6c189SCody Peter Mello#
17*e6d6c189SCody Peter Mello# The following program produces a core file on my FreeBSD system:
18*e6d6c189SCody Peter Mello#
19*e6d6c189SCody Peter Mello# bash$ echo 000800 >/tmp/seq
20*e6d6c189SCody Peter Mello# bash$ gawk '{ printf "%06d", $1 + 1 >"/tmp/seq";
21*e6d6c189SCody Peter Mello# 	      printf "%06d", $1 + 1 }' /tmp/seq
22*e6d6c189SCody Peter Mello#
23*e6d6c189SCody Peter Mello# This fragment comes from mgetty+sendfax.
24*e6d6c189SCody Peter Mello#
25*e6d6c189SCody Peter Mello# Here is the trace:
26*e6d6c189SCody Peter Mello#
27*e6d6c189SCody Peter Mello# Script started on Mon Jan 20 15:09:04 1997
28*e6d6c189SCody Peter Mello# bash$ gawk --version
29*e6d6c189SCody Peter Mello# GNU Awk 3.0.2
30*e6d6c189SCody Peter Mello# Copyright (C) 1989, 1991-1996 Free Software Foundation.
31*e6d6c189SCody Peter Mello#
32*e6d6c189SCody Peter Mello# This program is free software; you can redistribute it and/or modify
33*e6d6c189SCody Peter Mello# it under the terms of the GNU General Public License as published by
34*e6d6c189SCody Peter Mello# the Free Software Foundation; either version 2 of the License, or
35*e6d6c189SCody Peter Mello# (at your option) any later version.
36*e6d6c189SCody Peter Mello#
37*e6d6c189SCody Peter Mello# This program is distributed in the hope that it will be useful,
38*e6d6c189SCody Peter Mello# but WITHOUT ANY WARRANTY; without even the implied warranty of
39*e6d6c189SCody Peter Mello# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40*e6d6c189SCody Peter Mello# GNU General Public License for more details.
41*e6d6c189SCody Peter Mello#
42*e6d6c189SCody Peter Mello# You should have received a copy of the GNU General Public License
43*e6d6c189SCody Peter Mello# along with this program; if not, write to the Free Software
44*e6d6c189SCody Peter Mello# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
45*e6d6c189SCody Peter Mello# bash$ gdb gawk
46*e6d6c189SCody Peter Mello# GDB is free software and you are welcome to distribute copies of it
47*e6d6c189SCody Peter Mello#  under certain conditions; type "show copying" to see the conditions.
48*e6d6c189SCody Peter Mello# There is absolutely no warranty for GDB; type "show warranty" for details.
49*e6d6c189SCody Peter Mello# GDB 4.13 (i386-unknown-freebsd),
50*e6d6c189SCody Peter Mello# Copyright 1994 Free Software Foundation, Inc...
51*e6d6c189SCody Peter Mello# (gdb) shell echo 000800 >/tmp/seq
52*e6d6c189SCody Peter Mello# (gdb) r '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }(gdb) r '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }' /tmp/seq
53*e6d6c189SCody Peter Mello# Starting program: /scratch/archive/src/cmd/gnuawk-3.0.2/gawk '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }' /tmp/seq
54*e6d6c189SCody Peter Mello#
55*e6d6c189SCody Peter Mello# Program received signal SIGBUS, Bus error.
56*e6d6c189SCody Peter Mello# 0xd86f in def_parse_field (up_to=1, buf=0x37704, len=6, fs=0x3b240, rp=0x0,
57*e6d6c189SCody Peter Mello#     set=0xce6c <set_field>, n=0x0) at field.c:391
58*e6d6c189SCody Peter Mello# 391		sav = *end;
59*e6d6c189SCody Peter Mello# (gdb) bt
60*e6d6c189SCody Peter Mello# #0  0xd86f in def_parse_field (up_to=1, buf=0x37704, len=6, fs=0x3b240,
61*e6d6c189SCody Peter Mello#     rp=0x0, set=0xce6c <set_field>, n=0x0) at field.c:391
62*e6d6c189SCody Peter Mello# #1  0xddb1 in get_field (requested=1, assign=0x0) at field.c:669
63*e6d6c189SCody Peter Mello# #2  0xc25d in r_get_lhs (ptr=0x3b9b4, assign=0x0) at eval.c:1339
64*e6d6c189SCody Peter Mello# #3  0x9ab0 in r_tree_eval (tree=0x3b9b4, iscond=0) at eval.c:604
65*e6d6c189SCody Peter Mello# #4  0xa5f1 in r_tree_eval (tree=0x3b9fc, iscond=0) at eval.c:745
66*e6d6c189SCody Peter Mello# #5  0x4661 in format_tree (fmt_string=0x3e040 "%06d", n0=0, carg=0x3ba20)
67*e6d6c189SCody Peter Mello#     at builtin.c:620
68*e6d6c189SCody Peter Mello# #6  0x5beb in do_sprintf (tree=0x3b96c) at builtin.c:809
69*e6d6c189SCody Peter Mello# #7  0x5cd5 in do_printf (tree=0x3ba8c) at builtin.c:844
70*e6d6c189SCody Peter Mello# #8  0x9271 in interpret (tree=0x3ba8c) at eval.c:465
71*e6d6c189SCody Peter Mello# #9  0x8ca3 in interpret (tree=0x3bbd0) at eval.c:308
72*e6d6c189SCody Peter Mello# #10 0x8c34 in interpret (tree=0x3bc18) at eval.c:292
73*e6d6c189SCody Peter Mello# #11 0xf069 in do_input () at io.c:312
74*e6d6c189SCody Peter Mello# #12 0x12ba9 in main (argc=3, argv=0xefbfd538) at main.c:393
75*e6d6c189SCody Peter Mello# (gdb) l
76*e6d6c189SCody Peter Mello# 386			*buf += len;
77*e6d6c189SCody Peter Mello# 387			return nf;
78*e6d6c189SCody Peter Mello# 388		}
79*e6d6c189SCody Peter Mello# 389
80*e6d6c189SCody Peter Mello# 390		/* before doing anything save the char at *end */
81*e6d6c189SCody Peter Mello# 391		sav = *end;
82*e6d6c189SCody Peter Mello# 392		/* because it will be destroyed now: */
83*e6d6c189SCody Peter Mello# 393
84*e6d6c189SCody Peter Mello# 394		*end = ' ';	/* sentinel character */
85*e6d6c189SCody Peter Mello# 395		for (; nf < up_to; scan++) {
86*e6d6c189SCody Peter Mello# (gdb) print end
87*e6d6c189SCody Peter Mello# $1 = 0x804d006 <Error reading address 0x804d006: No such file or directory>
88*e6d6c189SCody Peter Mello# (gdb) print buf
89*e6d6c189SCody Peter Mello# $2 = (char **) 0x37704
90*e6d6c189SCody Peter Mello# (gdb) print *buf
91*e6d6c189SCody Peter Mello# $3 = 0x804d000 <Error reading address 0x804d000: No such file or directory>
92*e6d6c189SCody Peter Mello# (gdb) q
93*e6d6c189SCody Peter Mello# The program is running.  Quit anyway (and kill it)? (y or n) y
94*e6d6c189SCody Peter Mello# bash$ exit
95*e6d6c189SCody Peter Mello#
96*e6d6c189SCody Peter Mello# Script done on Mon Jan 20 15:11:07 1997
97*e6d6c189SCody Peter Mello#
98*e6d6c189SCody Peter Mello# Dave Bodenstab
99*e6d6c189SCody Peter Mello# imdave@synet.net
100