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