[#25936] [Bug:1.9] [rubygems] $LOAD_PATH includes bin directory — Nobuyoshi Nakada <nobu@...>

Hi,

10 messages 2009/10/05

[#25943] Disabling tainting — Tony Arcieri <tony@...>

Would it make sense to have a flag passed to the interpreter on startup that

16 messages 2009/10/05

[#26028] [Bug #2189] Math.atanh(1) & Math.atanh(-1) should not raise an error — Marc-Andre Lafortune <redmine@...>

Bug #2189: Math.atanh(1) & Math.atanh(-1) should not raise an error

14 messages 2009/10/10

[#26222] [Bug #2250] IO::for_fd() objects' finalization dangerously closes underlying fds — Mike Pomraning <redmine@...>

Bug #2250: IO::for_fd() objects' finalization dangerously closes underlying fds

11 messages 2009/10/22

[#26244] [Bug #2258] Kernel#require inside rb_require() inside rb_protect() inside SysV context fails — Suraj Kurapati <redmine@...>

Bug #2258: Kernel#require inside rb_require() inside rb_protect() inside SysV context fails

24 messages 2009/10/22

[#26361] [Feature #2294] [PATCH] ruby_bind_stack() to embed Ruby in coroutine — Suraj Kurapati <redmine@...>

Feature #2294: [PATCH] ruby_bind_stack() to embed Ruby in coroutine

42 messages 2009/10/27

[#26371] [Bug #2295] segmentation faults — tomer doron <redmine@...>

Bug #2295: segmentation faults

16 messages 2009/10/27

[ruby-core:26290] [Bug #2258] Kernel#require inside rb_require() inside rb_protect() inside SysV context fails

From: Suraj Kurapati <redmine@...>
Date: 2009-10-25 04:28:54 UTC
List: ruby-core #26290
Issue #2258 has been updated by Suraj Kurapati.

File 0001-add-ruby_bind_stack-to-inform-GC-about-explicit-stac.patch added
File ruby-ucontext-full.tgz added

Hi,

I am happy to announce that the problem is now solved! :-)

The attached 0001-add-ruby_bind_stack*.patch file adds a
ruby_bind_stack() function to the Ruby C API which allows
me to inform the GC about the stack boundaries of the 
System V context in which the Ruby interperter is running:

  void ruby_bind_stack(VALUE *lower, VALUE *upper);

I am also attaching an updated ruby-ucontext-full.tgz example
which makes use of the above ruby_bind_stack() function when
it is available.

Continue reading for a detailed explanation of the problem.

Thanks for your consideration.

##########################################################
# Problem explanation
##########################################################

The problem was that the GC assumed that Ruby's stack
was aligned with the native pthread's stack:

  upper=0xc1bff1f0
  lower=0xbffff1f0

As Ruby executes, the lower boundary is adjusted to
reflect the current C stack pointer by calls to the
SET_STACK_END macro.  In contrast, the upper boundary
is not updated at all.

When the GC runs, it scans from the current stack
lower boundary to the upper boundary.  Since the lower
boundary was updated to reflect the C stack pointer,
we face the following situation:

  (high memory address)
  
  0xc1bff1f0    Ruby's stack upper boundary
  
  0x086032a0    System V context's stack upper boundary
  
  0x08601680    Ruby's stack lower boundary
                (after update by SET_STACK_END)
                
  0x082032a0    System V context's stack lower boundary
  
  (low memory address)

To correct this situation, we need to update Ruby's
stack upper boundary to reflect the System V context's
stack upper boundary:

  (high memory address)
  
  0x086032a0    Ruby's stack upper boundary and also
                System V context's stack upper boundary
  
  0x08601680    Ruby's stack lower boundary
                (after update by SET_STACK_END)
                
  0x082032a0    System V context's stack lower boundary
  
  (low memory address)

For machines where the stack grows upward, a similar problem
would be faced where Ruby's stack lower boundary would need
to be updated to reflect the System V context's stack lower
boundary.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2258

----------------------------------------
http://redmine.ruby-lang.org

In This Thread