Bug #7635

debug_inspector API segfaults when opened from inside an eval frame

Added by Charlie Somerville over 1 year ago. Updated about 1 year ago.

[ruby-core:51192]
Status:Closed
Priority:High
Assignee:Koichi Sasada
Category:core
Target version:2.0.0
ruby -v:ruby 2.0.0dev (2012-12-29 trunk 38656) [x86_64-darwin11.4.0] Backport:

Description

=begin

(({rbdebuginspector_open})) segfaults when it is called from inside an eval frame.

Using this C extension:

#include "ruby/ruby.h"

static VALUE
cb()
{
return Qnil;
}

static VALUE
debuginspector()
{
return rb
debuginspectoropen(cb, NULL);
}

void
Initdebuginspector()
{
rbdefineglobalfunction("debuginspector", debug_inspector, 0);
}

Calling (({debug_inspector})) from the top level and from within methods works fine, calling inside eval from the top level works fine, but calling inside eval from within a method segfaults.

Here is a test program that segfaults:

require "./debug_inspector" # the c extension above

def x
eval "debug_inspector"
end

x

=end

Associated revisions

Revision 38970
Added by Koichi Sasada about 1 year ago

  • vmbacktrace.c: fix issue of rbdebuginspectoropen(). The order of making binding should be stack (frame) top to bottom. [Bug #7635] And also fix issue of collecting klass. Collecting klass is same as TracePoint#definedclass. (previous version, it returns TICLASS (internal objects).
  • test/-ext-/debug/test_debug.rb: add a test.
  • ext/-test-/debug/extconf.rb, init.c, inspector.c: ditto.
  • vmbacktrace.c: remove magic number and add enum CALLERBINDING_*.
  • vmbacktrace.c, include/ruby/debug.h: add new C api (experimental) rbdebuginspectorframeselfget().
  • vm.c, vmcore.h, vmtrace.c: move decl. of rbvmcontrolframeidandclass() and constify first parameter.

History

#1 Updated by Koichi Sasada about 1 year ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to Koichi Sasada
  • Priority changed from Normal to High
  • Target version set to 2.0.0

Ah.. I missed this ticket.

#2 Updated by Koichi Sasada about 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38970.
Charlie, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • vmbacktrace.c: fix issue of rbdebuginspectoropen(). The order of making binding should be stack (frame) top to bottom. [Bug #7635] And also fix issue of collecting klass. Collecting klass is same as TracePoint#definedclass. (previous version, it returns TICLASS (internal objects).
  • test/-ext-/debug/test_debug.rb: add a test.
  • ext/-test-/debug/extconf.rb, init.c, inspector.c: ditto.
  • vmbacktrace.c: remove magic number and add enum CALLERBINDING_*.
  • vmbacktrace.c, include/ruby/debug.h: add new C api (experimental) rbdebuginspectorframeselfget().
  • vm.c, vmcore.h, vmtrace.c: move decl. of rbvmcontrolframeidandclass() and constify first parameter.

Also available in: Atom PDF