[#28561] Ruby::DL vs Ruby::FFI — Aston <blackapache512-ticket@...>

Ruby.DL and FFI libraries are great for programmers like me who are not internet programmers, but are more interested in scientific and number processing etc.

11 messages 2010/03/08

[#28686] trunk (26947) build fail with msys/mingw/vista — Jon <jon.forums@...>

I get the following build failure when msysgit's "c:\git\cmd" dir is on PATH.

8 messages 2010/03/16

[#28687] [Bug #2973] rb_bug - Segmentation fault - error.c:213 — rudolf gavlas <redmine@...>

Bug #2973: rb_bug - Segmentation fault - error.c:213

10 messages 2010/03/16

[#28735] [Bug #2982] Ruby tries to link with both openssl and readline — Lucas Nussbaum <redmine@...>

Bug #2982: Ruby tries to link with both openssl and readline

16 messages 2010/03/18

[#28736] [Bug #2983] Ruby (GPLv2 only) tries to link to with readline (now GPLv3) — Lucas Nussbaum <redmine@...>

Bug #2983: Ruby (GPLv2 only) tries to link to with readline (now GPLv3)

10 messages 2010/03/18

[#28907] [Bug #3000] Open SSL Segfaults — Christian Höltje <redmine@...>

Bug #3000: Open SSL Segfaults

19 messages 2010/03/23

[#28924] [Bug #3005] Ruby core dump - [BUG] rb_sys_fail() - errno == 0 — Sebastian YEPES <redmine@...>

Bug #3005: Ruby core dump - [BUG] rb_sys_fail() - errno == 0

10 messages 2010/03/24

[#28954] [Feature #3010] slow require gems in ruby 1.9.1 — Miao Jiang <redmine@...>

Feature #3010: slow require gems in ruby 1.9.1

15 messages 2010/03/24

[#29179] [Bug #3071] Convert rubygems and rdoc to use psych — Aaron Patterson <redmine@...>

Bug #3071: Convert rubygems and rdoc to use psych

10 messages 2010/03/31

[ruby-core:28730] Re: When a trace hook raises an exception, should it terminate the program?

From: Charles Oliver Nutter <headius@...>
Date: 2010-03-18 05:59:36 UTC
List: ruby-core #28730
On Wed, Mar 17, 2010 at 5:42 AM, Rocky Bernstein <rockyb@rubyforge.org> wrote:
> In Ruby 1.8 and the Ruby 1.9 trunk when running a trace hook that raises an
> exception not caught by the hook, the program terminates -- whether or not
> there is a rescue further up the call stack, i.e. in the non-hook body.
>
> Ruby 1.9 also gives a stack trace, while Ruby 1.8 doesn't.

This is a pretty peculiar situation. What *should* happen? With the
hook set, if it starts raising exceptions, you start getting errors
happening not in particular methods but in the "inbetween" space
between method calls and lines and pretty much everything. In your
example, even if it rescues, it would hit a c-call event (for the
puts) and raise again before printing anything out.

Perhaps the specification could say that a ruby-land set_trace_func is
wrapped with an implicit rescue and disabled if an error is raised? Or
something?

> How do JRuby, IronRuby and Rubinius and other Rubies handle this? And what
> do the specifications say?

JRuby also terminates. Note that the trace output is slightly
different, since we have different call sequences for some things:

~/projects/jruby ➔ jruby --debug hook_thing.rb
line  :8 (the first event that fires after the hook is set)
c-call === :8 (this is the rescue calling ===)
c-call backtrace :1 (this is the toplevel of JRuby trying to get the backtrace)
c-call first :1 (fallback code because backtrace errored too?)
Exception in thread "main" c-call first :1 (finally, we give up)

There's so many calls and line events happening here, it's pretty much
impossible for anything good to come out of it. Catastrophic failure.

As for other Rubies...I don't know if IronRuby supports
set_trace_func, but Rubinius and MacRuby do not.

> If it is the case that raising an exception in a trace hook unconditionally
> terminates the hooked program, programmers that want to write a trace hook
> that plays nice with programs it hooks against should wrap the hook in a
> begin/rescue block. Or make sure your code never raises an uncaught
> exception.

That seems wise.

- Charlie

In This Thread