[ruby-dev:24377] File.basename dumps core

From: Tanaka Akira <akr@...17n.org>
Date: 2004-09-30 10:00:30 UTC
List: ruby-dev #24377
次のようにすると core を吐きます。

% ./ruby -e '
fname = Object.new
ext = "x" * 0x1fff4
class << fname; self end.send(:define_method, :to_str) {
  ext.replace ""
  "a.txt"
}
File.basename(fname, ext)'
-e:8: [BUG] Segmentation fault
ruby 1.9.0 (2004-09-30) [i686-linux]

zsh: abort (core dumped)  ./ruby -e 
% gdb ruby core 
GNU gdb 6.1-debian
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 "i386-linux"...Using host libthread_db library "/lib/libthread_db.so.1".

Core was generated by `./ruby -e 
fname = Object.new
ext = "x" * 0x1fff4
class << fname; self end.send'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x4009e721 in kill () from /lib/libc.so.6
(gdb) bt
#0  0x4009e721 in kill () from /lib/libc.so.6
#1  0x4009e4c5 in raise () from /lib/libc.so.6
#2  0x4009f9e8 in abort () from /lib/libc.so.6
#3  0x080d1f86 in rb_bug (fmt=0x0) at error.c:214
#4  0x080aff92 in sigsegv (sig=11) at signal.c:446
#5  <signal handler called>
#6  0x400eac0f in strlen () from /lib/libc.so.6
#7  0x0806c632 in rmext (p=0x8139ed8 "a.txt", e=0x401d9008 <Address 0x401d9008 out of bounds>) at file.c:2623
#8  0x0806c7ba in rb_file_s_basename (argc=0, argv=0x0) at file.c:2677
#9  0x08069f6a in call_cfunc (func=0x806c6a0 <rb_file_s_basename>, recv=1075632796, len=0, argc=-1, argv=0xbffff138)
    at eval.c:5368
#10 0x0805e187 in rb_call0 (klass=1075632776, recv=1075632796, id=8265, oid=0, argc=2, argv=0xbffff138, body=0x401ccb88, 
    nosuper=0) at eval.c:5509
#11 0x0805e438 in rb_call (klass=1075632776, recv=1075632796, mid=8265, argc=2, argv=0xbffff138, scope=0) at eval.c:5730
#12 0x08059368 in rb_eval (self=1075673496, n=0x0) at ruby.h:635
#13 0x080558fb in ruby_exec () at eval.c:1458
#14 0x08055940 in ruby_run () at eval.c:1484
#15 0x08053a05 in main (argc=0, argv=0x0, envp=0xbffff904) at main.c:38
(gdb) 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next