freeride-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FR-devel] Yet another Win32 thread bug - how to reproduce


From: Laurent Julliard
Subject: [FR-devel] Yet another Win32 thread bug - how to reproduce
Date: Thu, 12 Sep 2002 22:51:34 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

Lyle,

I thought the popen_test.rb file I posted before was working but actually it wasn't. I have reshaped popen_test.rb to make the thread problem even more visible on Win32. Here is the new program:

(please other FR developpers tell me if this program runs correctly and which Ruby platform/version do you use)

----- beginning of script -----------

command = "ruby -e 'loop { STDOUT.sync=true;sleep 5; puts 'Ding!'}'"

f = IO.popen(command)

th1 = Thread.new {
  loop {
    begin
      text = f.sysread(100)
      print text
    rescue EOFError
      puts "Remote program stopped"
      exit
    end
  }
}

th2 = Thread.new(0) { |i|
  loop { sleep 1; puts i=i+1 }
}

th1.join
th2.join

----- end of script -----------


On Linux (Ruby 1.6.6.) the output is exactly what one would expect:

1
2
3
4
Ding!
5
6
7
8
9
Ding!
10

On Win32 (Ruby 1.7.3+ from CVS including the recent fix for mswin32 threads) the (wrong) output is :

Ding!1

Ding!2

Ding!3


What happens is that the sysread call in th1 which is a blocking read most of the time prevents th2 from running or it rather looks like th2 is given a chance to print something only when th1 does print something itself once every 5 seconds.

I think this the root cause of all our troubles at least in FreeRIDE and may be in FOX addInput() as well. Do you think it's a real bug or is there something wrong in my program?

Laurent






reply via email to

[Prev in Thread] Current Thread [Next in Thread]