In article <1068753744.644627.6908.nullmailer / picachu.netlab.jp>,
  matz / ruby-lang.org (Yukihiro Matsumoto) writes:

> 飛行機の中でdelete_if実行中には更新を許さないようにしてみま
> したが、まだ落ちます。更新中にdelete_ifが実行されちゃうケー
> スでst_lookupがまだ参照しているrecordをfree()しちゃうようで
> す。もうちょっと考えないといけませんね。
>
> すぐに思いつくのはdelete_ifでは条件が真のkeyを覚えておくだけ
> にして、削除は後で一度にするくらいですかねえ。

修正が入ったようですが、まだ core を吐くことがあります。

% ruby -e 'h = {}
Thread.new { loop { h.delete_if {|k, s| s.length == 0 } } }
loop { h[rand] = "" }
'
zsh: segmentation fault (core dumped)  ruby -e 
% gdb =ruby core
GNU gdb 5.3-debian
Copyright 2002 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 "i386-linux"...
Core was generated by `ruby -e h = {}
Thread.new { loop { h.delete_if {|k, s| s.length == 0 } } }
loop'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x080aa902 in st_insert (table=0x8121870, key=1075875320, value=1075875300) at st.c:298
298         FIND_ENTRY(table, ptr, hash_val, bin_pos);
(gdb) p table
$1 = (st_table *) 0x8121870
(gdb) p ptr
$2 = (st_table_entry *) 0x8139030
(gdb) p hash_val
$3 = 127201
(gdb) p bin_pos
$4 = 142
(gdb) where
#0  0x080aa902 in st_insert (table=0x8121870, key=1075875320, value=1075875300) at st.c:298
#1  0x0806d58c in rb_hash_aset (hash=1075568676, key=1075875320, val=1075875300) at hash.c:562
#2  0x0805bc44 in rb_call0 (klass=1075604276, recv=1075568676, id=333, oid=333, argc=2, argv=0xbfffe370, body=0x401c6918, 
    nosuper=0) at eval.c:4943
#3  0x0805c686 in rb_call (klass=1075604276, recv=1075568676, mid=333, argc=2, argv=0xbfffe370, scope=0) at eval.c:5289
#4  0x0805711f in rb_eval (self=1075632696, n=0x401be09c) at eval.c:3064
#5  0x0805a013 in rb_yield_0 (val=6, self=1075632696, klass=0, flags=0, avalue=0) at eval.c:4299
#6  0x0805a308 in rb_f_loop () at eval.c:4400
#7  0x0805bc61 in rb_call0 (klass=1075637416, recv=1075632696, id=3937, oid=3937, argc=0, argv=0x0, body=0x401cd178, 
    nosuper=0) at eval.c:4946
#8  0x0805c686 in rb_call (klass=1075637416, recv=1075632696, mid=3937, argc=0, argv=0x0, scope=1) at eval.c:5289
#9  0x0805754c in rb_eval (self=1075632696, n=0x401be074) at eval.c:3097
#10 0x080565ac in rb_eval (self=1075632696, n=0x401be178) at eval.c:2802
#11 0x08053530 in eval_node (self=1075632696, node=0x401be178) at eval.c:1267
#12 0x080539fe in ruby_exec () at eval.c:1436
#13 0x08053a5a in ruby_run () at eval.c:1457
#14 0x08051f26 in main (argc=3, argv=0xbffff944, envp=0xbffff954) at main.c:50
#15 0x40084e3e in __libc_start_main () from /lib/libc.so.6
(gdb)  
-- 
[田中 哲][たなか あきら][Tanaka Akira]