Skip to content

NullPointerException when inheriting from SSLSocket #165

@ajlai

Description

@ajlai

This is using jruby-openssl 0.10.0, JRUBY_VERSION 9.1.17.0.
Discovered when doing a deeper dive on redis/redis-rb#756

require 'socket'
require 'openssl'

class InheritedSSLSocket < OpenSSL::SSL::SSLSocket
end

host = 'localhost'
port = 12345

tcp_server = TCPServer.new(host, port)

tcp_sock = TCPSocket.new(host, port)
ctx = OpenSSL::SSL::SSLContext.new

ssl_sock = InheritedSSLSocket.new(tcp_sock, ctx) # KABOOM

here's the stack trace:

Java::JavaLang::NullPointerException:
	from org.jruby.ext.openssl.SSLSocket.callSite(SSLSocket.java:149)
	from org.jruby.ext.openssl.SSLSocket.set_io_nonblock_checked(SSLSocket.java:195)
	from org.jruby.ext.openssl.SSLSocket.initialize(SSLSocket.java:183)
	from org.jruby.ext.openssl.SSLSocket$INVOKER$i$0$0$initialize.call(SSLSocket$INVOKER$i$0$0$initialize.gen)
	from org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:800)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:348)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:193)
	from org.jruby.RubyClass.newInstance(RubyClass.java:1009)
	from org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:210)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:183)
	from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:324)
	from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
	from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:117)
	from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:171)
... 103 levels...
	from org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:165)
	from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:202)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:318)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:155)
	from usr.local.var.rbenv.versions.jruby_minus_9_dot_1_dot_17_dot_0.bin.jirb.invokeOther13:start(/usr/local/var/rbenv/versions/jruby-9.1.17.0/bin/jirb:13)
	from usr.local.var.rbenv.versions.jruby_minus_9_dot_1_dot_17_dot_0.bin.jirb.RUBY$script(/usr/local/var/rbenv/versions/jruby-9.1.17.0/bin/jirb:13)
	from java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	from org.jruby.ir.Compiler$1.load(Compiler.java:94)
	from org.jruby.Ruby.runScript(Ruby.java:830)
	from org.jruby.Ruby.runNormally(Ruby.java:749)
	from org.jruby.Ruby.runNormally(Ruby.java:767)
	from org.jruby.Ruby.runFromMain(Ruby.java:580)
	from org.jruby.Main.doRunFromMain(Main.java:417)
	from org.jruby.Main.internalRun(Main.java:305)
	from org.jruby.Main.run(Main.java:232)
	from org.jruby.Main.main(Main.java:204)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions