Project

General

Profile

Actions

Bug #3183

closed

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

Added by AaZmaN (John Bragari) over 14 years ago. Updated over 13 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 master - Bug #2488: thread usage can result in bad HANDLEClosedko1 (Koichi Sasada)12/17/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0