Project

General

Profile

Bug #15262 ยป adder-test2.rb

Simplified version of the initial exploit - larskanis (Lars Kanis), 10/29/2018 08:34 AM

 
require "weakref"

Thread.abort_on_exception = true

class Adder
def self.start_adder(obj)
obj.add
end

def initialize
@qu = Queue.new
count = 10
count.times do
Thread.new(WeakRef.new(self), &self.class.method(:start_adder))
end
count.times do
@qu.deq
end
end

def add
@qu.enq true
end
end

def test_adder
10.times.map do
Thread.new do
Adder.new
end
end.each(&:join)
end

100.times do
test_adder
end
    (1-1/1)