Project

General

Profile

Bug #17304 » reproducer.rb

simplified reproducer - thinline (THINline s.r.o.), 11/02/2020 12:44 PM

 
require 'socket'

class SubKlass
attr_reader :socket

private

def initialize(arrayparam = [], opts = {})
socket, child = UNIXSocket.pair
@pid = fork do
STDIN.reopen(child)
STDOUT.reopen(child)
child.close
socket.close
arrayparam.unshift('/bin/cat')
exec(*arrayparam, close_others: true)
end

child.close
@socket = socket
end
end

class Klass
def method()
# issues a write to @instance's socket
@instance.socket.write('test')
begin
@instance.socket.read_nonblock(16)
rescue
retry
end
end

def initialize(arrayparam: [])
@instance = SubKlass.new(arrayparam, otherparam: :symbol)
end
end

params = []
instance = Klass.new(arrayparam: params)
instance.method
(1-1/2)