List Info

Thread: segfault on Proc#call after setting a trace_func




segfault on Proc#call after setting a trace_func
user name
2006-05-06 10:33:43
$ cat bug2.rb 
set_trace_func proc{}
l = lambda{}
l.call
$ ruby19 bug2.rb 
bug2.rb:3: [BUG] Segmentation fault
ruby 1.9.0 (2006-05-01) [i686-linux]

Aborted

[ruby-talk:191639]

-- 
Mauricio Fernandez  -   http://eigenclass.org   - 
singular Ruby

segfault on Proc#call after setting a trace_func
user name
2006-05-06 11:59:06
>>>>> "M" == Mauricio Fernandez
<mfpacm.org> writes:

M> l.call

 Not sure, but it seems to be in proc_invoke()

    /* modify current frame */
    ruby_frame->block = &_block;
    PUSH_TAG((pcall&YIELD_LAMBDA_CALL) ? PROT_LAMBDA :
PROT_NONE);
    state = EXEC_TAG();
    if (state == 0) {
	proc_set_safe_level(proc);
	result = rb_yield_0(args, self,
(self!=Qundef)?CLASS_OF(self):0,
			    pcall | YIELD_PROC_CALL, avalue);
    }
    else if (TAG_DST()) {
	result = prot_tag->retval;
    }
    POP_TAG();
    ruby_wrapper = old_wrapper;
    POP_VARS();


 Unfortunately the old block (ruby_frame->block) is never
restored when
 ruby leave proc_invoke()

 Now when it call call_trace_func()

    PUSH_TAG(PROT_NONE);


 will create a 'struct tag'  which "overlap"
with the variable _block (which
 is out of scope because ruby has leaved proc_invoke()) and
this is at
 this step that it erase some fields in the struct BLOCK and
it crash when
 it try a call to rb_f_binding()


Guy Decoux

segfault on Proc#call after setting a trace_func
user name
2006-05-06 14:42:56
Hi,

In message "Re: [BUG] segfault on Proc#call after
setting a trace_func"
    on Sat, 6 May 2006 20:59:06 +0900, ts <decouxmoulon.inra.fr> writes:

|M> l.call
|
| Not sure, but it seems to be in proc_invoke()
|
|    /* modify current frame */
|    ruby_frame->block = &_block;

| Unfortunately the old block (ruby_frame->block) is
never restored when
| ruby leave proc_invoke()

That's it.  Thank you.  Here's the patch to fix this.

							matz.

--- eval.c	23 Feb 2006 04:24:39 -0000	1.890
+++ eval.c	6 May 2006 14:41:49 -0000
 -8266,3
+8243,3  proc_invoke(VALUE proc, VALUE args /* OK
     struct BLOCK _block;
-    struct BLOCK *data;
+    struct BLOCK *data, *old_block;
     volatile VALUE result = Qundef;
 -8304,2
+8277,3  proc_invoke(VALUE proc, VALUE args /* OK
     /* modify current frame */
+    old_block = ruby_frame->block;
     ruby_frame->block = &_block;
 -8316,2
+8290,3  proc_invoke(VALUE proc, VALUE args /* OK
     POP_TAG();
+    ruby_frame->block = old_block;
     ruby_wrapper = old_wrapper;

segfault on Proc#call after setting a trace_func
user name
2006-05-19 15:56:16
Hi,

At Sat, 6 May 2006 23:42:56 +0900,
Yukihiro Matsumoto wrote in [ruby-core:07835]:
> | Unfortunately the old block (ruby_frame->block) is
never restored when
> | ruby leave proc_invoke()
> 
> That's it.  Thank you.  Here's the patch to fix this.

what state is this patch?

-- 
Nobu Nakada

segfault on Proc#call after setting a trace_func
user name
2006-05-20 06:20:27
Hi,

In message "Re: [BUG] segfault on Proc#call after
setting a trace_func"
    on Sat, 20 May 2006 00:56:16 +0900, noburuby-lang.org writes:

|> That's it.  Thank you.  Here's the patch to fix
this.
|
|what state is this patch?

Applied to the local copy of the repository.  Waiting to be
committed.

							matz.

segfault on Proc#call after setting a trace_func
user name
2006-05-27 13:50:36
Hi,

At Sat, 20 May 2006 15:20:27 +0900,
Yukihiro Matsumoto wrote in [ruby-core:07912]:
> Applied to the local copy of the repository.  Waiting
to be
> committed.

OK, committed, with volatile modifier as older versions.

-- 
Nobu Nakada

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )