Project

General

Profile

Feature #16090

RUBY_ON_BUG envval to debug

Added by ko1 (Koichi Sasada) about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:94216]

Description

How about to introduce RUBY_ON_BUG environment variable which specify the command launched at rb_bug()?

RUBY_ON_BUG='gdb -p' ruby ...

In this case, gdb -p [PID] is invoked when rb_bug() is called.
after that, we can spy the interpreter with gdb.

https://github.com/ruby/ruby/pull/2331

On my patch, it is limited to RUBY_DEVEL build.

Security risk

I'm not a professional about security, but it can introduce new security risk.
Comments are welcome.
This is why I made a ticket.

Thanks,
Koichi

Associated revisions

Revision 53a55aef
Added by ko1 (Koichi Sasada) about 1 month ago

introduce RUBY_ON_BUG envval. (#2331)

rb_bug() is called at critical bug, MRI can't run anymore.
To make debug easy, this patch introduces RUBY_ON_BUG environment
variable to specify the process which is called with pid.
[Feature #16090] [GH #2331]

RUBY_ON_BUG='gdb -p' ruby xxx.rb

In this case, if ruby interpreter causes critical bug, and call
rb_bug(), then "gdb -p [PID]' is called by system(3). You can
debug on invoked gdb.

This feature is limited on RUBY_DEVEL build.

History

Updated by shevegen (Robert A. Heiler) about 1 month ago

In general I think this is fine (if we don't forget to document it :) ).

It would give people a way to influence the behaviour there, if they need to,
e. g. the example you gave via using "gdb -p". So this is a convenience
feature mostly, the way I see it.

I have two comments, though. The first one you wrote yourself, security issues.

I am not sure what/if security-related issues can arise, so I am not really
qualified to comment. It may help if we could put specifics into this, e. g.
what might be a real issue here (I really don't know).

The other part is the name; I understand the prefix "RUBY_", this is fine
IMO. Makes sense to assume that those prefixed with "RUBY_" should refer
to the programming language ruby.

The part "ON_BUG" is a bit strange. I understand that you refer to the
function rb_bug() (in C I guess). But I still find the name a bit strange;
to be "ON_BUG" implies some conditional such as "on bug, do this". But I
don't have an alternative suggestion and any name could be re-considered
at a later time; or it is not so important anyway, since this is only for
debugging. So I think the functionality itself is fine.

If this is approved and added, I would recommend to also describe the
assumed use cases for it, e. g. "gdb -p" and whether other debuggers can
be used too. Describing these use cases may be helpful for a later time
when the software ecosystem may be different to e. g. 2019.

#2

Updated by ko1 (Koichi Sasada) about 1 month ago

  • Status changed from Open to Closed

Applied in changeset git|53a55aeff3d409b4894d077f2b3b874fac53e387.


introduce RUBY_ON_BUG envval. (#2331)

rb_bug() is called at critical bug, MRI can't run anymore.
To make debug easy, this patch introduces RUBY_ON_BUG environment
variable to specify the process which is called with pid.
[Feature #16090] [GH #2331]

RUBY_ON_BUG='gdb -p' ruby xxx.rb

In this case, if ruby interpreter causes critical bug, and call
rb_bug(), then "gdb -p [PID]' is called by system(3). You can
debug on invoked gdb.

This feature is limited on RUBY_DEVEL build.

Updated by ko1 (Koichi Sasada) about 1 month ago

There is no comment so I pushed this change.

Also available in: Atom PDF