Issue #6647 has been reported by headius (Charles Nutter). ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647 Author: headius (Charles Nutter) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-06-26 00:22
on 2012-06-26 00:25
Issue #6647 has been updated by headius (Charles Nutter). FWIW, precedent: Java threads log their exceptions by default. I have *never* found the feature to be a bother, and it makes it nearly impossible to ignore fatally-flawed thread logic that spins up and fails lots of threads. ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-27455 Author: headius (Charles Nutter) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-06-26 00:45
Issue #6647 has been updated by rue (Eero Saynatkari). headius (Charles Nutter) wrote: > Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. I have had to set .abort_on_exception more times than I care to remember. > rescue Exception => e > raise if Thread.abort_on_exception || Thread.current.abort_on_exception > puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" > puts e.backtrace.map {|line| " #{line}"} $stderr/warn, but this would improve the current situation significantly. Can significant upgrade problems be expected if .abort_on_exception defaulted to true? This would seem to be the behaviour to suit most users. ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-27456 Author: headius (Charles Nutter) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-06-26 11:00
On 25/06/12 23:44, rue (Eero Saynatkari) wrote: > > Issue #6647 has been updated by rue (Eero Saynatkari). > > > headius (Charles Nutter) wrote: >> Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. > > I have had to set .abort_on_exception more times than I care to remember. Agreed. It's one of the things I check for in code review. Consider this a +1 from me. > >> rescue Exception => e >> raise if Thread.abort_on_exception || Thread.current.abort_on_exception >> puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" >> puts e.backtrace.map {|line| " #{line}"} > > $stderr/warn, but this would improve the current situation significantly. > > Can significant upgrade problems be expected if .abort_on_exception defaulted to true? This would seem to be the behaviour to suit most users. That sounds a little extreme, although I wouldn't object. I'd be happy with them not being silently swallowed. -- Alex
on 2012-06-27 04:12
Alex Young <alex@blackkettle.org> wrote: > On 25/06/12 23:44, rue (Eero Saynatkari) wrote: > >Issue #6647 has been updated by rue (Eero Saynatkari). > > > >$stderr/warn, but this would improve the current situation significantly. > > > >Can significant upgrade problems be expected if .abort_on_exception defaulted to true? This would seem to be the behaviour to suit most users. > > That sounds a little extreme, although I wouldn't object. I'd be > happy with them not being silently swallowed. I think aborting the whole process is extreme (though, I usually do it myself). I would very much like to see this via $stderr/warn, though.
on 2012-06-27 13:27
Issue #6647 has been updated by rue (Eero Saynatkari). normalperson (Eric Wong) wrote: > > I think aborting the whole process is extreme (though, I usually do > it myself). You are probably correct. Reconsidering the issue, the benefit of raising is probably not enough to offset that, thus leaving the $stderr/warn as the better choice. -- Eero ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-27519 Author: headius (Charles Nutter) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-07-14 11:12
Issue #6647 has been updated by nahi (Hiroshi Nakamura). Category set to core Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) Target version set to 2.0.0 Discussions ad CRuby dev meeting at 14th July. * We can understand the requirement. (We understood that the requirement is dumping something without raising when Thread#abort_on_exception = false) * Writing to STDERR could cause problem with existing applications so we should take care about it. * rb_warn() instead of puts would be good because we already using rb_warns. Matz, do you mind if we dump Thread error with rb_warn if Thread#abort_on_exception = false? ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-28068 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-09-10 19:45
Issue #6647 has been updated by headius (Charles Nutter). Any update on this? ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-29234 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-10-14 22:04
Issue #6647 has been updated by headius (Charles Nutter). Ping! This came up in JEG's talk at Aloha RubyConf as a recommendation (specifically, set abort_on_exception globally to ensure failed threads don't quietly disappear). Ruby should not allow threads to quietly fail. ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-30671 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-10-15 04:24
Issue #6647 has been updated by kosaki (Motohiro KOSAKI). I think "exception raised" callback is better way because an ideal output (both format and output device) depend on an application. It should be passed a raised exception. ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-30689 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-10-15 11:20
On 15/10/12 03:24, kosaki (Motohiro KOSAKI) wrote: > > Issue #6647 has been updated by kosaki (Motohiro KOSAKI). > > > I think "exception raised" callback is better way because an ideal output (both format and output device) depend on an application. It should be passed a raised exception. This, along with a sensible default that displays *something* to stderr, would be absolutely ideal from my point of view. -- Alex
on 2012-10-17 20:00
Issue #6647 has been updated by headius (Charles Nutter). I started prototyping a callback version and ran into some complexities I could not easily resolve: * How does abort_on_exception= interact with a callback system? ** I tried implementing abort_on_exception=true to use a builtin callback that raises in Thread.main, but should abort_on_exception=true blow away a previously-set callback? ** Similarly: should abort_on_exception=false reset to a do-nothing callback? ** If neither of these, how do we combine callback and abort_on_exception behavior? * Seems like there should be a Thread.default_exception_handler you can set once for all future threads. My concern is that bikeshedding a callback API -- as useful as it might be -- will cause further delays in the more important behavior of having threads report that they terminated due to an exception. ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-30979 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-10-23 07:24
Issue #6647 has been updated by dafiku (dafi harisy). Everlastingly, an issue with the intention of I am passionate in this vicinity. I be inflicted with looked for in rank of this feature for the last numerous hours. Your locate is greatly valued. http://www.yourhousecontents.com/ http://www.electroscanogram.com/ http://www.videophototravel.info/ http://www.supershinelaundry.com/ http://www.ywor.info/ http://www.bicity.info/ http://www.ubidyne.info/ ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-31313 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-11-16 16:40
Issue #6647 has been updated by headius (Charles Nutter). Ping! ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-32967 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-11-24 18:20
Issue #6647 has been updated by headius (Charles Nutter). Checking in on this again. Can we at least agree it should happen for 2.0.0? Perhaps Matz should review this? ---------------------------------------- Bug #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-33822 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 ruby -v: head Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
on 2012-11-25 01:48
Issue #6647 has been updated by mame (Yusuke Endoh). Target version changed from 2.0.0 to next minor ---------------------------------------- Feature #6647: Exceptions raised in threads should be logged https://bugs.ruby-lang.org/issues/6647#change-33832 Author: headius (Charles Nutter) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor Many applications and users I have dealt with have run into bugs due to Ruby's behavior of quietly swallowing exceptions raised in threads. I believe this is a bug, and threads should always at least log exceptions that bubble all the way out and terminate them. The implementation should be simple, but I'm not yet familiar enough with the MRI codebase to provide a patch. The exception logging should be logged in the same way top-level exceptions get logged, but perhaps with information about the thread that was terminated because of the exception. Here is a monkey patch that simulates what I'm hoping to achieve with this bug: class << Thread alias old_new new def new(*args, &block) old_new(*args) do |*bargs| begin block.call(*bargs) rescue Exception => e raise if Thread.abort_on_exception || Thread.current.abort_on_exception puts "Thread for block #{block.inspect} terminated with exception: #{e.message}" puts e.backtrace.map {|line| " #{line}"} end end end end Thread.new { 1 / 0 }.join puts "After thread" __END__ Output: system ~/projects/jruby $ ruby thread_error.rb Thread for block #<Proc:0x000000010d008a80@thread_error.rb:17> terminated with exception: divided by 0 thread_error.rb:17:in `/' thread_error.rb:17 thread_error.rb:7:in `call' thread_error.rb:7:in `new' thread_error.rb:5:in `initialize' thread_error.rb:5:in `old_new' thread_error.rb:5:in `new' thread_error.rb:17 After thread
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.