[#23457] [Bug #1471] "Mutual join" deadlock detection faulty in 1.8.6 and 1.8.7 — John Carter <redmine@...>

Bug #1471: "Mutual join" deadlock detection faulty in 1.8.6 and 1.8.7

17 messages 2009/05/15

[#23483] [Bug #1478] Ruby archive — Oleg Puchinin <redmine@...>

Bug #1478: Ruby archive

29 messages 2009/05/16
[#29225] [Feature #1478] Ruby archive — Luis Lavena <redmine@...> 2010/04/02

Issue #1478 has been updated by Luis Lavena.

[#30345] Re: [Feature #1478] Ruby archive — "NAKAMURA, Hiroshi" <nakahiro@...> 2010/05/21

On Fri, Apr 2, 2010 at 17:13, Luis Lavena <redmine@ruby-lang.org> wrote:

[#30346] Re: [Feature #1478] Ruby archive — Jonathan Nielsen <jonathan@...> 2010/05/21

> Thanks for your comment.

[#30347] Re: [Feature #1478] Ruby archive — Jonathan Nielsen <jonathan@...> 2010/05/21

OK Hiroshi, I read some of the comments earlier in the thread that I

[#30355] Re: [Feature #1478] Ruby archive — Caleb Clausen <vikkous@...> 2010/05/21

On 5/20/10, Jonathan Nielsen <jonathan@jmnet.us> wrote:

[#30364] Re: [Feature #1478] Ruby archive — Benoit Daloze <eregontp@...> 2010/05/22

Hi,

[#23505] [Bug #1494] tempfile#unlink may silently fail on windows — Nicholas Manning <redmine@...>

Bug #1494: tempfile#unlink may silently fail on windows

19 messages 2009/05/19

[#23572] [Bug #1525] Deadlock in Ruby 1.9's VM caused by ConditionVariable.wait and fork? — Hongli Lai <redmine@...>

Bug #1525: Deadlock in Ruby 1.9's VM caused by ConditionVariable.wait and fork?

27 messages 2009/05/27

[#23595] Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...>

The RUBY_PLATFORM constant is documented in the latest Pickaxe as "The

17 messages 2009/05/28
[#23596] Re: Meaning of RUBY_PLATFORM — Luis Lavena <luislavena@...> 2009/05/28

On Thu, May 28, 2009 at 3:41 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#23602] Re: Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...> 2009/05/28

On Thu, May 28, 2009 at 2:52 PM, Luis Lavena <luislavena@gmail.com> wrote:

[#23608] Re: Meaning of RUBY_PLATFORM — Luis Lavena <luislavena@...> 2009/05/28

On Thu, May 28, 2009 at 7:08 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#23609] Re: Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...> 2009/05/29

On Thu, May 28, 2009 at 7:22 PM, Luis Lavena <luislavena@gmail.com> wrote:

[ruby-core:23614] [Bug #1535] Hash#merge! Inside Iterator Can Cause RuntimeError

From: Run Paint Run Run <redmine@...>
Date: 2009-05-29 01:29:09 UTC
List: ruby-core #23614
Bug #1535: Hash#merge! Inside Iterator Can Cause RuntimeError
http://redmine.ruby-lang.org/issues/show/1535

Author: Run Paint Run Run
Status: Open, Priority: Normal
Category: core, Target version: Ruby 1.8.7
ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

While iterating over a hash I can cause a RuntimeError to be raised when calling Hash#merge! on the same hash under very specific circumstances. Specifically, before the merge! the size of the two hashes combined needs to be about 67 or 68. Much more or less and the code runs correctly. For example:
  
  hash = {1 => 2, 3 => 4, 5 => 6}
  big_hash = {}
  64.times { |k| big_hash[k.to_s] = k }
  hash.each { hash.merge!(big_hash) }

This raises a RuntimeError: "hash modified during iteration" on 1.8.6.368 and 1.8.7.72. It runs correctly on 1.9.1.129. I've tested on a 32-bit Linux box, but it has been confirmed on a Mac, too.

I believe this to be a bug for three principle reasons:

1 - This behaviour is not documented for #each or #merge!. Something similar is documented for #rehash, but as the user does not explicitly call #rehash, they cannot be held responsible for its side effects.
2 - It seemingly operates under very specific conditions such that it may only be visible given such data structures, so the user would likely be unaware of this fatal consequence prior to experiencing it.
3 - It does not occur under 1.9.1, implying that this isn't the desired behaviour.

The ideal resolution is that this code works correctly, regardless of the dimensions of the data structures. If that is not possible, calling Hash#merge inside such an iterator block should be prohibited, so as to notify users of the incompatibility at design time.


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next