Project

General

Profile

Bug #3183

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

Added by AaZmaN (John Bragari) over 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
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

Related to Ruby master - Bug #2488: thread usage can result in bad HANDLEClosed12/17/2009Actions

History

#1

Updated by AaZmaN (John Bragari) over 9 years ago

=begin
I could reach the the same crash with the following code:

somevar = []
700.times{|i|
somevar << Thread.new{}
puts "cycle #{i}"
}

Sometimes it crashes on the third time when I run the code, but sometimes it doesn't crash even if I run it 20 times.

...
...
...
cycle 351
cycle 352[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.

=end

#2

Updated by AaZmaN (John Bragari) over 9 years ago

=begin
Also able to reach the crash with:

700.times{|i|
Thread.new{}
puts i
}

and even with:

700.times{
Thread.new{}
puts "."
}

but not with:

700.times{
Thread.new{}
}

[Note: The script crashes even when 0 < i < 10]
=end

#3

Updated by rogerdpack (Roger Pack) over 9 years ago

=begin
do you get this on trunk?
=end

#4

Updated by rogerdpack (Roger Pack) over 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Do you still get this with trunk (I will assume not since #2488 was fixed).
=end

Also available in: Atom PDF