From: Neil Spring Date: 2004-05-20T07:47:19+09:00 Subject: threads, Hash#delete_if, and ruby segfaults. should the following code cause the ruby interpreter to segfault? If so, resolv.rb should have a mutex guard @senders. If not, st_foreach should avoid the race when independent threads delete adjacent elements from the same linked list. #!/usr/bin/ruby desired_length = 10000 hash = Hash.new threads = (0..4).map { |i| Thread.new { while true hash.delete_if { |k,v| Kernel.rand > 0.5 } while hash.length < desired_length hash[Kernel.rand(desired_length * 10)] = 12 end end } } (I submitted a really clunky version of this as ruby bug 1326 with not nearly so simple a test case, but can't figure out how to follow up to the message). thanks, -neil