[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>

Currently, ruby/spec is maintained mostly by individuals and enjoys the

13 messages 2016/12/13

[ruby-core:78872] [Ruby trunk Bug#13043] Exception#cause can become recursive/infinite

From: usa@...
Date: 2016-12-27 11:39:51 UTC
List: ruby-core #78872
Issue #13043 has been updated by Usaku NAKAMURA.

Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: REQUIRED, 2.2: DONE, 2.3: REQUIRED

ruby_2_2 r57222 merged revision(s) 57137.

----------------------------------------
Bug #13043: Exception#cause can become recursive/infinite
https://bugs.ruby-lang.org/issues/13043#change-62281

* Author: Cody Cutrer
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
* Backport: 2.1: REQUIRED, 2.2: DONE, 2.3: REQUIRED
----------------------------------------
In a certain situation, Exception#cause can become an infinite list:

```ruby
def raise_errors
  begin
    raise "error 1"
  ensure
     orig_error = $!
     begin
       raise "error 2"
     rescue => err
       raise orig_error || err
     end
  end
end

x = nil
begin
  raise_errors
rescue
  x = $!
end

x.cause.cause.object_id == x.object_id
```

Note that this pattern happened during an HTTP request with net/http: see https://github.com/ruby/ruby/blob/v2_3_1/lib/net/http/response.rb#L261.  I would expect that x would be "error 2", x.cause would be "error 1", and x.cause.cause would be nil. Instead an infinite loop forms, breaking error reporting code that loops over an exception's cause



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next