serious bug in ruby 1.8 when threads are enabled. Please upgrade to 1.8.3-1 !

Bug #23586 reported by Lucas Nussbaum on 2005-10-09
8
Affects Status Importance Assigned to Milestone
ruby1.8 (Debian)
Fix Released
Unknown
ruby1.8 (Ubuntu)
Medium
Unassigned

Bug Description

I'd like to point out that Debian bug #322346 is very annoying and makes lots of
Ruby scripts unusable in Breezy. The bug is fixed in Debian package 1.8.3-1.
Could you please consider upgrading breezy's version to this one, or at least
provide it through breezy-updates ?

CVE References

On Wed, Aug 17, 2005 at 04:20:52AM +0900, Paul van Tilburg wrote:
> Hey all,
>
> I am using ruby1.8 from Debian unstable, which seems to be Ruby 1.8.2
> with some patches from CVS (ruby -v already returns 1.8.3). I am
> experiencing some problems with exceptions in Threads since a few
> days/weeks. They all seem to be converted to a TypeError, which makes
> debugging very hard for the app I am working on.

The example you provided in your bug report (reproduced below for the record)
seems to work fine after reverting part of the changes in revision 1.616.2.101
of eval.c:

Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.616.2.117
diff -p -u -r1.616.2.117 eval.c
--- eval.c 16 Aug 2005 03:43:11 -0000 1.616.2.117
+++ eval.c 16 Aug 2005 22:38:44 -0000
@@ -1378,8 +1378,9 @@ static int
 sysexit_status(err)
     VALUE err;
 {
- VALUE st = rb_iv_get(err, "status");
- return NUM2INT(st);
+ VALUE st = rb_attr_get(err, rb_intern("status"));
+
+ return NIL_P(st) ? EXIT_FAILURE : NUM2INT(st);
 }

 static int
@@ -10070,6 +10071,7 @@ rb_thread_switch(n)
       case RESTORE_EXIT:
  ruby_errinfo = th_raise_exception;
  ruby_current_node = th_raise_node;
+ error_print();
  terminate_process(sysexit_status(ruby_errinfo), 0, 0);
  break;
       case RESTORE_NORMAL:

batsman@tux-chan:~/src/ruby/ruby1.8$ cat fail.rb
Thread.abort_on_exception = true
Thread.new { p foo }
batsman@tux-chan:~/src/ruby/ruby1.8$ ./ruby -v fail.rb
ruby 1.8.3 (2005-08-16) [i686-linux]
fail.rb:2: undefined local variable or method `foo' for main:Object (NameError)
        from fail.rb:2

--
Mauricio Fernandez

Download full text (6.5 KiB)

Source: ruby1.8
Source-Version: 1.8.3-1

We believe that the bug you reported is fixed in the latest version of
ruby1.8, which is due to be installed in the Debian FTP archive:

irb1.8_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/irb1.8_1.8.3-1_all.deb
libdbm-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libdbm-ruby1.8_1.8.3-1_i386.deb
libgdbm-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libgdbm-ruby1.8_1.8.3-1_i386.deb
libopenssl-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libopenssl-ruby1.8_1.8.3-1_i386.deb
libreadline-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libreadline-ruby1.8_1.8.3-1_i386.deb
libruby1.8-dbg_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libruby1.8-dbg_1.8.3-1_i386.deb
libruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libruby1.8_1.8.3-1_i386.deb
libtcltk-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libtcltk-ruby1.8_1.8.3-1_i386.deb
rdoc1.8_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/rdoc1.8_1.8.3-1_all.deb
ri1.8_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/ri1.8_1.8.3-1_all.deb
ruby1.8-dev_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/ruby1.8-dev_1.8.3-1_i386.deb
ruby1.8-elisp_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/ruby1.8-elisp_1.8.3-1_all.deb
ruby1.8-examples_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/ruby1.8-examples_1.8.3-1_all.deb
ruby1.8_1.8.3-1.diff.gz
  to pool/main/r/ruby1.8/ruby1.8_1.8.3-1.diff.gz
ruby1.8_1.8.3-1.dsc
  to pool/main/r/ruby1.8/ruby1.8_1.8.3-1.dsc
ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/ruby1.8_1.8.3-1_i386.deb
ruby1.8_1.8.3.orig.tar.gz
  to pool/main/r/ruby1.8/ruby1.8_1.8.3.orig.tar.gz

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to <email address hidden>,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
akira yamada <email address hidden> (supplier of updated ruby1.8 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing <email address hidden>)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Wed, 21 Sep 2005 12:43:50 +0900
Source: ruby1.8
Binary: libtcltk-ruby1.8 libruby1.8-dbg rdoc1.8 libgdbm-ruby1.8 ruby1.8-dev ruby1.8-elisp ruby1.8-examples libdbm-ruby1.8 irb1.8 ruby1.8 libreadline-ruby1.8 libopenssl-ruby1.8 libruby1.8 ri1.8
Architecture: source i386 all
Version: 1.8.3-1
Distribution: unstable
Urgency: high
Maintainer: akira yamada <email address hidden>
Changed-By: akira yamada <email address hidden>
Description:
 irb1.8 - Interactive Ruby (for Ruby 1.8)
 libdbm-ruby1.8 - DBM interface for Ruby 1.8
 libgdbm-ruby1.8 - GDBM interface for Ruby 1.8
 libopenssl-ruby1.8 - OpenSSL interface for Ruby 1.8
 libreadline-ruby1.8 - Readline interface for Ruby 1.8
 libruby1.8 - Libraries necessary to run Ruby 1.8
 libruby1.8-dbg - Debugging libraries for Ruby 1.8
 libtcltk-ruby1.8 - Tcl/Tk interface for Ruby 1.8
 rdoc1.8 - Generate documentation from Ruby source files (for Ruby 1.8)
 ri1.8 - Ruby Interactive reference (for Ruby 1.8)
 ruby1.8 - Inte...

Read more...

Lucas Nussbaum (lucas) wrote :

I'd like to point out that Debian bug #322346 is very annoying and makes lots of
Ruby scripts unusable in Breezy. The bug is fixed in Debian package 1.8.3-1.
Could you please consider upgrading breezy's version to this one, or at least
provide it through breezy-updates ?

Lucas Nussbaum (lucas) wrote :

Ruby 1.8.3 has security fixes too (see bug:17289). It would greatly benefit
breezy to upgrade ruby...

Matt Zimmerman (mdz) wrote :

We are too close to the final release of Ubuntu to consider updating ruby; many
packages use it and there is insufficient time to regression-test them.

Debian Bug Importer (debzilla) wrote :

Message-Id: <email address hidden>
Date: Wed, 10 Aug 2005 12:28:08 +0200
From: Paul van Tilburg <email address hidden>
To: Debian Bug Tracking System <email address hidden>
Subject: ruby1.8: Exceptions in threads all get converted to a TypeError

Package: ruby1.8
Version: 1.8.2-9
Severity: normal
Tags: sid

When "abort_on_exception" for Thread is set to true, exceptions get
transformed to a TypeError with the same message everytime regardless what
the original exception was. This makes it very hard to debug programs
using threads. This problems only occurs with Ruby 1.8.3 (or this is the
version ruby1.8 in sid reports):

In sarge:
---
irb(main):001:0> Thread.abort_on_exception = true
=> true
irb(main):002:0> Thread.new { p foo }
(irb):2:in `irb_binding': undefined local variable or method `foo' for main:Object (NameError)
        from (irb):2:in `initialize'
        from (irb):2:in `new'
        [...]
---

In sid:
---
irb(main):001:0> Thread.abort_on_exception = true
=> true
irb(main):002:0> Thread.new { p foo }
TypeError: no implicit conversion from nil to integer
        from (irb):2:in `initialize'
        from (irb):2
irb(main):003:0> Thread.new { 10 / 0 }
TypeError: no implicit conversion from nil to integer
        from (irb):3:in `initialize'
        from (irb):3
---

Greetings,

Paul

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-686
Locale: LANG=C, LC_CTYPE=nl_NL.UTF8@euro (charmap=UTF-8)

Versions of packages ruby1.8 depends on:
ii libc6 2.3.5-3 GNU C Library: Shared libraries an
ii libruby1.8 1.8.2-9 Libraries necessary to run Ruby 1.

ruby1.8 recommends no packages.

-- no debconf information

Debian Bug Importer (debzilla) wrote :

Message-ID: <20050816224240.GC4389@tux-chan>
Date: Wed, 17 Aug 2005 00:42:40 +0200
From: Mauricio Fernandez <email address hidden>
To: <email address hidden>
Cc: <email address hidden>, <email address hidden>
Subject: Re: Exceptions in threads all get converted to a TypeError

On Wed, Aug 17, 2005 at 04:20:52AM +0900, Paul van Tilburg wrote:
> Hey all,
>
> I am using ruby1.8 from Debian unstable, which seems to be Ruby 1.8.2
> with some patches from CVS (ruby -v already returns 1.8.3). I am
> experiencing some problems with exceptions in Threads since a few
> days/weeks. They all seem to be converted to a TypeError, which makes
> debugging very hard for the app I am working on.

The example you provided in your bug report (reproduced below for the record)
seems to work fine after reverting part of the changes in revision 1.616.2.101
of eval.c:

Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.616.2.117
diff -p -u -r1.616.2.117 eval.c
--- eval.c 16 Aug 2005 03:43:11 -0000 1.616.2.117
+++ eval.c 16 Aug 2005 22:38:44 -0000
@@ -1378,8 +1378,9 @@ static int
 sysexit_status(err)
     VALUE err;
 {
- VALUE st = rb_iv_get(err, "status");
- return NUM2INT(st);
+ VALUE st = rb_attr_get(err, rb_intern("status"));
+
+ return NIL_P(st) ? EXIT_FAILURE : NUM2INT(st);
 }

 static int
@@ -10070,6 +10071,7 @@ rb_thread_switch(n)
       case RESTORE_EXIT:
  ruby_errinfo = th_raise_exception;
  ruby_current_node = th_raise_node;
+ error_print();
  terminate_process(sysexit_status(ruby_errinfo), 0, 0);
  break;
       case RESTORE_NORMAL:

batsman@tux-chan:~/src/ruby/ruby1.8$ cat fail.rb
Thread.abort_on_exception = true
Thread.new { p foo }
batsman@tux-chan:~/src/ruby/ruby1.8$ ./ruby -v fail.rb
ruby 1.8.3 (2005-08-16) [i686-linux]
fail.rb:2: undefined local variable or method `foo' for main:Object (NameError)
        from fail.rb:2

--
Mauricio Fernandez

Debian Bug Importer (debzilla) wrote :
Download full text (6.7 KiB)

Message-Id: <email address hidden>
Date: Tue, 20 Sep 2005 21:47:14 -0700
From: akira yamada <email address hidden>
To: <email address hidden>
Subject: Bug#322346: fixed in ruby1.8 1.8.3-1

Source: ruby1.8
Source-Version: 1.8.3-1

We believe that the bug you reported is fixed in the latest version of
ruby1.8, which is due to be installed in the Debian FTP archive:

irb1.8_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/irb1.8_1.8.3-1_all.deb
libdbm-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libdbm-ruby1.8_1.8.3-1_i386.deb
libgdbm-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libgdbm-ruby1.8_1.8.3-1_i386.deb
libopenssl-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libopenssl-ruby1.8_1.8.3-1_i386.deb
libreadline-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libreadline-ruby1.8_1.8.3-1_i386.deb
libruby1.8-dbg_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libruby1.8-dbg_1.8.3-1_i386.deb
libruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libruby1.8_1.8.3-1_i386.deb
libtcltk-ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/libtcltk-ruby1.8_1.8.3-1_i386.deb
rdoc1.8_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/rdoc1.8_1.8.3-1_all.deb
ri1.8_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/ri1.8_1.8.3-1_all.deb
ruby1.8-dev_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/ruby1.8-dev_1.8.3-1_i386.deb
ruby1.8-elisp_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/ruby1.8-elisp_1.8.3-1_all.deb
ruby1.8-examples_1.8.3-1_all.deb
  to pool/main/r/ruby1.8/ruby1.8-examples_1.8.3-1_all.deb
ruby1.8_1.8.3-1.diff.gz
  to pool/main/r/ruby1.8/ruby1.8_1.8.3-1.diff.gz
ruby1.8_1.8.3-1.dsc
  to pool/main/r/ruby1.8/ruby1.8_1.8.3-1.dsc
ruby1.8_1.8.3-1_i386.deb
  to pool/main/r/ruby1.8/ruby1.8_1.8.3-1_i386.deb
ruby1.8_1.8.3.orig.tar.gz
  to pool/main/r/ruby1.8/ruby1.8_1.8.3.orig.tar.gz

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to <email address hidden>,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
akira yamada <email address hidden> (supplier of updated ruby1.8 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing <email address hidden>)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Wed, 21 Sep 2005 12:43:50 +0900
Source: ruby1.8
Binary: libtcltk-ruby1.8 libruby1.8-dbg rdoc1.8 libgdbm-ruby1.8 ruby1.8-dev ruby1.8-elisp ruby1.8-examples libdbm-ruby1.8 irb1.8 ruby1.8 libreadline-ruby1.8 libopenssl-ruby1.8 libruby1.8 ri1.8
Architecture: source i386 all
Version: 1.8.3-1
Distribution: unstable
Urgency: high
Maintainer: akira yamada <email address hidden>
Changed-By: akira yamada <email address hidden>
Description:
 irb1.8 - Interactive Ruby (for Ruby 1.8)
 libdbm-ruby1.8 - DBM interface for Ruby 1.8
 libgdbm-ruby1.8 - GDBM interface for Ruby 1.8
 libopenssl-ruby1.8 - OpenSSL interface for Ruby 1.8
 libreadline-ruby1.8 - Readline interface for Ruby 1.8
 libruby1.8 - Libraries necessary to run Ruby 1.8
 libruby1.8-dbg - Debugging libraries for Rub...

Read more...

Paulus (donmatteo) wrote :

I'd like to confirm that this bug ended up in breezy final. When setting "abort_on_exception = true", exceptions in child
threads are reported as "TypeError: no implicit conversion from nil to integer" in "initialize" at bogus line numbers. This
bug renders the task of debugging threaded application difficult, if not impossible.

It looks as though the fix is quite simple (see the debian bug). Wouldn't this be a candidate for a breezy update?

Lucas Nussbaum (lucas) wrote :

This has been fixed in Dapper but won't be fixed in Breezy. Marking Rejected.

Changed in ruby1.8:
status: Unconfirmed → Rejected
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.