This issue was solved with changeset r43859.
Sam, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
hash.c: cut off if recursion
hash.c (rb_hash): cut off if recursion detected to get rid of stack
overflow. [ruby-core:58567] [Bug #9151]