Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Thread#value is nil for a killed thread

  • Loading branch information...
commit cb3843b1cdd839cd6401345d7092bc01c072c28e 1 parent 0476cdc
@ileitch ileitch authored
View
48 kernel/bootstrap/thread.rb
@@ -142,50 +142,6 @@ def thread_is_setup?
@block != nil
end
- # Called by Thread#fork in the new thread
- #
- def __run__()
- begin
- begin
- @lock.send nil
- @result = @block.call(*@args)
- ensure
- @lock.receive
- unlock_locks
- @joins.each { |join| join.send self }
- end
- rescue Die
- @exception = nil
- rescue Exception => e
- # I don't really get this, but this is MRI's behavior. If we're dying
- # by request, ignore any raised exception.
- @exception = e # unless @dying
- ensure
- @alive = false
- @lock.send nil
- end
-
- if @exception
- if abort_on_exception or Thread.abort_on_exception
- Thread.main.raise @exception
- elsif $DEBUG
- STDERR.puts "Exception in thread: #{@exception.message} (#{@exception.class})"
- end
- end
- end
-
- def setup(prime_lock)
- @group = nil
- @alive = true
- @result = false
- @exception = nil
- @critical = false
- @dying = false
- @lock = Rubinius::Channel.new
- @lock.send nil if prime_lock
- @joins = []
- end
-
def alive?
@lock.receive
@alive
@@ -241,10 +197,6 @@ def add_to_group(group)
@group = group
end
- def value
- join_inner { @result }
- end
-
def join_inner(timeout = undefined)
result = nil
@lock.receive
View
48 kernel/bootstrap/thread18.rb
@@ -47,4 +47,52 @@ def self.critical=(value)
set_critical value
@critical = !!value
end
+
+ # Called by Thread#fork in the new thread
+ #
+ def __run__()
+ begin
+ begin
+ @lock.send nil
+ @result = @block.call(*@args)
+ ensure
+ @lock.receive
+ unlock_locks
+ @joins.each { |join| join.send self }
+ end
+ rescue Die
+ @exception = nil
+ rescue Exception => e
+ # I don't really get this, but this is MRI's behavior. If we're dying
+ # by request, ignore any raised exception.
+ @exception = e # unless @dying
+ ensure
+ @alive = false
+ @lock.send nil
+ end
+
+ if @exception
+ if abort_on_exception or Thread.abort_on_exception
+ Thread.main.raise @exception
+ elsif $DEBUG
+ STDERR.puts "Exception in thread: #{@exception.message} (#{@exception.class})"
+ end
+ end
+ end
+
+ def setup(prime_lock)
+ @group = nil
+ @alive = true
+ @result = false
+ @exception = nil
+ @critical = false
+ @dying = false
+ @lock = Rubinius::Channel.new
+ @lock.send nil if prime_lock
+ @joins = []
+ end
+
+ def value
+ join_inner { @result }
+ end
end
View
52 kernel/bootstrap/thread19.rb
@@ -32,4 +32,56 @@ def self.stop
sleep
nil
end
+
+ # Called by Thread#fork in the new thread
+ #
+ def __run__()
+ begin
+ begin
+ @lock.send nil
+ @result = @block.call(*@args)
+ ensure
+ @lock.receive
+ unlock_locks
+ @joins.each { |join| join.send self }
+ end
+ rescue Die
+ @killed = true
+ @exception = nil
+ rescue Exception => e
+ # I don't really get this, but this is MRI's behavior. If we're dying
+ # by request, ignore any raised exception.
+ @exception = e # unless @dying
+ ensure
+ @alive = false
+ @lock.send nil
+ end
+
+ if @exception
+ if abort_on_exception or Thread.abort_on_exception
+ Thread.main.raise @exception
+ elsif $DEBUG
+ STDERR.puts "Exception in thread: #{@exception.message} (#{@exception.class})"
+ end
+ end
+ end
+
+ def setup(prime_lock)
+ @group = nil
+ @alive = true
+ @result = false
+ @exception = nil
+ @critical = false
+ @dying = false
+ @lock = Rubinius::Channel.new
+ @lock.send nil if prime_lock
+ @joins = []
+ @killed = false
+ end
+
+ def value
+ join_inner do
+ @killed ? nil : @result
+ end
+ end
end
View
1  spec/tags/19/ruby/core/thread/value_tags.txt
@@ -1 +0,0 @@
-fails:Thread#value is nil for a killed thread
Please sign in to comment.
Something went wrong with that request. Please try again.