Project

General

Profile

Actions

Bug #17033

closed

Infinite Traceback when encountering an Exception while catching an Exception

Added by NickHackman (Nick Hackman) over 4 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
[ruby-core:99172]

Description

In Ruby 2.7.1 when an Exception occurs and another occurs when handling the first one it results in an infinite Traceback that doesn't mention the error.

class MyException < StandardError
  def initialize(obj)
    @obj = obj
  end

  def to_s
    @obj.to_strm
  end
end

begin
  raise MyException.new('test'), 'message'
rescue StandardError => e
  puts e.to_s
end

In the above instance, there's a typo to_strm doesn't exist for type String, but instead of a normal case of a typo saying that the method doesn't exist the output is

~ λ ruby ruby_traceback_hell.rb
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
...

it keeps going without printing any sort of message about the actual error.

It's expected that this would result in a message saying that the method is undefined, and this is the behavior on 2.5.1, and appears to be a regression in 2.7.1

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0