[ruby-dev:28286] SEGV with zlib
From:
Tanaka Akira <akr@...17n.org>
Date:
2006-01-30 06:52:23 UTC
List:
ruby-dev #28286
最近、Data オブジェクトの free 関数が気になっているのですが、
とりあえず次のようにすると SEGV になるようです。
% cat tst.rb
require 'zlib'
class C
def write(str)
end
end
GC.stress = true
100.times {|i|
p i
o = C.new
100.times {
o = Zlib::GzipWriter.new(o)
}
o.write "a"
}
% ./ruby tst.rb
0
1
tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.
tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.
tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.
zsh: segmentation fault (core dumped) ./ruby tst.rb
% gdb ruby core
GNU gdb 6.4-debian
Copyright 2005 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 "i486-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
Core was generated by `./ruby tst.rb'.
Program terminated with signal 11, Segmentation fault.
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/libdl.so.2...done.
Loaded symbols for /lib/tls/libdl.so.2
Reading symbols from /lib/tls/libcrypt.so.1...done.
Loaded symbols for /lib/tls/libcrypt.so.1
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /home/akr/ruby/tmp-ruby/lib/ruby/1.9/i686-linux/zlib.so...done.
Loaded symbols for /home/akr/ruby/tmp-ruby/lib/ruby/1.9/i686-linux/zlib.so
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
#0 0xb7e4afce in free () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7e4afce in free () from /lib/tls/libc.so.6
#1 0xb7e4c8bc in malloc () from /lib/tls/libc.so.6
#2 0x08072e58 in ruby_xmalloc (size=3614891752) at gc.c:140
#3 0x080c3f6f in str_new (klass=<value optimized out>, ptr=0x49 <Address 0x49 out of bounds>, len=71) at string.c:83
#4 0x08078083 in rb_write_error2 (
mesg=0xbfc91f54 "tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.\nsed explicitly.\n\036$抃o餬\021", len=71) at io.c:3843
#5 0x080e3a91 in warn_print (fmt=<value optimized out>, args=<value optimized out>) at error.c:98
#6 0x080e3ada in rb_warn (fmt=0xb7f82378 "Zlib::GzipWriter object must be closed explicitly.") at error.c:112
#7 0xb7f7f57b in gzfile_writer_end (gz=0x99e0238) at zlib.c:2286
#8 0xb7f7eb76 in gzfile_free (gz=0x99e0238) at zlib.c:1755
#9 0x08072b92 in garbage_collect () at gc.c:1183
#10 0x08073158 in ruby_xrealloc (ptr=0x9aa48c8, size=2059) at gc.c:185
#11 0x080c4bf0 in rb_str_resize (str=3084712432, len=2058) at string.c:613
#12 0xb7f7cfb8 in zstream_expand_buffer (z=0xb26c6c8) at zlib.c:457
#13 0xb7f7d5a3 in zstream_run (z=0xb26c6c8, src=0x41668 <Address 0x41668 out of bounds>, len=3086059672, flush=0)
at zlib.c:729
#14 0xb7f7f1fa in gzfile_write (gz=0xb26c6c8, str=0x9aa48b8 "\037\213\b", len=10) at zlib.c:2107
#15 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712312) at zlib.c:2847
#16 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710392, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc973c0, body=0xb7dd0350, flags=8) at eval.c:5691
#17 0x08060ca0 in rb_call (klass=3084716112, recv=3084710392, mid=7409, argc=1, argv=0xbfc973c0, scope=CALLING_FCALL)
at eval.c:5864
#18 0x08061a10 in rb_funcall (recv=3084710392, mid=7409, n=1) at eval.c:5964
#19 0xb7f7ed4b in gzfile_write_raw (gz=0xb2ade28) at zlib.c:1823
#20 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712332) at zlib.c:2847
#21 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710372, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97610, body=0xb7dd0350, flags=8) at eval.c:5691
#22 0x08060ca0 in rb_call (klass=3084716112, recv=3084710372, mid=7409, argc=1, argv=0xbfc97610, scope=CALLING_FCALL)
at eval.c:5864
#23 0x08061a10 in rb_funcall (recv=3084710372, mid=7409, n=1) at eval.c:5964
#24 0xb7f7ed4b in gzfile_write_raw (gz=0xb2ef588) at zlib.c:1823
#25 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084720452) at zlib.c:2847
#26 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710352, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97860, body=0xb7dd0350, flags=8) at eval.c:5691
#27 0x08060ca0 in rb_call (klass=3084716112, recv=3084710352, mid=7409, argc=1, argv=0xbfc97860, scope=CALLING_FCALL)
at eval.c:5864
#28 0x08061a10 in rb_funcall (recv=3084710352, mid=7409, n=1) at eval.c:5964
#29 0xb7f7ed4b in gzfile_write_raw (gz=0xb330ce8) at zlib.c:1823
#30 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084720492) at zlib.c:2847
---Type <return> to continue, or q <return> to quit---
#31 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710332, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97ab0, body=0xb7dd0350, flags=8) at eval.c:5691
#32 0x08060ca0 in rb_call (klass=3084716112, recv=3084710332, mid=7409, argc=1, argv=0xbfc97ab0, scope=CALLING_FCALL)
at eval.c:5864
#33 0x08061a10 in rb_funcall (recv=3084710332, mid=7409, n=1) at eval.c:5964
#34 0xb7f7ed4b in gzfile_write_raw (gz=0xb372448) at zlib.c:1823
#35 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712372) at zlib.c:2847
#36 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710312, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97d00, body=0xb7dd0350, flags=8) at eval.c:5691
#37 0x08060ca0 in rb_call (klass=3084716112, recv=3084710312, mid=7409, argc=1, argv=0xbfc97d00, scope=CALLING_FCALL)
at eval.c:5864
#38 0x08061a10 in rb_funcall (recv=3084710312, mid=7409, n=1) at eval.c:5964
#39 0xb7f7ed4b in gzfile_write_raw (gz=0xb3b3ba8) at zlib.c:1823
#40 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712392) at zlib.c:2847
#41 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710292, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97f50, body=0xb7dd0350, flags=8) at eval.c:5691
#42 0x08060ca0 in rb_call (klass=3084716112, recv=3084710292, mid=7409, argc=1, argv=0xbfc97f50, scope=CALLING_FCALL)
at eval.c:5864
#43 0x08061a10 in rb_funcall (recv=3084710292, mid=7409, n=1) at eval.c:5964
#44 0xb7f7ed4b in gzfile_write_raw (gz=0xb3f5308) at zlib.c:1823
#45 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084720412) at zlib.c:2847
#46 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710272, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc981a0, body=0xb7dd0350, flags=8) at eval.c:5691
#47 0x08060ca0 in rb_call (klass=3084716112, recv=3084710272, mid=7409, argc=1, argv=0xbfc981a0, scope=CALLING_FCALL)
at eval.c:5864
#48 0x08061a10 in rb_funcall (recv=3084710272, mid=7409, n=1) at eval.c:5964
#49 0xb7f7ed4b in gzfile_write_raw (gz=0xb436a68) at zlib.c:1823
#50 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712252) at zlib.c:2847
#51 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710252, id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc983f0, body=0xb7dd0350, flags=0) at eval.c:5691
#52 0x08060ca0 in rb_call (klass=3084716112, recv=3084710252, mid=7409, argc=1, argv=0xbfc983f0, scope=CALLING_NORMAL)
at eval.c:5864
#53 0x0805ed62 in rb_eval (self=3084786192, n=<value optimized out>) at eval.c:3310
#54 0x08063938 in rb_yield_0 (val=3, self=3084786192, klass=<value optimized out>, flags=0, avalue=0) at eval.c:4869
#55 0x08064a16 in rb_yield (val=267881) at eval.c:4950
#56 0x0808374f in int_dotimes (num=201) at numeric.c:2757
#57 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=201, id=5561, oid=5561, argc=<value optimized out>, argv=0x0,
body=0xb7dde3ec, flags=0) at eval.c:5691
#58 0x08060ca0 in rb_call (klass=3084772532, recv=201, mid=5561, argc=0, argv=0x0, scope=CALLING_NORMAL) at eval.c:5864
#59 0x0805ed62 in rb_eval (self=3084786192, n=<value optimized out>) at eval.c:3310
---Type <return> to continue, or q <return> to quit---
#60 0x0805ff05 in rb_eval (self=3084786192, n=<value optimized out>) at eval.c:3034
#61 0x0806abb0 in ruby_exec_internal () at eval.c:1547
#62 0x0806abf4 in ruby_exec () at eval.c:1563
#63 0x0806ac1f in ruby_run () at eval.c:1579
#64 0x08054399 in main (argc=2, argv=0xbfc99084, envp=0xbfc99090) at main.c:43
(gdb)
--
[田中 哲][たなか あきら][Tanaka Akira]