https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112009-09-21T02:35:19ZRuby Issue Tracking SystemRuby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=59282009-09-21T02:35:19Zsunaku (Suraj Kurapati)sunaku@gmail.com
<ul></ul><p>=begin<br>
Whoops, I assumed that the native machine's stack direction grows from<br>
high to low. That is not protable, so here is my corrected request:</p>
<p>Add a max_stack_size parameter to ruby_init_stack():</p>
<pre><code> void ruby_init_stack(
VALUE* stack_start,
size_t max_stack_size,
bool stack_descends /* stack grows from high to low? */
);
</code></pre>
<p>Add a function to return Ruby's preferred stack size:</p>
<pre><code> size_t ruby_stack_size_preference();
</code></pre>
<p>Add a function to return Ruby's preferred stack direction:</p>
<pre><code> bool ruby_stack_descends_p(); /* stack grows from high to low? */
</code></pre>
<p>This way, I can provide a custom stack to Ruby:</p>
<pre><code> size_t stack_size = ruby_stack_size_preference();
bool stack_descends = ruby_stack_descends_p();
VALUE* stack_start = malloc(stack_size);
if (stack_descends) {
stack_start += stack_size;
}
ruby_init_stack(stack_start, stack_size);
</code></pre>
<p>If you wish to minimize the number of new functions added to the Ruby<br>
C API, then perhaps you could add a RUBY_INIT_STACK_ON_HEAP macro<br>
which makes Ruby do (internally) everything in the code shown above.</p>
<p>Thanks for your consideration.<br>
=end</p> Ruby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=59292009-09-21T02:42:12Zsunaku (Suraj Kurapati)sunaku@gmail.com
<ul></ul><p>=begin<br>
Sigh, yet another mistake. Below is my corrected request. Sorry for<br>
the trouble.</p>
<p>Add a max_stack_size parameter to ruby_init_stack():</p>
<pre><code> void ruby_init_stack(VALUE* stack_start, size_t max_stack_size);
</code></pre>
<p>Add a function to return Ruby's preferred stack size:</p>
<pre><code> size_t ruby_stack_size_preference();
</code></pre>
<p>Add a function to return Ruby's preferred stack direction:</p>
<pre><code> bool ruby_stack_descends_p(); /* stack grows from high to low? */
</code></pre>
<p>This way, I can provide a custom stack to Ruby:</p>
<pre><code> size_t stack_size = ruby_stack_size_preference();
bool stack_descends = ruby_stack_descends_p();
VALUE* stack_start = malloc(stack_size);
if (stack_descends) {
stack_start += stack_size;
}
ruby_init_stack(stack_start, stack_size);
</code></pre>
<p>If you wish to minimize the number of new functions added to the Ruby<br>
C API, then perhaps you could add a RUBY_INIT_STACK_ON_HEAP macro<br>
which makes Ruby do (internally) everything in the code shown above.</p>
<p>Thanks for your consideration.<br>
=end</p> Ruby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=59802009-09-23T17:15:55Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/25674">[ruby-core:25674]</a> [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: ruby_init_stack() - add ability to specify or query max_stack_size (Closed)" href="https://redmine.ruby-lang.org/issues/2126">#2126</a>] ruby_init_stack() - add ability to specify or query max_stack_size"<br>
on Mon, 21 Sep 2009 02:42:14 +0900, Suraj Kurapati <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> writes:</p>
<p>| This way, I can provide a custom stack to Ruby:<br>
|<br>
| size_t stack_size = ruby_stack_size_preference();<br>
| bool stack_descends = ruby_stack_descends_p();<br>
|<br>
| VALUE* stack_start = malloc(stack_size);<br>
|<br>
| if (stack_descends) {<br>
| stack_start += stack_size;<br>
| }<br>
|<br>
| ruby_init_stack(stack_start, stack_size);</p>
<p>As far as I know, there's no portable way to switch machine stack to<br>
pre-allocated heap region. I'm happy to be proven wrong.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=64382009-10-25T13:39:46Zsunaku (Suraj Kurapati)sunaku@gmail.com
<ul></ul><p>=begin<br>
Hi Matz,</p>
<p>Please take a look at issue <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Kernel#require inside rb_require() inside rb_protect() inside SysV context fails (Closed)" href="https://redmine.ruby-lang.org/issues/2258">#2258</a> (from note 16 onwards) which<br>
provides a practical example of the need for a stack-informing<br>
function in the Ruby C API.</p>
<p>That example uses UNIX System V contexts to switch the<br>
machine stack to a pre-allocated heap region. Other<a href="http://en.wikipedia.org/w/index.php?title=Coroutine&section=8#Implementations_for_C" class="external">1</a>, more<br>
cross-platform libraries, such as libpcl (portable coroutine<br>
library), are also capable of doing this.</p>
<p>For your convenience, I will create a variation of that<br>
example which uses libpcl and other libraries to demonstrate<br>
the feasibility of this request.</p>
<p>Thanks for your consideration.</p>
<p>=end</p> Ruby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=64412009-10-25T15:25:47Zsunaku (Suraj Kurapati)sunaku@gmail.com
<ul></ul><p>=begin<br>
Hi Matz,</p>
<p>I added examples that use libpcl<a href="http://www.xmailserver.org/libpcl.html" class="external">1</a> to issue <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Kernel#require inside rb_require() inside rb_protect() inside SysV context fails (Closed)" href="https://redmine.ruby-lang.org/issues/2258">#2258</a> (note 18).</p>
<p>Please consider the "ruby_bind_stack.patch" file attached to<br>
that issue as my proposed solution for this feature request.</p>
<p>Thanks for your consideration.</p>
<p>=end</p> Ruby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=65032009-10-28T02:07:18Zsunaku (Suraj Kurapati)sunaku@gmail.com
<ul></ul><p>=begin<br>
Hi,</p>
<p>I created a new issue <a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: [PATCH] ruby_bind_stack() to embed Ruby in coroutine (Assigned)" href="https://redmine.ruby-lang.org/issues/2294">#2294</a> to summarize<br>
this feature request and the results of<br>
my experiments for solving issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: ruby_init_stack() - add ability to specify or query max_stack_size (Closed)" href="https://redmine.ruby-lang.org/issues/2126">#2126</a>.</p>
<p>Please close this feature request and<br>
refer to the new <a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: [PATCH] ruby_bind_stack() to embed Ruby in coroutine (Assigned)" href="https://redmine.ruby-lang.org/issues/2294">#2294</a> issue instead.</p>
<p>Thanks.<br>
=end</p> Ruby master - Feature #2126: ruby_init_stack() - add ability to specify or query max_stack_sizehttps://redmine.ruby-lang.org/issues/2126?journal_id=68792009-11-18T18:27:05Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>=begin<br>
This issue was solved with changeset r25842.<br>
Suraj, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<p>=end</p>