Class clones and duplicates raise StackOverflowError when listing their singleton class ancestors #4339

Closed
gdeoliveira opened this Issue Nov 27, 2016 · 1 comment

Projects

None yet

3 participants

@gdeoliveira

Environment

Running inside 9-alpine docker container.

jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM 25.111-b14 on 1.8.0_111-internal-alpine-r0-b14 +jit [linux-x86_64]
Linux dfcfcfee1b70 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 Linux

Expected Behavior (MRI 2.3.1)

Klass = Class.new
Clone = Klass.clone
Dup = Klass.dup

Clone.singleton_class.ancestors
#=> [#<Class:Clone>, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, PP::ObjectMixin, Kernel, BasicObject]

Dup.singleton_class.ancestors
#=> [#<Class:Dup>, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, PP::ObjectMixin, Kernel, BasicObject]

Actual Behavior

Klass = Class.new
Clone = Klass.clone
Dup = Klass.dup

Clone.singleton_class.ancestors
Java::JavaLang::StackOverflowError: 
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
... 992 levels...
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)

Dup.singleton_class.ancestors
Java::JavaLang::StackOverflowError: 
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
... 992 levels...
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
	from org.jruby.RubyModule.to_s(RubyModule.java:2183)
	from org.jruby.RubyBasicObject.inspect(RubyBasicObject.java:1105)
@enebo enebo added this to the JRuby 9.1.7.0 milestone Nov 28, 2016
@headius
Member
headius commented Nov 29, 2016

Appears to be fixed on master. Probably same fix as #4340.

@headius headius closed this Nov 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment