Bug #1000

Segmentation fault in Hash#[]

Added by Morgan Christiansson over 5 years ago. Updated over 1 year ago.

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

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-trunk - Bug #1385: Wonderful undocumented feature in Ruby 1.8.7 & 1.9 Closed 04/17/2009

History

#1 Updated by Shyouhei Urabe over 5 years ago

=begin
Situation confirmed on my environment.

zsh % gdb --args ~/target/branches/ruby18/bin/ruby -v ~/target/branches/ruby18/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 "x8664-linux-gnu"...Using host libthreaddb library "/lib/libthread_db.so.1".

(gdb) run
Starting program: /home/shyouhei/target/branches/ruby18/bin/ruby -v /home/shyouhei/target/branches/ruby18/bin/irb
[Thread debugging using libthreaddb 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)]
searchmethod (klass=65, id=3145, origin=0x7fff626a2cd8) at /home/shyouhei/ruby/branches/ruby18/eval.c:475
warning: Source file is more recent than executable.
475 while (!st
lookup(RCLASS(klass)->mtbl, id, &body)) {
(gdb) bt
#0 search
method (klass=65, id=3145, origin=0x7fff626a2cd8) at /home/shyouhei/ruby/branches/ruby18/eval.c:475
#1 0x0000000000411dc7 in rbgetmethodbody (klassp=0x7fff626a2d20, idp=0x7fff626a2d28, noexp=0x7fff626a2d34) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6130
#3 0x000000000041cdf7 in vafuncall (recv=7238064, mid=3145, n=0, ar=) at /home/shyouhei/ruby/branches/ruby18/eval.c:6232
#4 0x000000000041d083 in rbfuncall (recv=65, mid=3145, n=1651125464) at /home/shyouhei/ruby/branches/ruby18/eval.c:6249
#5 0x00000000004440e6 in rb
inspect (obj=65) at /home/shyouhei/ruby/branches/ruby18/object.c:334
#6 0x0000000000431117 in inspecti (key=, value=7238064, str=47185724125000) at /home/shyouhei/ruby/branches/ruby18/hash.c:1332
#7 0x0000000000430aa3 in hash
foreachiter (key=47185724128040, value=3145, arg=0x7fff626a3080) at /home/shyouhei/ruby/branches/ruby18/hash.c:177
#8 0x0000000000472de9 in st
foreach (table=0x6e75e0, func=0x430a80 , arg=140734844514432) at /home/shyouhei/ruby/branches/ruby18/st.c:487
#9 0x0000000000432788 in hashforeachcall (arg=0x7fff626a2cd8) at /home/shyouhei/ruby/branches/ruby18/hash.c:212
#10 0x000000000041031b in rbensure (bproc=0x432770 , data1=140734844514432, eproc=0x432720 <hashforeachensure>, data2=47185724126920) at /home/shyouhei/ruby/branches/ruby18/eval.c:5557
#11 0x0000000000431dba in rb
hashforeach (hash=0, func=, farg=) at /home/shyouhei/ruby/branches/ruby18/hash.c:230
#12 0x00000000004320ce in inspect
hash (hash=47185724126920) at /home/shyouhei/ruby/branches/ruby18/hash.c:1346
#13 0x000000000041031b in rbensure (bproc=0x486090 , data1=140734844514848, eproc=0x488130 <inspectensure>, data2=47185724126920) at /home/shyouhei/ruby/branches/ruby18/eval.c:5557
#14 0x000000000048b45e in rbprotectinspect (func=0x4320a0 , obj=47185724126920, arg=0) at /home/shyouhei/ruby/branches/ruby18/array.c:1544
#15 0x000000000041bb1a in rbcall0 (klass=47185723224000, recv=47185724126920, id=3145, oid=3145, argc=0, argv=0x0, body=0x2aea48456cc8, flags=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6155
#17 0x00000000004175dc in rbeval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3496
#18 0x000000000041769c in rb
eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3506
#19 0x000000000041c392 in rbcall0 (klass=47185723452080, recv=47185723434760, id=11513, oid=11513, argc=62, argv=0x0, body=0x2aea48434d80, flags=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6155
#21 0x000000000041775c in rbeval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3517
#22 0x0000000000418da4 in rb
eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3312
#23 0x000000000041ace3 in rbyield0 (val=6, self=47185723434760, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby18/eval.c:5081
#24 0x0000000000418114 in rbeval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3301
#25 0x000000000041905f in rb
eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3360
#26 0x000000000041c392 in rbcall0 (klass=47185723452080, recv=47185723434760, id=11425, oid=11425, argc=0, argv=0x7fff626a50d8, body=0x2aea48436d10, flags=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6155
#28 0x0000000000417712 in rbeval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3511
#29 0x0000000000419710 in rb
eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3226
#30 0x000000000041ace3 in rbyield0 (val=47185724130280, self=47185723434760, klass=0, flags=, avalue=2) at /home/shyouhei/ruby/branches/ruby18/eval.c:5081
#31 0x0000000000418114 in rbeval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3301
#32 0x0000000000418da4 in rb
eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3312
#33 0x000000000041ace3 in rbyield0 (val=6, self=47185723169920, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby18/eval.c:5081
#34 0x0000000000424c97 in loopi () at /home/shyouhei/ruby/branches/ruby18/eval.c:5213
#35 0x0000000000410e64 in rb
rescue2 (bproc=0x424c80 <loopi>, data1=0, rproc=0, data2=0) at /home/shyouhei/ruby/branches/ruby18/eval.c:5477
#36 0x0000000000411040 in rb
floop () at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:5908
#38 0x000000000041c8e9 in rbcall (klass=47185723296080, recv=47185723169920, mid=4121, argc=0, argv=0x0, scope=1, self=47185723169920) at /home/shyouhei/ruby/branches/ruby18/eval.c:6155
#39 0x0000000000417712 in rb
eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3511
#40 0x0000000000419710 in rbeval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3226
#41 0x000000000041ace3 in rb
yield0 (val=3652878, self=47185723169920, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby18/eval.c:5081
#42 0x000000000041b0c4 in rb
fcatch (dmy=, tag=3652878) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:5908
#44 0x000000000041c8e9 in rbcall (klass=47185723296080, recv=47185723169920, mid=4185, argc=1, argv=0x7fff626a73b0, scope=1, self=47185723169920) at /home/shyouhei/ruby/branches/ruby18/eval.c:6155
#45 0x0000000000417712 in rb
eval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3511
#46 0x0000000000419710 in rbeval (self=47185723169920, n=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6059
#48 0x000000000041c8e9 in rbcall (klass=47185723709600, recv=47185723169920, mid=11481, argc=0, argv=0x0, scope=0, self=47185723434760) at /home/shyouhei/ruby/branches/ruby18/eval.c:6155
#49 0x00000000004175dc in rb
eval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3496
#50 0x0000000000419710 in rbeval (self=47185723434760, n=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6059
#52 0x000000000041c8e9 in rbcall (klass=47185723452080, recv=47185723434760, mid=11161, argc=0, argv=0x0, scope=0, self=47185722983280) at /home/shyouhei/ruby/branches/ruby18/eval.c:6155
#53 0x00000000004175dc in rb
eval (self=47185722983280, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3496
#54 0x000000000041ace3 in rbyield0 (val=2856206, self=47185722983280, klass=0, flags=, avalue=0) at /home/shyouhei/ruby/branches/ruby18/eval.c:5081
#55 0x000000000041b0c4 in rbfcatch (dmy=, tag=2856206) at /home/shyouhei/ruby/branches/ruby18/eval.c:13624
#56 0x000000000041bb1a in rbcall0 (klass=47185723296080, recv=47185722983280, id=4185, oid=4185, argc=1, argv=0x7fff626a8fb0, body=0x2aea484646e8, flags=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6155
#58 0x0000000000417712 in rbeval (self=47185722983280, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3511
#59 0x0000000000419710 in rb
eval (self=47185722983280, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3226
#60 0x000000000041c392 in rbcall0 (klass=47185722983120, recv=47185722983280, id=5329, oid=5329, argc=0, argv=0x7fff626a9998, body=0x2aea48441968, flags=) at /home/shyouhei/ruby/branches/ruby18/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/ruby18/eval.c:6155
#62 0x00000000004175dc in rbeval (self=47185723286200, n=) at /home/shyouhei/ruby/branches/ruby18/eval.c:3496
#63 0x0000000000427779 in ruby
execinternal () at /home/shyouhei/ruby/branches/ruby18/eval.c:1645
#64 0x00000000004277c5 in ruby
exec () at /home/shyouhei/ruby/branches/ruby18/eval.c:1665
#65 0x00000000004277ed in rubyrun () at /home/shyouhei/ruby/branches/ruby18/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 Nobuyoshi Nakada over 5 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