SosMan的getline_test中的错误 [英] Bug in SosMan's getline_test

查看:53
本文介绍了SosMan的getline_test中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信我在Sosman博士的getline_test计划中发现了一个错误,

是官方新闻组程序之一。调试信息

如下:


$ gdb ./getline_test

GNU gdb 6.3

Copyright 2004自由软件基金会,公司

GDB是免费软件,受GNU通用公共许可证保护,欢迎您来b / b
欢迎更改和/或分发它的副本某些条件。

键入show copying查看条件。

GDB绝对没有保修。输入show warranty有关详细信息。

此GDB配置为i586-suse-linux...使用主机libthread_db库

" /lib/tls/libthread_db.so。 1。


(gdb)r

启动程序:/ tmp / getline_test


程序接收信号SIGSEGV ,分段错误。

来自/lib/tls/libc.so.6的getdelim()中的0x4008febf

(gdb)bt

#0来自/lib/tls/libc.so.6的getdelim()中的0x4008febf
来自/lib/tls/libc.so.6的getline()中的
#1 0x4008d844

#2 0x080486b2验证(文件= 0x804a008,st = 0xbfffee70,特殊= 0)

getline_test.c:44

#3 0x0804891d在main()at getline_test。 c:103

(gdb)f 2

#2 0x080486b2验证(文件= 0x804a008,st = 0xbfffee70,特殊= 0)

getline_test.c:44

44 buff = getline(文件);

(gdb)p *文件

$ 1 = {_flags = - 72539008,

_IO_read_ptr = 0x40018000''n''<重复25次&g t;," \ n",''d''<重复174次> ...,

_IO_read_end = 0x40018000''n''<重复25次>," \ n",''d''<重复174次> ...,

_IO_read_base = 0x40018000''n''<重复25次>," \ n", ''d''<重复174次> ...,

_IO_write_base = 0x40018000''n''<重复25次>," \ n",''d'' <重复174次> ...,

_IO_write_ptr = 0x40018000''n''<重复25次>," \ n",''d''<重复174次> ; ...,

_IO_write_end = 0x40018000''n''<重复25次>," \ n",''d''<重复174次> ...,

_IO_buf_base = 0x40018000''n''<重复25次>,\ n,d重复174次> ...,

_IO_buf_end = 0x40019000''b''<重复200次> ; ...,

_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''<重复51次>}

(gdb)


在我看来文件的_flags字段已经损坏了 - 它

似乎有一个奇数值。

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.

推荐答案

gdb ./getline_test

GNU gdb 6.3

版权所有2004 Free Software Foundation,Inc。

GDB是免费软件,受GNU通用公共许可证保护,你是

欢迎在某些条件下更改和/或分发它的副本。

键入show copying查看条件。

GDB绝对没有保修。输入show warranty有关详细信息。

此GDB配置为i586-suse-linux...使用主机libthread_db库

" /lib/tls/libthread_db.so。 1。


(gdb)r

启动程序:/ tmp / getline_test


程序接收信号SIGSEGV ,分段错误。

来自/lib/tls/libc.so.6的getdelim()中的0x4008febf

(gdb)bt

#0来自/lib/tls/libc.so.6的getdelim()中的0x4008febf
来自/lib/tls/libc.so.6的getline()中的
#1 0x4008d844

#2 0x080486b2验证(文件= 0x804a008,st = 0xbfffee70,特殊= 0)

getline_test.c:44

#3 0x0804891d在main()at getline_test。 c:103

(gdb)f 2

#2 0x080486b2验证(文件= 0x804a008,st = 0xbfffee70,特殊= 0)

getline_test.c:44

44 buff = getline(文件);

(gdb)p * file
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'' <重复25次>," \ n",''d''<重复174次> ...,

_IO_read_end = 0x40018000''n''<重复25次> ;," \ n",''d''<重复174次> ...,

_IO_read_base = 0x40018000''n''<重复25次>," \\ \\ n",''d''<重复174次> ...,

_IO_write_base = 0x40018000''n''<重复25次>," \ n",' 'd''<重复174次> ...,

_IO_write_ptr = 0x40018000''n''<重复25次>," \ n",''d''< ;重复174次> ...,

_IO_write_end = 0x40018000''n''<重复25次>," \ n",''d''<重复174次> ...,

_IO_buf_base = 0x40018000''n''<重复25次>,\ n,''d''<重复174次> ...,

_IO_buf_end = 0x40019000''b''& LT;重复200次> ...,

_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''<重复51次>}

(gdb)


在我看来文件的_flags字段已经变成了已损坏 - 它

似乎有一个奇怪的价值。

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.


Friar Tuck< no **** @ invalid.comwrites :
Friar Tuck <no****@invalid.comwrites:

我相信我在Sosman博士的getline_test程序中发现了一个错误,

是官方新闻组程序之一。
I believe I have found a bug in Dr Sosman''s getline_test program, which
is one of the official newsgroup programs.



没有官方新闻组程序这样的东西,

至少不在comp.lang.c


(gdb)bt

#0 0x4008febf in getdelim()from /lib/tls/libc.so.6
$ b $来自/lib/tls/libc.so.6的getline()中的b#1 0x4008d844

#2 0x080486b2验证(文件= 0x804a008,st = 0xbfffee70,特殊= 0)

getline_test.c:44

#3 0x0804891d in main()at getline_test.c:103

(gdb)f 2

#2 0x080486b2验证(文件= 0x804a008,st = 0xbfffee70,特殊= 0)

getline_test.c:44

44 buff = getline(file);
(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);



Eric似乎不太可能将他的代码写入

来调用getline。 GNU C库中的函数,这个回溯显示的是
。我认为你没有编译

并正确链接测试程序。


GNU lib''c getline和Eric'的getline显然有不同<从上面的源代码行判断,接口是
接口。

-

如果我告诉过你一次,我就是' ve告诉你LLONG_MAX次不要夸大。

- 杰克克莱恩

It seems very unlikely that Eric would have written his code to
call into the "getline" function in the GNU C library, which is
what this backtrace is showing. I think that you did not compile
and link the test program correctly.

GNU lib''c getline and Eric''s getline evidently have different
interfaces, judging from the line of source code above.
--
"If I''ve told you once, I''ve told you LLONG_MAX times not to
exaggerate."
--Jack Klein


这篇关于SosMan的getline_test中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆