FXRuby Threading Problem Solved?

All,

I am hesistant to post this because I’m afraid it’s just a dream :wink:

A little history:

There’s a long-standing bug related to using Ruby threads in a program
that also uses FXRuby. This bug only shows up for the Visual C++ build
(a.k.a. the “mswin32” build) of Ruby and FXRuby; threads seem to work
just fine under Cygwin on Windows, and they definitely work fine under
Linux. The problem is that shortly after the thread starts executing,
the interpreter locks up. My debugging of the problem led to a point
during thread scheduling (in the rb_thread_schedule() function) where
Ruby attempts to switch contexts from one thread to another, using a C
longjmp() call. The longjmp() should “jump” to a spot previously marked
by some other thread using setjmp(), and pick up execution there, but in
my case the code was “jump”-ing into oblivion.

One of the example programs distributed with FXRuby demonstrates the
problem very well. The “groupbox.rb” example has some code that’s
currently commented-out; that code (if uncommented) would create a
little thread that updates the clock in the lower right-hand corner of
the example program’s main window. This bit of code in groupbox.rb is
commented-out precisely because it caused the Windows version to lock up.

I spent a lot of time tracking this down, as did Curt Hibbs (and perhaps
others), but was never able to really identify what caused the lock-up.
After a much-needed break, I decided to revisit the issue this morning.
So I first checked out the latest CVS version of Ruby (now at 1.7.3) and
built and installed that. Then I checked out FXRuby and built that
against this Ruby. And then I tried to run the “groupbox.rb” example
(after uncommenting the bit that creates a thread)… and it worked.

I haven’t changed anything in FXRuby to “fix” this because, as far as I
could tell, there was nothing to “fix”. I can only assume that
something has changed in Ruby 1.7 – say, within the last month –
that made the problem go away. I’m scouring the ChangeLog to try to
figure it out, because I’m awfully curious; I sure don’t want anyone to
"fix it back" :wink:

Does anyone who’s working on the core have an idea of why this has
suddenly started working? And if so, is it something that can be easily
back-ported to Ruby 1.6?

TIA,

Lyle

(… replying to myself …)

I would bet that Nobu’s changes (made around August 19) related to
structured exception handling (SEH) have something to do with this.

Lyle Johnson wrote:

Does anyone who’s working on the core have an idea of why this has
suddenly started working? And if so, is it something that can be
easily back-ported to Ruby 1.6?

Yes, this fix has been back-ported to the Ruby 1.6 CVS branch (just
confirmed this). And the currently available FXRuby installer for Ruby
1.6 works as-is with the CVS version of Ruby 1.6.

Just curious (and confused), I’ve seen 1.7.3 mentioned a couple of times
recently - Ruby home page still says 1.7.2. Since 1.7.2 isn’t actually a
tagged version yet, it’s just reference to the latest, I thought I might see
a 1.7.2 tag in cvs now, assuming 1.7.3 to be the new latest - but I don’t
see a 1.7.2 tag. Is there really a 1.7.3? Or are we still at 1.7.2 (which is
the, IMO, confusing reference to ‘the latest’).

Chris

···

----- Original Message -----
From: “Lyle Johnson” lyle@knology.net
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, August 29, 2002 1:13 PM
Subject: FXRuby Threading Problem Solved?

So I first checked out the latest CVS version of Ruby (now at 1.7.3) and

----- Original Message -----
From: “Rich Kilmer” rich@infoether.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, August 29, 2002 11:04 PM
Subject: Problems building mysql library on 1.7.3 on win32

Cool and cool!

It also makes our FreeRIDE code run under Win32 :slight_smile:

-rich

···

-----Original Message-----
From: Lyle Johnson [mailto:lyle@knology.net]
Sent: Thursday, August 29, 2002 4:34 PM
To: ruby-talk ML
Subject: Re: FXRuby Threading Problem Solved?

Lyle Johnson wrote:

Does anyone who’s working on the core have an idea of why this has
suddenly started working? And if so, is it something that can be
easily back-ported to Ruby 1.6?

Yes, this fix has been back-ported to the Ruby 1.6 CVS branch (just
confirmed this). And the currently available FXRuby installer
for Ruby
1.6 works as-is with the CVS version of Ruby 1.6.

Hi,

···

At Fri, 30 Aug 2002 03:13:22 +0900, Lyle Johnson wrote:

(… replying to myself …)

I would bet that Nobu’s changes (made around August 19) related to
structured exception handling (SEH) have something to do with this.

It was identified and suggested by Tietew.


Nobu Nakada

When you check out of CVS and build the version is reported in Ruby as
1.7.3

···

-----Original Message-----
From: Chris Morris [mailto:chrismo@clabs.org]
Sent: Friday, August 30, 2002 9:43 AM
To: ruby-talk ML
Subject: Ruby at 1.7.3?

Just curious (and confused), I’ve seen 1.7.3 mentioned a
couple of times recently - Ruby home page still says 1.7.2.
Since 1.7.2 isn’t actually a tagged version yet, it’s just
reference to the latest, I thought I might see a 1.7.2 tag in
cvs now, assuming 1.7.3 to be the new latest - but I don’t
see a 1.7.2 tag. Is there really a 1.7.3? Or are we still at
1.7.2 (which is the, IMO, confusing reference to ‘the latest’).

Chris

----- Original Message -----
From: “Lyle Johnson” lyle@knology.net
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, August 29, 2002 1:13 PM
Subject: FXRuby Threading Problem Solved?

So I first checked out the latest CVS version of Ruby (now
at 1.7.3)
and

----- Original Message -----
From: “Rich Kilmer” rich@infoether.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, August 29, 2002 11:04 PM
Subject: Problems building mysql library on 1.7.3 on win32

Just curious (and confused), I've seen 1.7.3 mentioned a couple of times
recently - Ruby home page still says 1.7.2. Since 1.7.2 isn't actually a
tagged version yet, it's just reference to the latest, I thought I might see
a 1.7.2 tag in cvs now, assuming 1.7.3 to be the new latest - but I don't
see a 1.7.2 tag. Is there really a 1.7.3? Or are we still at 1.7.2 (which is
the, IMO, confusing reference to 'the latest').

Apparently 7.3

pigeon% ruby -v
ruby 1.7.3 (2002-08-30) [i686-linux]
pigeon%

but ruby don't seems to like it

socket.c: In function `sock_s_getnameinfo':
socket.c:2294: parse error before `=='

Guy Decoux

Chris Morris wrote:

Just curious (and confused), I’ve seen 1.7.3 mentioned a couple of times
recently - Ruby home page still says 1.7.2. Since 1.7.2 isn’t actually a
tagged version yet, it’s just reference to the latest, I thought I might see
a 1.7.2 tag in cvs now, assuming 1.7.3 to be the new latest - but I don’t
see a 1.7.2 tag. Is there really a 1.7.3? Or are we still at 1.7.2 (which is
the, IMO, confusing reference to ‘the latest’).

This surprised me too. The version number was definitely bumped up to
1.7.3 just a few days ago (around the 27th?), but version 1.7.2 was
never tagged in the CVS repository. The change in version numbers also
isn’t acknowledged in the ChangeLog and so it’s unclear what (if any)
significance it has.

OK. Many thanks to Tietew for identifying the problem!

···

nobu.nokada@softhome.net wrote:

Hi,

At Fri, 30 Aug 2002 03:13:22 +0900, >Lyle Johnson wrote:

(… replying to myself …)

I would bet that Nobu’s changes (made around August 19) related to
structured exception handling (SEH) have something to do with this.

It was identified and suggested by Tietew.

When you check out of CVS and build the version is reported in Ruby as
1.7.3

D’oh! … thanks, that would be a good place to check. :slight_smile:

Chris

Lyle Johnson wrote:

OK. Many thanks to Tietew for identifying the problem!

I just tested FreeRIDE (which suffered from the Threading problem under
Windows) with both of the latest versions of Andy’s Windows Installers:
1.6.7-4 and 1.7.2-4 downloaded from:

http://rubygarden.com/ruby?WindowsInstaller

FreeRIDE runs perfectly with both builds! Thanks, Andy!

Curt

Curt Hibbs wrote:

I just tested FreeRIDE (which suffered from the Threading problem under
Windows) with both of the latest versions of Andy’s Windows Installers:
1.6.7-4 and 1.7.2-4 downloaded from:

http://rubygarden.com/ruby?WindowsInstaller

FreeRIDE runs perfectly with both builds! Thanks, Andy!

Looks like I jumped the gun on this one.

Other programs that exhibited the threading bug still fail under these two
Ruby versions. Why I can get FreeRIDE to run with them is a mystery to me.

Curt

Hi,

···

At Fri, 30 Aug 2002 23:20:39 +0900, Curt Hibbs wrote:

Other programs that exhibited the threading bug still fail under these two
Ruby versions. Why I can get FreeRIDE to run with them is a mystery to me.

Could you explain about that bug in detail?


Nobu Nakada