Mailinglist Archive: opensuse-security (32 mails)

< Previous Next >
Puzzled with gawk
  • From: Pablo <pablocosta@xxxxxxxx>
  • Date: Wed, 28 Jun 2006 13:43:23 +0200
  • Message-id: <02E7E3AE-3437-49D3-B259-85E79EA7989F@xxxxxxxx>
Hello there,

I've just found a rather weird problem on my opensuse10.1 box.

I've produced a simple awk script and a sample input file which makes
gawk crash on my 10.1, while it works as expected on my gentoo. I got
also what I would expect on non-gnu awk running under Mac OS X.

I would really appreciate if someone ran my script under 10.1 and tried
to reproduce the error. It's a one minute task: I've arranged everything
below so you can run it on your ~/tmp with a single copy/paste, if you
feel like giving it a try.

Maybe I'm not seeing the obvious, I would expect a broken awk build to
cause lots of trouble on my system, but this sample script is quite tricky.
So I would appreciate if someone confirms the odd behaviour or has
any clue before I go on with further testing.


$ uname -a
Linux 2.6.16.13-4-smp #1 SMP Wed May 3 04:53:23 UTC 2006 i686 i686 i386 GNU/Linux
$ rpm -qa | grep awk
gawk-3.1.5-18
$ gawk --version | head -n 1
GNU Awk 3.1.5


Thank you for getting so far, and thank you very much if you choose to go on ;)
Kind regards.
Pablo


-8<-------------cut here---------------------
#skip this if your CWD is a better place for two temp files ;)
cd ~/tmp


# the script; PLEASE take care if you copy on your own file
# to remove the BACKSLASH just before the DOLLAR; It's
# there to prevent the shell from evaluating $i when copy/pasting.
cat > problem.awk <<-EOF
{
print "RECORD " NR;
for ( i = 0; length( \$i ) > 0; i++ ) print " FIELD " i " of " NF;
}
EOF

# It doesn't seem to really matter what kind of input you
# give to the script. Also it doesn't matter if it's given
# on a file via gawk command line invocation or if it's fed
# via stdin through a pipe.
cat > awk_example <<EOF
drwxr-xr-x 2 pablo users 112 2006-06-20 19:29 .
drwxr-xr-x 3 pablo users 248 2006-06-20 19:26 ..
-rw-r--r-- 1 pablo users 0 2006-06-20 19:43 awk_example
-rw-r--r-- 1 pablo users 91 2006-06-20 19:37 problem.awk
drwxr-xr-x 2 pablo users 112 2006-06-20 19:29 .
drwxr-xr-x 3 pablo users 248 2006-06-20 19:26 ..
-rw-r--r-- 1 pablo users 0 2006-06-20 19:43 awk_example
-rw-r--r-- 1 pablo users 91 2006-06-20 19:37 problem.awk
EOF

# Unleash hell!
gawk -f problem.awk awk_example

-8<-------------cut here---------------------

This is the expected output (what I get on my Gentoo's gawk and on my Mac OS X's awk):

$ gawk -f problem.awk awk_example
RECORD 1
FIELD 0 of 8
FIELD 1 of 8
FIELD 2 of 8
FIELD 3 of 8
FIELD 4 of 8
FIELD 5 of 8
FIELD 6 of 8
FIELD 7 of 8
FIELD 8 of 8
[... records 2 to 7 ...]
RECORD 8
FIELD 0 of 8
FIELD 1 of 8
FIELD 2 of 8
FIELD 3 of 8
FIELD 4 of 8
FIELD 5 of 8
FIELD 6 of 8
FIELD 7 of 8
FIELD 8 of 8

This is what I get on my opensuse10.1:

$ gawk -f problem.awk awk_example
RECORD 1
FIELD 0 of 8
FIELD 1 of 8
FIELD 2 of 8
FIELD 3 of 8
FIELD 4 of 8
FIELD 5 of 8
FIELD 6 of 8
FIELD 7 of 8
FIELD 8 of 8
RECORD 2
FIELD 0 of 8
FIELD 1 of 8
FIELD 2 of 8
*** glibc detected *** gawk: double free or corruption (fasttop): 0x08089be0 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7e80911]
/lib/libc.so.6(__libc_free+0x84)[0xb7e81f84]
gawk(str2wstr+0x37)[0x806f2dd]
gawk(do_length+0x1f3)[0x8056c73]
gawk(r_tree_eval+0x3a2)[0x80742f2]
gawk(r_tree_eval+0x75)[0x8073fc5]
gawk[0x8075d12]
gawk(interpret+0x2c6)[0x80727e6]
gawk(interpret+0x221)[0x8072741]
gawk(interpret+0x1b1)[0x80726d1]
gawk(do_input+0x33)[0x806a743]
gawk(main+0x79b)[0x806e33b]
/lib/libc.so.6(__libc_start_main+0xdc)[0xb7e3287c]
gawk[0x804c9b1]
======= Memory map: ========
08048000-08082000 r-xp 00000000 03:01 431340 /bin/gawk
08082000-08083000 rw-p 0003a000 03:01 431340 /bin/gawk
08083000-080a9000 rw-p 08083000 00:00 0 [heap]
b7b00000-b7b21000 rw-p b7b00000 00:00 0
b7b21000-b7c00000 ---p b7b21000 00:00 0
b7d12000-b7de9000 r--p 00000000 03:01 441088 /usr/lib/locale/ en_US.utf8/LC_COLLATE
b7de9000-b7e1c000 r--p 00000000 03:01 441087 /usr/lib/locale/ en_US.utf8/LC_CTYPE
b7e1c000-b7e1d000 rw-p b7e1c000 00:00 0
b7e1d000-b7f36000 r-xp 00000000 03:01 473445 /lib/libc-2.4.so
b7f36000-b7f38000 r--p 00118000 03:01 473445 /lib/libc-2.4.so
b7f38000-b7f3a000 rw-p 0011a000 03:01 473445 /lib/libc-2.4.so
b7f3a000-b7f3d000 rw-p b7f3a000 00:00 0
b7f3d000-b7f60000 r-xp 00000000 03:01 473453 /lib/libm-2.4.so
b7f60000-b7f62000 rw-p 00022000 03:01 473453 /lib/libm-2.4.so
b7f62000-b7f64000 r-xp 00000000 03:01 473451 /lib/libdl-2.4.so
b7f64000-b7f66000 rw-p 00001000 03:01 473451 /lib/libdl-2.4.so
b7f6b000-b7f75000 r-xp 00000000 03:01 473492 /lib/libgcc_s.so.1
b7f75000-b7f76000 rw-p 00009000 03:01 473492 /lib/libgcc_s.so.1
b7f76000-b7f77000 rw-p b7f76000 00:00 0
b7f77000-b7f78000 r--p 00000000 03:01 441084 /usr/lib/locale/ en_US.utf8/LC_NUMERIC
b7f78000-b7f79000 r--p 00000000 03:01 429431 /usr/lib/locale/ en_US.utf8/LC_TIME
b7f79000-b7f7a000 r--p 00000000 03:01 431263 /usr/lib/locale/ en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES
b7f7a000-b7f81000 r--s 00000000 03:01 428430 /usr/lib/gconv/ gconv-modules.cache
b7f81000-b7f82000 rw-p b7f81000 00:00 0
b7f82000-b7f9c000 r-xp 00000000 03:01 479433 /lib/ld-2.4.so
b7f9c000-b7f9e000 rw-p 00019000 03:01 479433 /lib/ld-2.4.so
bf868000-bf87d000 rw-p bf868000 00:00 0 [stack]
ffffe000-fffff000 ---p 00000000 00:00 0 [vdso]
Aborted




< Previous Next >
This Thread
Follow Ups