Project

General

Profile

This project is closed and read-only.

Actions

Bug #3183

closed

"[BUG] The handle is invalid." when working with Threads

Bug #3183: "[BUG] The handle is invalid." when working with Threads

Added by AaZmaN (John Bragari) over 16 years ago. Updated over 15 years ago.

Status:
Closed
Assignee:
-
ruby -v:
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32]
[ruby-core:29698]

Description

=begin
Sometimes (about 30% times) when running the following code ruby crashes.

The code:

$threads_alowed = 750;
$threads = []
#Initializing thread objects
$threads_alowed.times{|thread_id|
$threads[thread_id] = {'thread' => Thread.new{}}
puts "thID #{thread_id} initialized"
}

def do_something(thread_id)
wait = rand(300)
print "\nThread #{thread_id} is doing something for #{wait} seconds"
sleep wait
end

while true do
$threads_alowed.times{|thread_id|
status = $threads[thread_id]['thread'].status
if status == false or status == nil
$threads[thread_id]['thread'] = Thread.new(thread_id){do_something(thread_id)}
print ","
end
}
print "."
sleep 0.03
end

The crash:

....
....
....
thID 288 initialized
thID 289 initialized
[BUG] The handle is invalid.

ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32]

-- control frame ----------

-- Ruby level backtrace information-----------------------------------------

[NOTE]
You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Tried Ruby 1.9.1 MinGW and mswin32 with the same result.
=end


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #2488: thread usage can result in bad HANDLEClosedko1 (Koichi Sasada)Actions
Actions

Also available in: PDF Atom