I think this is related to an old, but intensional, spec around
Symbols.  In the age of stone, Ruby's Symbols were mere Fixnums
generated by String#intern.  String#intern mapped *any* strings into
Fixnums so there were always possibility of hash collision.  Today's MRI
seems to save this ancient behavior.

I'm not sure if this particular 2**21 range is needlessly small.  And
for a side note, I've not seen the collision on my 64bit machine, maybe
because I do not have enough physical memory for ruby to do so.

Vladimir Sizikov wrote:
> Hi,
>
> I found some interesting blog post with bug report against MRI, and it
> seems  that it relates to a number of symbols MRI can handle.
>
> The original report is here:
> http://ninh.nl/blog/2008/07/06/ruby-bug/
>
> Here's a very simple example:
> obj = Object.new
> (1..20_000_000).each { |i|
>   puts "Object responds to #{i}" if obj.respond_to?(i.to_s)
> }
>
> Try to run it on *any* MRI version and you'll see:
> Object responds to 2094132
> Object responds to 2094133
> Object responds to 2094134
> Object responds to 2094141
> Object responds to 2094144
> Object responds to 2094156
> Object responds to 2094158
> Object responds to 2094159
> Object responds to 2094160
> Object responds to 2094249
> Object responds to 4191284
> Object responds to 4191285
> Object responds to 4191286
> ....
>
> And the object *DOES* respond to those :)
>
> For example, :"2094132" is actually :nil?, etc.
>
> If you take a look at the series above, you'll see that they repeat
> every 2**21th iteration.
>
> So, effectively, MRI can handle at most 2**21 unique symbols and then
> it silently overflows thus producing non-unique symbols.
>
> I've checked with JRuby, and it can handle more than 2*21 symbols.
>
> Thanks,
>   --Vladimir
>
>
>
>