Issue #5894 has been reported by Hideki Miura.
Bug #5894: ISeq#compile with line no 0
Author: Hideki Miura
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0dev (2012-01-13 trunk 34295) [x86_64-linux]
三浦英樹と申します
以下のようにISeq.compile、ISeq#to_aを以下のように呼びだすと、セグメンテーションフォルトが発生します。
行番号(第4引数)を正数にするとこの現象は発生しないようです。
Rubyのバージョン
$ ruby -v
ruby 2.0.0dev (2012-01-13 trunk 34295) [x86_64-linux]
テストプログラム
$ cat tt.rb
p RubyVM::InstructionSequence.compile(“1”, “mac”, “”, 0).to_a
実行結果
$ ruby tt.rb
tt.rb:1: [BUG] Segmentation fault
ruby 2.0.0dev (2012-01-13 trunk 34295) [x86_64-linux]
– Control frame information
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :to_a
c:0003 p:0032 s:0007 b:0006 l:001a58 d:000468 EVAL tt.rb:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001a58 d:001a58 TOP
– Ruby level backtrace information
tt.rb:1:in <main>' tt.rb:1:in
to_a’
– C level backtrace information
ruby [0x53a152]
ruby [0x584086]
ruby(rb_bug+0xb8) [0x584208]
ruby [0x4c4547]
/lib/libpthread.so.0 [0x7f24a7039080]
ruby [0x51f3ff]
ruby [0x52768b]
ruby [0x5298d9]
ruby [0x52e62a]
ruby(rb_iseq_eval_main+0x27d) [0x52e99d]
ruby [0x4190cb]
ruby(ruby_run_node+0x36) [0x41b7a6]
ruby [0x41834f]
/lib/libc.so.6(__libc_start_main+0xe6) [0x7f24a640d5a6]
ruby [0x418239]
– Other runtime information
-
Loaded script: tt.rb
-
Loaded features:
0 enumerator.so
1 /usr/local/lib/ruby/2.0.0/x86_64-linux/enc/encdb.so
2 /usr/local/lib/ruby/2.0.0/x86_64-linux/enc/trans/transdb.so
3 /usr/local/lib/ruby/2.0.0/rubygems/defaults.rb
4 /usr/local/lib/ruby/2.0.0/x86_64-linux/rbconfig.rb
5 /usr/local/lib/ruby/2.0.0/rubygems/deprecate.rb
6 /usr/local/lib/ruby/2.0.0/rubygems/exceptions.rb
7 /usr/local/lib/ruby/2.0.0/rubygems/custom_require.rb
8 /usr/local/lib/ruby/2.0.0/rubygems.rb -
Process memory map:
00400000-00627000 r-xp 00000000 08:01 286235
/usr/local/bin/ruby
00827000-0082b000 r–p 00227000 08:01 286235
/usr/local/bin/ruby
0082b000-0082d000 rw-p 0022b000 08:01 286235
/usr/local/bin/ruby
0082d000-00849000 rw-p 0082d000 00:00 0
0213b000-023b8000 rw-p 0213b000 00:00 0
[heap]
7f24a5dd0000-7f24a5de6000 r-xp 00000000 08:01 16413
/lib/libgcc_s.so.1
7f24a5de6000-7f24a5fe6000 —p 00016000 08:01 16413
/lib/libgcc_s.so.1
7f24a5fe6000-7f24a5fe7000 r–p 00016000 08:01 16413
/lib/libgcc_s.so.1
7f24a5fe7000-7f24a5fe8000 rw-p 00017000 08:01 16413
/lib/libgcc_s.so.1
7f24a5fe8000-7f24a5fea000 r-xp 00000000 08:01 332317
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/trans/transdb.so
7f24a5fea000-7f24a61ea000 —p 00002000 08:01 332317
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/trans/transdb.so
7f24a61ea000-7f24a61eb000 r–p 00002000 08:01 332317
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/trans/transdb.so
7f24a61eb000-7f24a61ec000 rw-p 00003000 08:01 332317
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/trans/transdb.so
7f24a61ec000-7f24a61ee000 r-xp 00000000 08:01 332301
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/encdb.so
7f24a61ee000-7f24a63ed000 —p 00002000 08:01 332301
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/encdb.so
7f24a63ed000-7f24a63ee000 r–p 00001000 08:01 332301
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/encdb.so
7f24a63ee000-7f24a63ef000 rw-p 00002000 08:01 332301
/usr/local/lib/ruby/2.0.0/x86_64-linux/enc/encdb.so
7f24a63ef000-7f24a6557000 r-xp 00000000 08:01 16825
/lib/libc-2.9.so
7f24a6557000-7f24a6757000 —p 00168000 08:01 16825
/lib/libc-2.9.so
7f24a6757000-7f24a675b000 r–p 00168000 08:01 16825
/lib/libc-2.9.so
7f24a675b000-7f24a675c000 rw-p 0016c000 08:01 16825
/lib/libc-2.9.so
7f24a675c000-7f24a6761000 rw-p 7f24a675c000 00:00 0
7f24a6761000-7f24a67e5000 r-xp 00000000 08:01 17568
/lib/libm-2.9.so
7f24a67e5000-7f24a69e4000 —p 00084000 08:01 17568
/lib/libm-2.9.so
7f24a69e4000-7f24a69e5000 r–p 00083000 08:01 17568
/lib/libm-2.9.so
7f24a69e5000-7f24a69e6000 rw-p 00084000 08:01 17568
/lib/libm-2.9.so
7f24a69e6000-7f24a69ef000 r-xp 00000000 08:01 17563
/lib/libcrypt-2.9.so
7f24a69ef000-7f24a6bee000 —p 00009000 08:01 17563
/lib/libcrypt-2.9.so
7f24a6bee000-7f24a6bef000 r–p 00008000 08:01 17563
/lib/libcrypt-2.9.so
7f24a6bef000-7f24a6bf0000 rw-p 00009000 08:01 17563
/lib/libcrypt-2.9.so
7f24a6bf0000-7f24a6c1e000 rw-p 7f24a6bf0000 00:00 0
7f24a6c1e000-7f24a6c20000 r-xp 00000000 08:01 17565
/lib/libdl-2.9.so
7f24a6c20000-7f24a6e20000 —p 00002000 08:01 17565
/lib/libdl-2.9.so
7f24a6e20000-7f24a6e21000 r–p 00002000 08:01 17565
/lib/libdl-2.9.so
7f24a6e21000-7f24a6e22000 rw-p 00003000 08:01 17565
/lib/libdl-2.9.so
7f24a6e22000-7f24a6e29000 r-xp 00000000 08:01 17627
/lib/librt-2.9.so
7f24a6e29000-7f24a7028000 —p 00007000 08:01 17627
/lib/librt-2.9.so
7f24a7028000-7f24a7029000 r–p 00006000 08:01 17627
/lib/librt-2.9.so
7f24a7029000-7f24a702a000 rw-p 00007000 08:01 17627
/lib/librt-2.9.so
7f24a702a000-7f24a7041000 r-xp 00000000 08:01 17625
/lib/libpthread-2.9.so
7f24a7041000-7f24a7240000 —p 00017000 08:01 17625
/lib/libpthread-2.9.so
7f24a7240000-7f24a7241000 r–p 00016000 08:01 17625
/lib/libpthread-2.9.so
7f24a7241000-7f24a7242000 rw-p 00017000 08:01 17625
/lib/libpthread-2.9.so
7f24a7242000-7f24a7246000 rw-p 7f24a7242000 00:00 0
7f24a7246000-7f24a7266000 r-xp 00000000 08:01 16493
/lib/ld-2.9.so
7f24a72cf000-7f24a73d0000 rw-p 7f24a72cf000 00:00 0
7f24a73d0000-7f24a7451000 r–p 00000000 08:01 214202
/usr/lib/locale/ja_JP.utf8/LC_CTYPE
7f24a7451000-7f24a7455000 rw-p 7f24a7451000 00:00 0
7f24a7456000-7f24a7457000 rw-p 7f24a7456000 00:00 0
7f24a7457000-7f24a7458000 —p 7f24a7457000 00:00 0
7f24a7458000-7f24a745b000 rw-p 7f24a7458000 00:00 0
7f24a745b000-7f24a7462000 r–s 00000000 08:01 204520
/usr/lib/gconv/gconv-modules.cache
7f24a7462000-7f24a7465000 rw-p 7f24a7462000 00:00 0
7f24a7465000-7f24a7466000 r–p 0001f000 08:01 16493
/lib/ld-2.9.so
7f24a7466000-7f24a7467000 rw-p 00020000 08:01 16493
/lib/ld-2.9.so
7ffff24d4000-7ffff24e9000 rw-p 7ffffffea000 00:00 0
[stack]
7ffff2524000-7ffff2525000 r-xp 7ffff2524000 00:00 0
[vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
[vsyscall]
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension
libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Aborted
デバッガで実行した場合
$ gdb ruby
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show
copying”
and “show warranty” for details.
This GDB was configured as “x86_64-linux-gnu”…
(gdb) r tt.rb
Starting program: /usr/local/bin/ruby tt.rb
[Thread debugging using libthread_db enabled]
[New Thread 0x7f3ccca806f0 (LWP 3711)]
[New Thread 0x7f3ccca89950 (LWP 3714)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f3ccca806f0 (LWP 3711)]
0x000000000051f3ff in iseq_data_to_ary (iseq=0x126ba30) at iseq.c:1318
1318 if (iseq->line_info_table[ti].position == pos) {
(gdb) where
#0 0x000000000051f3ff in iseq_data_to_ary (iseq=0x126ba30) at
iseq.c:1318
#1 0x000000000052768b in vm_call_method (th=0x100c300,
cfp=0x7f3ccc9fdf08, num=0, blockptr=0x1, flag=0, id=992,
me=0x1122080, recv=19299400) at vm_insnhelper.c:452
#2 0x00000000005298d9 in vm_exec_core (th=0x100c300, initial=) at insns.def:1015
#3 0x000000000052e62a in vm_exec (th=0x100c300) at vm.c:1217
#4 0x000000000052e99d in rb_iseq_eval_main (iseqval=19300040) at
vm.c:1459
#5 0x00000000004190cb in ruby_exec_internal (n=0x1267ec8) at eval.c:204
#6 0x000000000041b7a6 in ruby_run_node (n=) at
eval.c:251
#7 0x000000000041834f in main (argc=2, argv=0x7fff748a2ae8) at
main.c:38
(gdb)
期待した結果は"1"というRubyプログラムのISeqの配列表現が表示されることです。