In case it helps, it seems as if Ruby v2.3 is "more" broken than earlier versions. If I remove the Bar.method(:foo) lookup before the Baz module is prepended, the final lookup still hangs in Ruby v2.3, but not in v2.2. See below:
moduleFooprivatedeffoo"foo"endendclassBarextendFooclass<<selfpublic:fooendendmoduleBazendclassBarclass<<selfprependBazendendBar.method(:foo)# => hangs in Ruby v2.3.1, but not v2.2.5
I'm not sure whether this is useful information but calling #instance_method on Bar's metaclass also causes Ruby to hang. Using James's most recent code snippet, the following code seems to cause the same problem as Bar.method(:foo).
metaclass=(class<<Bar;self;end)pmetaclass.instance_method(:foo)# => hangs in Ruby v2.3.1, but not v2.2.5
Ruby defers signals. At safe moments, Ruby checks if a signal arrived, then handles it. If Ruby is stuck in an infinite loop (because of a bug like this one), then Ruby would never check if a signal arrived, so the signal would be ignored. After fixing the bug, signals should work again. Ruby's deferred signals seem like Perl's, see http://perldoc.perl.org/perlipc.html#Deferred-Signals-(Safe-Signals)