List Info

Thread: Ruby 1.9 "exception reentered"




Ruby 1.9 "exception reentered"
user name
2008-05-27 16:04:26
Hi,

I've made a module that embeds a Ruby interpreter into
S-Lang
(ht
tp://www.cheesit.com/downloads/slang/slruby.html). The
module
worked OK until Ruby 1.9 revision 15996 came out:

r15996 | nobu | 2008-04-14 05:52:27 +0200 (ma, 14 apr 2008)
| 2 lines

* gc.c (Init_stack): use ruby_init_stack.  [ruby-dev:34350]

Now I get this error:

slsh> require("slruby");
Ruby error: fatal: exception reentered
Traceback: rb_load_file

slruby.sl imports the module (it's dynamically loaded) and
then tries
to load itself as a Ruby file using the S-Lang function
rb_load_file(), which calls rb_load_protect().  If I first
import it
and then require slruby.sl, it works sometimes:
slsh> import("ruby");
slsh> require("slruby");
slsh>

Can someone explain what causes this error?


Re: Ruby 1.9 "exception reentered"
user name
2008-06-06 15:23:59
2008/5/27, Paul Boekholt <p.boekholtgmail.com>:
> Hi,
>
>  I've made a module that embeds a Ruby interpreter into
S-Lang
>  (ht
tp://www.cheesit.com/downloads/slang/slruby.html). The
module
>  worked OK until Ruby 1.9 revision 15996 came out:
>
>  r15996 | nobu | 2008-04-14 05:52:27 +0200 (ma, 14 apr
2008) | 2 lines
>
>  * gc.c (Init_stack): use ruby_init_stack. 
[ruby-dev:34350]

I've found that when I use ruby_init_stack instead of
Init_stack, it
works again.


Re: Ruby 1.9 "exception reentered"
user name
2008-06-10 14:50:37
2008/6/6, Paul Boekholt <p.boekholtgmail.com>:
> I've found that when I use ruby_init_stack instead of
Init_stack, it
>  works again.

I've just checked out revision 17082 and now the error is
back again??


Re: Ruby 1.9 "exception reentered"
user name
2008-06-11 15:46:22
> 2008/6/6, Paul Boekholt <p.boekholtgmail.com>:
> I've just checked out revision 17082 and now the error
is back again??

It seems it was broken when revision 17036 came out:

r17036 | nobu | 2008-06-09 02:54:23 +0200 (ma, 09 jun 2008)
| 2 lines

* include/ruby/intern.h (Init_stack): make to call
ruby_init_stack.

Again, can someone explain what causes this error?


Re: Ruby 1.9 "exception reentered"
country flaguser name
Japan
2008-06-12 02:13:53
Hi,

At Thu, 12 Jun 2008 05:46:22 +0900,
Paul Boekholt wrote in [ruby-core:17227]:
> It seems it was broken when revision 17036 came out:
> 
> r17036 | nobu | 2008-06-09 02:54:23 +0200 (ma, 09 jun
2008) | 2 lines
> 
> * include/ruby/intern.h (Init_stack): make to call
ruby_init_stack.
> 
> Again, can someone explain what causes this error?

It doesn't change ruby_init_stack(), but makes the function
will be called always instead of Init_stack().

What're your OS and CPU?

And couldn't you make simpler code to reproduce it?

-- 
Nobu Nakada


Re: Ruby 1.9 "exception reentered"
user name
2008-06-12 13:12:01
2008/6/12, Nobuyoshi Nakada <noburuby-lang.org>:
> It doesn't change ruby_init_stack(), but makes the
function
>  will be called always instead of Init_stack().

This is a mystery, because currently I'm not using
Init_stack(). I'm
using ruby_init_stack().

>
>  What're your OS and CPU?

OS is Debian Etch. CPU is an Intel Pentium III
(Coppermine).

>
>  And couldn't you make simpler code to reproduce it?

That's difficult. When the module is statically linked I
don't get the
error. I suspect the problem only occurs when it's
dynamically loaded.
So any code to reproduce it would have to be a DSO, such as
a SLang,
Perl or Apache module.

With Ruby 1.8.5 I had random segmentation faults, but only
when the
module was dynamically loaded. Then I found the post in
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-talk/67877 and
added some calls to Init_stack. After that I didn't have
segfaults,
but after r15996 came out I got the error "exception
reentered". I
replaced Init_stack with ruby_init_stack, and then it worked
again
until r17036 came out - even though it's not using
Init_stack.


Re: Ruby 1.9 "exception reentered"
user name
2008-07-06 02:18:29
Hi,
2008/6/12, Paul Boekholt <p.boekholtgmail.com>:

> That's difficult. When the module is statically linked
I don't get the
>  error. I suspect the problem only occurs when it's
dynamically loaded.
>  So any code to reproduce it would have to be a DSO,
such as a SLang,
>  Perl or Apache module.

I've compiled Perl's Inline::Ruby module with edpratomo's
patch to get
it working with 1.9 (see
h
ttp://rt.cpan.org/Public/Bug/Display.html?id=32536). I
get this when
running 'make test':

PERL_DL_NONLAZY=1 /usr/bin/perl
"-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01basic.......ok
t/02iter........<dummy toplevel>:17: [BUG]
Segmentation fault
ruby 1.9.0 (2008-04-14 revision 17550) [i686-linux]

-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:0017c4 d:0017c4 TOP   
<dummy toplevel>:17
---------------------------
-- backtrace of native function call (Use addr2line) --
0x4046410e
0x4039fbd7
0x4039fc0f
0x404276a9
0x40017440
0x403a74b7
0x403877b4
0x80bdaa1
0x80bc379
0x8063a1b
0x805ffd1
0x40072ea8
0x805fe31
-------------------------------------------------------
dubious
	Test returned status 0 (wstat 6, 0x6)
DIED. FAILED tests 10-11
	Failed 2/11 tests, 81.82% okay
t/03bindfunc....#<SystemStackError: stack level too
deep>
dubious
	Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 2-6
	Failed 5/6 tests, 16.67% okay
t/04iterator....#<SystemStackError: stack level too
deep>
dubious
	Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 1-6
	Failed 6/6 tests, 0.00% okay
t/05rb_exc......dubious
	Test returned status 0 (wstat 11, 0xb)
DIED. FAILED tests 1-8
	Failed 8/8 tests, 0.00% okay
t/06pl_exc......<dummy toplevel>:17: [BUG]
Segmentation fault
ruby 1.9.0 (2008-04-14 revision 17550) [i686-linux]

-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP   
<dummy toplevel>:17
---------------------------
-- backtrace of native function call (Use addr2line) --
0x4046310e
0x4039ebd7
0x4039ec0f
0x404266a9
0x40017440
(nil)
-------------------------------------------------------
dubious
	Test returned status 0 (wstat 6, 0x6)
DIED. FAILED tests 1-8
	Failed 8/8 tests, 0.00% okay
t/07proc........ok
t/08bind1.......ok
t/08bind2.......ok
t/09regex.......dubious
	Test returned status 0 (wstat 11, 0xb)
DIED. FAILED test 3
	Failed 1/3 tests, 66.67% okay
Failed Test    Stat Wstat Total Fail  Failed  List of
Failed
------------------------------------------------------------
-------------------
t/02iter.t        0     6    11    4  36.36%  10-11
t/03bindfunc.t  255 65280     6   10 166.67%  2-6
t/04iterator.t  255 65280     6   12 200.00%  1-6
t/05rb_exc.t      0    11     8   16 200.00%  1-8
t/06pl_exc.t      0     6     8   16 200.00%  1-8
t/09regex.t       0    11     3    2  66.67%  3
Failed 6/10 test scripts, 40.00% okay. 30/66 subtests
failed, 54.55% okay.
make: *** [test_dynamic] Fout 255


>
>  With Ruby 1.8.5 I had random segmentation faults, but
only when the
>  module was dynamically loaded. Then I found the post
in
>  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-talk/67877 and
>  added some calls to Init_stack. After that I didn't
have segfaults,
>  but after r15996 came out I got the error
"exception reentered". I
>  replaced Init_stack with ruby_init_stack, and then it
worked again
>  until r17036 came out - even though it's not using
Init_stack.

I can no longer get it to work with 15996 by replacing
Init_stack with
ruby_init_stack. Maybe I made some error rebuilding Ruby.
Anyway,
apparently the problem is caused by Init_stack and
ruby_init_stack not
doing quite the same thing. This patch to ruby_init_stack
seems to fix
my problem:

--- gc.c	(revision 15996)
+++ gc.c	(working copy)
 -1641,12
+1641,18 
 #endif
     )
 {
+#if defined(STACK_END_ADDRESS)
+        extern void *STACK_END_ADDRESS;
+        rb_gc_stack_start = STACK_END_ADDRESS;
+#else
+
     if (!rb_gc_stack_start ||
         STACK_UPPER(&addr,
                     rb_gc_stack_start > addr,
                     rb_gc_stack_start < addr)) {
         rb_gc_stack_start = addr;
     }
+#endif
 #ifdef __ia64
     if (!rb_gc_register_stack_start ||
         (VALUE*)bsp < rb_gc_register_stack_start) {

Perl's Inline::Ruby also works better. At least 'make test'
no longer
gives segmentation faults or SystemStackErrors:

PERL_DL_NONLAZY=1 /usr/bin/perl
"-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01basic.......ok
t/02iter........# Test 11 got: "no block given
(yield)" (t/02iter.t at line 41)
#    Expected: "no block given"
#  t/02iter.t line 41 is: ok($->message, 'no block
given');
FAILED test 11
	Failed 1/11 tests, 90.91% okay
t/03bindfunc....ok
t/04iterator....ok
t/05rb_exc......# Test 5 got: "divided by 0n(eval):1:
syntax error,
unexpected $end" (t/05rb_exc.t at line 25 fail #2)
#   Expected: "compile errorn(eval): parse
error"
#  t/05rb_exc.t line 25 is:     ok($x->message,
$exc[$n][0]);
FAILED test 5
	Failed 1/8 tests, 87.50% okay
t/06pl_exc......ok
t/07proc........ok
t/08bind1.......ok
t/08bind2.......ok
t/09regex.......ok
Failed Test  Stat Wstat Total Fail  Failed  List of Failed
------------------------------------------------------------
-------------------
t/02iter.t                 11    1   9.09%  11
t/05rb_exc.t                8    1  12.50%  5
Failed 2/10 test scripts, 80.00% okay. 2/66 subtests failed,
96.97% okay.
make: *** [test_dynamic] Fout 255


[1-7]

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