Project

General

Profile

Actions

Bug #6058

closed

Stack overflow in SEGV Handler

Added by authorNari (Narihiro Nakamura) about 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-02-22 trunk 34726) [x86_64-linux]
Backport:
[ruby-dev:45272]

Description

nariです。

以下のようにたまにSEGVのテストで落ちることがありまして、

http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20120221T130301Z.log.html.gz

原因を調査したところ、SIGSEGVハンドラの中でスタックオーバフローしている
ようでした。

uname -orv

2.6.18-274.el5 #1 SMP Fri Jul 22 04:43:29 EDT 2011 GNU/Linux

cat /etc/redhat-release

CentOS release 5.7 (Final)

./miniruby -v

ruby 2.0.0dev (2012-02-22 trunk 34726) [x86_64-linux]

64bit環境のCentOSだと100%再現しました。
./configureの指定はchkbuildと同じにしています。

gdb ./miniruby

(gdb) r -e 'Process.kill :SIGSEGV, $$'
Starting program: /root/ruby/ruby-trunk-svn/miniruby -e 'Process.kill :SIGSEGV, $$'
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x2aaaaaaab000
[Thread debugging using libthread_db enabled]
[New Thread 0x40003940 (LWP 5662)]

Program received signal SIGSEGV, Segmentation fault.
0x000000329b6306f7 in kill () from /lib64/libc.so.6
(gdb) c
Continuing.
-e:1: [BUG] Segmentation fault
ruby 2.0.0dev (2012-02-22 trunk 34726) [x86_64-linux]

-- Control frame information -----------------------------------------------

Program received signal SIGSEGV, Segmentation fault.
0x00002aaaae08d040 in ?? ()
(gdb) up
#1 0x00000000004e6304 in st_lookup (table=0x7f7a90, key=8368, value=0x7fa0e8) at st.c:399
399 hash_val = do_hash(key, table);
(gdb) p table
$1 = (st_table *) 0x7f7a90
(gdb) p *table
$2 = {type = 0x2aaaae18cf08, num_bins = 217355419913, entries_packed = 0, num_entries = 1664379390147606789, bins = 0x2820766564302e30, head = 0x2d32302d32313032,
tail = 0x6b6e757274203232}
(gdb) up
#2 0x0000000000490077 in rb_id2str (id=8368) at parse.y:10612
10612 if (st_lookup(global_symbols.id_str, id, &data)) {
(gdb) p global_symbols.id_str
$3 = (st_table *) 0x7f7a90

gdbで調べると、global_symbols.id_strが指すメモリ領域がどこかで破壊され
ているようでした。

(gdb) (gdb) watch (((st_table *) 0x7f7a90)->type == 0x7d61f0)
Hardware watchpoint 2: (((st_table *) 0x7f7a90)->type == 0x7d61f0)
(gdb) r
...
Old value = 1
New value = 0
0x000000329b642841 in vfprintf () from /lib64/libc.so.6
(gdb) info frame
Stack level 0, Stack frame at 0x7f7aa0:
rip = 0x329b642841 in vfprintf; saved rip 0x329b648086
called by frame at 0x7f9bf0
Arglist at 0x7f7a90, args:
Locals at 0x7f7a90, Previous frame's sp is 0x7f7aa0
Saved registers:
rbp at 0x7f7a90, rip at 0x7f7a98

対象のメモリ領域が破壊された点を探すと、vfprintf()に行き当たって、スタッ
クフレームの情報を見るとLocalsのアドレスがglobal_symbols.id_strのアドレ
スと同じになっていることがわかりました。

ので、たぶんスタックがオーバフローしているのではないかと思います。
あまり詳しくないのでとりあえずバグ報告しておきます。


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #7141: ALT_STACK_SIZE is not enoughClosedkosaki (Motohiro KOSAKI)10/11/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0