Project

General

Profile

Actions

Bug #7180

closed

set_trace_func with error in proc block locks up Ruby with 100% cpu usage and no way to exit without killing proc

Added by garysweaver (Gary Weaver) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
Backport:
[ruby-core:48053]

Description

Causes 100% cpu usage and cannot ctrl-C to exit (have to kill proc):

set_trace_func proc {|event, file, line, id, binding, classname| raise "error"}

Understand that set_trace_func plays by different rules, but this isn't expected.

Updated by garysweaver (Gary Weaver) over 11 years ago

One workaround:

l = lambda {|event, file, line, id, binding, classname| eval "def invalid syntax"}
set_trace_func proc {|event, file, line, id, binding, classname| begin;l.call(event, file, line, id, binding, classname);rescue SystemExit,Interrupt;raise;rescue Exception;end}

Would it be good to add to the rdoc for set_trace_func to indicate that the user should consider using this method if there is any chance it might raise an Exception other than SystemExit or Interrupt?

Updated by drbrain (Eric Hodel) over 11 years ago

  • Category set to core
  • Status changed from Open to Feedback

=begin
I can't reproduce this. Can you provide a way to reproduce it?

With trunk:

$ time ruby20 -ve 'set_trace_func proc {|event, file, line, id, binding, classname| raise "error"}; loop do 1 + 1 end'
ruby 2.0.0dev (2012-09-06 trunk 36915) [x86_64-darwin12.1.0]
-e:1:in block in <main>': error (RuntimeError) from -e:1:in '

real 0m0.017s
user 0m0.012s
sys 0m0.004s

With ruby 1.9.4-p194 as you are running:

$ time ruby19 -ve 'set_trace_func proc {|event, file, line, id, binding, classname| raise "error"}; loop do 1 + 1 end'
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]
-e:1:in block in <main>': error (RuntimeError) from -e:1:in '

real 0m0.017s
user 0m0.012s
sys 0m0.004s

=end

Updated by mame (Yusuke Endoh) over 11 years ago

  • Target version set to 2.0.0

Gary Weaver, ping?

--
Yusuke Endoh

Updated by mame (Yusuke Endoh) over 11 years ago

  • Priority changed from Normal to 3

Updated by ko1 (Koichi Sasada) over 11 years ago

The following script also repeat "[:return, 1]".
I'm not sure it is same problem or not.

def m
p:m
end

TracePoint.trace(:call, :return){|tp| p [tp.event, tp.line]; raise "bar"}
m

Updated by Anonymous over 11 years ago

This can be reproduced inside eval:

eval 'set_trace_func proc {|event, file, line, id, binding, classname| raise "error"}'

Edit: It seems this can be repro'd whenever there is a parent control frame.

Updated by ko1 (Koichi Sasada) over 11 years ago

  • Status changed from Feedback to Closed
  • Assignee set to ko1 (Koichi Sasada)

Maybe r38331 (nobu's commit) solves this issue.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0