Hi,

(2013/02/13 14:49), sunaku (Suraj Kurapati) wrote:
> ko1 (Koichi Sasada) wrote:
>>> 1.  Cannot bind Ruby to a pre-allocated stack address range.
>>
>> I'm not sure what you are saying.
> 
> Changeset r38905 did not include my ruby_bind_stack() function.
> 
> Without that function (or something similar), I cannot tell Ruby 2.0.0-rc2 
> about the stack address range of the coroutine which is hosting the Ruby.
> 
> And if Ruby is not told that information, it might make a fatal mistake: 
> Ruby might go beyond the coroutine's pre-allocated stack address range.
> 
> This can cause memory corruption, segfault crashes, and undefined behavior.
> 
>> `ucontext' version do `pre-allocation'.
> 
> Yes, in my ruby-coroutine-example application, all versions do pre-allocation.
> 
> However, Ruby must also be told (bound to) the coroutine's stack address range.

I think you got misunderstanding.

(1) Ruby interpreter must know machine stack start, not a `range'.
(2) Machine stack start can be grabbed without telling an address
    range explicitly.
    See a r38905.

NOTE: On Ruby 1.8, may run fine on co-routines.
      The patch revert to this behavior.

Without machine-stack-end, we can't detect machine stack overflow. This
is an issue. But not a critical issue.

However, the implantation of `ruby_bind_stack()' has several problems:

- Designed on misunderstanding
- Depend on specific architecture

I agree to add another interface to tell the stack range. But
`ruby_bind_stack()' is not acceptable now. At least Ruby 2.0.0 shouldn't
include it.

Maybe it will be a parameter of an initialize function of the Ruby
interpreter.


> Ruby might go beyond the coroutine's pre-allocated stack address range.

Yes. That's right.


>>> 2.  In my coroutine example, only ucontext works correctly:
>>
>> I checked pthread and it okay...
>>
>> I'll check again soon. Please wait.
> 
> Sure, thanks for your consideration.

I believe last patch will solve this issue.
So the problem is based on my misunderstanding or a bug.
I want to solve this issue before 2.0.0 release.

I'll check it soon.

-- 
// SASADA Koichi at atdot dot net