Project

General

Profile

Bug #1000

Segmentation fault in Hash#[]

Added by mog (Morgan Christiansson) over 11 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
[ruby-core:21249]

Description

=begin
Ruby crashes when creating a Hash using the [] public method.
For some reason it works the first time but segfaults the second time.

$ irb
irb(main):001:0> Hash[{:k=>["empty"]}]
=> {"empty"=>false}
irb(main):002:0> Hash[
{:k=>["empty"]}]
/usr/lib/ruby/1.8/irb.rb:302: [BUG] Segmentation fault
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

Aborted
=end


Related issues

Related to Ruby master - Bug #1385: Wonderful undocumented feature in Ruby 1.8.7 & 1.9Closedyugui (Yuki Sonoda)04/17/2009Actions
#1

Updated by shyouhei (Shyouhei Urabe) over 11 years ago

=begin
Situation confirmed on my environment.

zsh % gdb --args ~/target/branches/ruby_1_8/bin/ruby -v ~/target/branches/ruby_1_8/bin/irb
GNU gdb 6.4.90-debian
Copyright (C) 2006 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 "x86_64-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run
Starting program: /home/shyouhei/target/branches/ruby_1_8/bin/ruby -v /home/shyouhei/target/branches/ruby_1_8/bin/irb
[Thread debugging using libthread_db enabled]
[New Thread 47185722893680 (LWP 13501)]
ruby 1.8.7 (2009-01-07 revision 21366) [x86_64-linux]
irb(main):001:0> Hash[{:k=>["empty"]}]
=> {"empty"=>false}
irb(main):002:0> Hash[
{:k=>["empty"]}]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47185722893680 (LWP 13501)]
search_method (klass=65, id=3145, origin=0x7fff626a2cd8) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:475
warning: Source file is more recent than executable.
475 while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
(gdb) bt
#0 search_method (klass=65, id=3145, origin=0x7fff626a2cd8) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:475
#1 0x0000000000411dc7 in rb_get_method_body (klassp=0x7fff626a2d20, idp=0x7fff626a2d28, noexp=0x7fff626a2d34) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:496
#2 0x000000000041c80e in rb_call (klass=65, recv=7238064, mid=3145, argc=0, argv=0x0, scope=1, self=6) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6130
#3 0x000000000041cdf7 in vafuncall (recv=7238064, mid=3145, n=0, ar=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6232
#4 0x000000000041d083 in rb_funcall (recv=65, mid=3145, n=1651125464) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6249
#5 0x00000000004440e6 in rb_inspect (obj=65) at /home/shyouhei/ruby/branches/ruby_1_8/object.c:334
#6 0x0000000000431117 in inspect_i (key=, value=7238064, str=47185724125000) at /home/shyouhei/ruby/branches/ruby_1_8/hash.c:1332
#7 0x0000000000430aa3 in hash_foreach_iter (key=47185724128040, value=3145, arg=0x7fff626a3080) at /home/shyouhei/ruby/branches/ruby_1_8/hash.c:177
#8 0x0000000000472de9 in st_foreach (table=0x6e75e0, func=0x430a80 , arg=140734844514432) at /home/shyouhei/ruby/branches/ruby_1_8/st.c:487
#9 0x0000000000432788 in hash_foreach_call (arg=0x7fff626a2cd8) at /home/shyouhei/ruby/branches/ruby_1_8/hash.c:212
#10 0x000000000041031b in rb_ensure (b_proc=0x432770 , data1=140734844514432, e_proc=0x432720 , data2=47185724126920) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5557
#11 0x0000000000431dba in rb_hash_foreach (hash=0, func=, farg=) at /home/shyouhei/ruby/branches/ruby_1_8/hash.c:230
#12 0x00000000004320ce in inspect_hash (hash=47185724126920) at /home/shyouhei/ruby/branches/ruby_1_8/hash.c:1346
#13 0x000000000041031b in rb_ensure (b_proc=0x486090 , data1=140734844514848, e_proc=0x488130 , data2=47185724126920) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5557
#14 0x000000000048b45e in rb_protect_inspect (func=0x4320a0 , obj=47185724126920, arg=0) at /home/shyouhei/ruby/branches/ruby_1_8/array.c:1544
#15 0x000000000041bb1a in rb_call0 (klass=47185723224000, recv=47185724126920, id=3145, oid=3145, argc=0, argv=0x0, body=0x2aea48456cc8, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5908
#16 0x000000000041c8e9 in rb_call (klass=47185723224000, recv=47185724126920, mid=3145, argc=0, argv=0x0, scope=0, self=47185723434760) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#17 0x00000000004175dc in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3496
#18 0x000000000041769c in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3506
#19 0x000000000041c392 in rb_call0 (klass=47185723452080, recv=47185723434760, id=11513, oid=11513, argc=62, argv=0x0, body=0x2aea48434d80, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6059
#20 0x000000000041c8e9 in rb_call (klass=47185723452080, recv=47185723434760, mid=11513, argc=0, argv=0x0, scope=2, self=47185723434760) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#21 0x000000000041775c in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3517
#22 0x0000000000418da4 in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3312
#23 0x000000000041ace3 in rb_yield_0 (val=6, self=47185723434760, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5081
#24 0x0000000000418114 in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3301
#25 0x000000000041905f in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3360
#26 0x000000000041c392 in rb_call0 (klass=47185723452080, recv=47185723434760, id=11425, oid=11425, argc=0, argv=0x7fff626a50d8, body=0x2aea48436d10, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6059
#27 0x000000000041c8e9 in rb_call (klass=47185723452080, recv=47185723434760, mid=11425, argc=1, argv=0x7fff626a50d0, scope=1, self=47185723434760) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#28 0x0000000000417712 in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3511
#29 0x0000000000419710 in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3226
#30 0x000000000041ace3 in rb_yield_0 (val=47185724130280, self=47185723434760, klass=0, flags=, avalue=2) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5081
#31 0x0000000000418114 in rb_eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3301
#32 0x0000000000418da4 in rb_eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3312
#33 0x000000000041ace3 in rb_yield_0 (val=6, self=47185723169920, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5081
#34 0x0000000000424c97 in loop_i () at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5213
#35 0x0000000000410e64 in rb_rescue2 (b_proc=0x424c80 , data1=0, r_proc=0, data2=0) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5477
#36 0x0000000000411040 in rb_f_loop () at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5238
#37 0x000000000041bb1a in rb_call0 (klass=47185723296080, recv=47185723169920, id=4121, oid=4121, argc=0, argv=0x0, body=0x2aea48464b98, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5908
#38 0x000000000041c8e9 in rb_call (klass=47185723296080, recv=47185723169920, mid=4121, argc=0, argv=0x0, scope=1, self=47185723169920) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#39 0x0000000000417712 in rb_eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3511
#40 0x0000000000419710 in rb_eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3226
#41 0x000000000041ace3 in rb_yield_0 (val=3652878, self=47185723169920, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5081
#42 0x000000000041b0c4 in rb_f_catch (dmy=, tag=3652878) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:13624
#43 0x000000000041bb1a in rb_call0 (klass=47185723296080, recv=47185723169920, id=4185, oid=4185, argc=1, argv=0x7fff626a73b0, body=0x2aea484646e8, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5908
#44 0x000000000041c8e9 in rb_call (klass=47185723296080, recv=47185723169920, mid=4185, argc=1, argv=0x7fff626a73b0, scope=1, self=47185723169920) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#45 0x0000000000417712 in rb_eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3511
#46 0x0000000000419710 in rb_eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3226
#47 0x000000000041c392 in rb_call0 (klass=47185723709600, recv=47185723169920, id=11481, oid=11481, argc=10986, argv=0x0, body=0x2aea48518dc8, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6059
#48 0x000000000041c8e9 in rb_call (klass=47185723709600, recv=47185723169920, mid=11481, argc=0, argv=0x0, scope=0, self=47185723434760) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#49 0x00000000004175dc in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3496
#50 0x0000000000419710 in rb_eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3226
#51 0x000000000041c392 in rb_call0 (klass=47185723452080, recv=47185723434760, id=11161, oid=11161, argc=0, argv=0x0, body=0x2aea4843cdf0, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6059
#52 0x000000000041c8e9 in rb_call (klass=47185723452080, recv=47185723434760, mid=11161, argc=0, argv=0x0, scope=0, self=47185722983280) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#53 0x00000000004175dc in rb_eval (self=47185722983280, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3496
#54 0x000000000041ace3 in rb_yield_0 (val=2856206, self=47185722983280, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5081
#55 0x000000000041b0c4 in rb_f_catch (dmy=, tag=2856206) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:13624
#56 0x000000000041bb1a in rb_call0 (klass=47185723296080, recv=47185722983280, id=4185, oid=4185, argc=1, argv=0x7fff626a8fb0, body=0x2aea484646e8, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:5908
#57 0x000000000041c8e9 in rb_call (klass=47185723296080, recv=47185722983280, mid=4185, argc=1, argv=0x7fff626a8fb0, scope=1, self=47185722983280) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#58 0x0000000000417712 in rb_eval (self=47185722983280, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3511
#59 0x0000000000419710 in rb_eval (self=47185722983280, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3226
#60 0x000000000041c392 in rb_call0 (klass=47185722983120, recv=47185722983280, id=5329, oid=5329, argc=0, argv=0x7fff626a9998, body=0x2aea48441968, flags=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6059
#61 0x000000000041c8e9 in rb_call (klass=47185722983120, recv=47185722983280, mid=5329, argc=1, argv=0x7fff626a9990, scope=0, self=47185723286200) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:6155
#62 0x00000000004175dc in rb_eval (self=47185723286200, n=) at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:3496
#63 0x0000000000427779 in ruby_exec_internal () at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:1645
#64 0x00000000004277c5 in ruby_exec () at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:1665
#65 0x00000000004277ed in ruby_run () at /home/shyouhei/ruby/branches/ruby_1_8/eval.c:1675
#66 0x000000000040e5e3 in main (argc=3, argv=0x7fff626a9f68) at /home/shyouhei/ruby/branches/ruby_1_8/main.c:48
(gdb) q
The program is running. Exit anyway? (y or n) y
zsh %

=end

#2

Updated by nobu (Nobuyoshi Nakada) over 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r21423.
=end

Also available in: Atom PDF