Bug in SosMan's getline_test



I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs. Debugging information
follows.

$ gdb ./getline_test
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...Using host libthread_db library
"/lib/tls/libthread_db.so.1".

(gdb) r
Starting program: /tmp/getline_test

Program received signal SIGSEGV, Segmentation fault.
0x4008febf in getdelim () from /lib/tls/libc.so.6
(gdb) bt
#0 0x4008febf in getdelim () from /lib/tls/libc.so.6
#1 0x4008d844 in getline () from /lib/tls/libc.so.6
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
#3 0x0804891d in main () at getline_test.c:103
(gdb) f 2
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
44 buff = getline(file);
(gdb) p *file
$1 = {_flags = -72539008,
_IO_read_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_read_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_read_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_write_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_write_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_write_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_buf_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_buf_end = 0x40019000 'b' <repeats 200 times>...,
_IO_save_base = 0x0,
_IO_backup_base = 0x0, _IO_save_end = 0x0, _markers = 0x0,
_chain = 0x40151460,
_fileno = 6, _flags2 = 0, _old_offset = 0, _cur_column = 0,
_vtable_offset = 0 '\0',
_shortbuf = "", _lock = 0x804a0a0, _offset = 0, __pad1 =
0x0, __pad2 = 0x804a0ac,
_mode = -1, _unused2 = '\0' <repeats 51 times>}
(gdb)

It looks to me like the _flags field of file has become corrupted - it
seems to have an odd value.

.



Relevant Pages

  • Re: Fedora 9
    ... GNU gdb Fedora ... This is free software: you are free to change and redistribute it. ... There is NO WARRANTY, to the extent permitted by law. ... Program received signal SIGSEGV, Segmentation fault. ...
    (Fedora)
  • Re: Fedora 9
    ... GNU gdb Fedora ... This is free software: you are free to change and redistribute it. ... There is NO WARRANTY, to the extent permitted by law. ... Program received signal SIGSEGV, Segmentation fault. ...
    (Fedora)
  • Re: Fedora 9
    ... GNU gdb Fedora ... This is free software: you are free to change and redistribute it. ... There is NO WARRANTY, to the extent permitted by law. ... Program received signal SIGSEGV, Segmentation fault. ...
    (Fedora)
  • Stability issues / UFS based panic on recent CURRENT (03/22)
    ... Copyright 2004 Free Software Foundation, ... GDB is free software, covered by the GNU General Public License, and you are ... There is absolutely no warranty for GDB. ... #0 doadump at pcpu.h:246 ...
    (freebsd-current)
  • 2 core dumps
    ... GNU gdb 6.1.1 ... Copyright 2004 Free Software Foundation, ... There is absolutely no warranty for GDB. ... #0 doadump at pcpu.h:195 ...
    (freebsd-current)