ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: stefano.tortarolo@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:69940] [Ruby trunk - Bug #9115] Logger traps all exceptions; breaks Timeout
Date: Fri, 10 Jul 2015 15:36:18 +0000	[thread overview]
Message-ID: <redmine.journal-53367.20150710153616.3a331d0d0395eae6@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-9115.20131116123025@ruby-lang.org

Issue #9115 has been updated by Stefano Tortarolo.


I confirm that this bug is reproducible up to 2.2 and it's pretty easy to trigger.

~~~
require 'timeout'
require 'logger'

class MyExc < RuntimeError; end

def long_call(logger)
  Timeout.timeout(3, MyExc) do
    a = 1
    loop do
      a += 1
      logger.warn "Test #{a}"
    end
  end
end
~~~

Aaron Stone is right though that using 2.1+ it would work if you don't provide a custom exception or if your exception inherits from TimeoutError.

Beware that it must inherit from Object::TimeoutError and not Timeout::Error.

Having said that, it'd be nice to have a proper fix at logger.rb level.

@Bill, I don't think your code would fix it though, because the underlying device might throw a different exception.

----------------------------------------
Bug #9115: Logger traps all exceptions; breaks Timeout
https://bugs.ruby-lang.org/issues/9115#change-53367

* Author: Chris Phoenix
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN
----------------------------------------
Line 577-579 of logger.rb

      rescue Exception => ignored
        warn("log writing failed. #{ignored}")
      end

Thus, when the system times out in the middle of writing a log message, it warns "log writing failed. execution expired" and just keeps right on running.

This is true in 1.9.3 as well. I haven't looked at older versions.

Pardon me while I go grep "rescue Exception" in the entire Ruby codebase, and see whether I can reliably use Timeout at all...

OK, you might check out C:\Ruby200\lib\ruby\gems\2.0.0\gems\activerecord-3.2.13\lib\active_record\railties\databases.rake

All the other "rescue Exception" seem to re-raise it, except maybe C:\Ruby200\lib\ruby\2.0.0\xmlrpc\server.rb and C:\Ruby200\lib\ruby\gems\2.0.0\gems\activesupport-3.2.13\lib\active_support\callbacks.rb





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

  parent reply	other threads:[~2015-07-10 15:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-16  3:30 [ruby-core:58374] [ruby-trunk - Bug #9115][Open] Logger traps all exceptions; breaks Timeout cphoenix (Chris Phoenix)
2013-11-16 23:57 ` [ruby-core:58385] [ruby-trunk - Bug #9115] " cphoenix (Chris Phoenix)
2014-08-13  8:28 ` [ruby-core:64346] " aaron
2014-09-03 19:40 ` [ruby-core:64753] " billpaulson
2015-07-10 15:36 ` stefano.tortarolo [this message]
2015-07-15 16:11 ` [ruby-core:69979] [Ruby trunk " stefano.tortarolo
2019-08-16 16:18 ` [ruby-core:94391] [Ruby master Bug#9115] " merch-redmine
2019-08-17  0:10 ` [ruby-core:94393] " samuel
2019-08-20  6:45 ` [ruby-core:94443] " naruse
2019-08-20 12:47 ` [ruby-core:94445] " naruse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-53367.20150710153616.3a331d0d0395eae6@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).