あ伊藤です。 ruby のバグ報告です。
Hash::each のイテレータブロックの中で、パラメータとして渡された
キーを delete で削除すると、ruby が core dump します。
$ cat test.rb
a = {"a"=>1,"b"=>2,"c"=>3}
a.each do |k,v|
a.delete(k)
end
$ ruby -v
ruby - version 1.0-970530 (i586-linux)
$ ruby test.rb
test.rb:3: [BUG] Segmentation fault
Abort (core dumped)
$ gdb ~/amuse/ruby-1.0-970530/ruby core
GDB is free software and you are welcome to 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.
GDB 4.16 (i586-unknown-linux), Copyright 1996 Free Software Foundation, Inc...
Core was generated by `ruby test.rb'.
Program terminated with signal 6, IOT trap/Abort.
Reading symbols from /lib/libdl.so.1.7.14...done.
Reading symbols from /lib/libm.so.5.0.6...done.
Reading symbols from /lib/libc.so.5.3.12...done.
Reading symbols from /lib/ld-linux.so.1...done.
#0 0x4002b911 in __kill ()
(gdb) bt
#0 0x4002b911 in __kill ()
#1 0x40067a3d in gsignal ()
#2 0x807cdad in sigsegv (sig=11) at signal.c:313
#3 0xbffff654 in ?? ()
#4 0x8063395 in hash_each_pair (hash=0x40105aa0) at hash.c:376
#5 0x805a6cc in rb_call (class=0x4010a49c, recv=1074813600, mid=3257, argc=0,
argv=0x0, scope=0) at eval.c:2787
#6 0x8057900 in rb_eval (self=1074853420, node=0x40105c58) at eval.c:1387
#7 0x805708b in rb_eval (self=1074853420, node=0x40105b40) at eval.c:1207
#8 0x8056c1c in rb_eval (self=1074853420, node=0x40105af0) at eval.c:1061
#9 0x8056075 in eval_node (self=1074853420) at eval.c:664
#10 0x805610d in ruby_run () at eval.c:692
#11 0x804e52c in main (argc=2, argv=0xbffffda8, envp=0xbffffdb4) at main.c:22
#12 0x804e4bb in ___crt_dummy__ ()