<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/include/ruby/internal/interpreter.h, branch v4.0.2</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Pass down "stack start" variables from closer to the top of the stack</title>
<updated>2024-01-18T22:55:12+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>kj@kjtsanaktsidis.id.au</email>
</author>
<published>2023-11-12T02:24:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=807714447ef02c77bb0e17fe27d96ee2692264f8'/>
<id>807714447ef02c77bb0e17fe27d96ee2692264f8</id>
<content type='text'>
This commit changes how stack extents are calculated for both the main
thread and other threads. Ruby uses the address of a local variable as
part of the calculation for machine stack extents:

* pthreads uses it as a lower-bound on the start of the stack, because
  glibc (and maybe other libcs) can store its own data on the stack
  before calling into user code on thread creation.
* win32 uses it as an argument to VirtualQuery, which gets the extent of
  the memory mapping which contains the variable

However, the local being used for this is actually too low (too close to
the leaf function call) in both the main thread case and the new thread
case.

In the main thread case, we have the `INIT_STACK` macro, which is used
for pthreads to set the `native_main_thread-&gt;stack_start` value. This
value is correctly captured at the very top level of the program (in
main.c). However, this is _not_ what's used to set the execution context
machine stack (`th-&gt;ec-&gt;machine_stack.stack_start`); that gets set as
part of a call to `ruby_thread_init_stack` in `Init_BareVM`, using the
address of a local variable allocated _inside_ `Init_BareVM`. This is
too low; we need to use a local allocated closer to the top of the
program.

In the new thread case, the lolcal is allocated inside
`native_thread_init_stack`, which is, again, too low.

In both cases, this means that we might have VALUEs lying outside the
bounds of `th-&gt;ec-&gt;machine.stack_{start,end}`, which won't be marked
correctly by the GC machinery.

To fix this,

* In the main thread case: We already have `INIT_STACK` at the right
  level, so just pass that local var to `ruby_thread_init_stack`.
* In the new thread case: Allocate the local one level above the call to
  `native_thread_init_stack` in `call_thread_start_func2`.

[Bug #20001]

fix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit changes how stack extents are calculated for both the main
thread and other threads. Ruby uses the address of a local variable as
part of the calculation for machine stack extents:

* pthreads uses it as a lower-bound on the start of the stack, because
  glibc (and maybe other libcs) can store its own data on the stack
  before calling into user code on thread creation.
* win32 uses it as an argument to VirtualQuery, which gets the extent of
  the memory mapping which contains the variable

However, the local being used for this is actually too low (too close to
the leaf function call) in both the main thread case and the new thread
case.

In the main thread case, we have the `INIT_STACK` macro, which is used
for pthreads to set the `native_main_thread-&gt;stack_start` value. This
value is correctly captured at the very top level of the program (in
main.c). However, this is _not_ what's used to set the execution context
machine stack (`th-&gt;ec-&gt;machine_stack.stack_start`); that gets set as
part of a call to `ruby_thread_init_stack` in `Init_BareVM`, using the
address of a local variable allocated _inside_ `Init_BareVM`. This is
too low; we need to use a local allocated closer to the top of the
program.

In the new thread case, the lolcal is allocated inside
`native_thread_init_stack`, which is, again, too low.

In both cases, this means that we might have VALUEs lying outside the
bounds of `th-&gt;ec-&gt;machine.stack_{start,end}`, which won't be marked
correctly by the GC machinery.

To fix this,

* In the main thread case: We already have `INIT_STACK` at the right
  level, so just pass that local var to `ruby_thread_init_stack`.
* In the new thread case: Allocate the local one level above the call to
  `native_thread_init_stack` in `call_thread_start_func2`.

[Bug #20001]

fix
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Pass down "stack start" variables from closer to the top of the stack"</title>
<updated>2024-01-12T06:58:54+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>kj@kjtsanaktsidis.id.au</email>
</author>
<published>2024-01-12T06:32:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=396e94666ba1646cb0fd1459eeae3f2e7ddd2658'/>
<id>396e94666ba1646cb0fd1459eeae3f2e7ddd2658</id>
<content type='text'>
This reverts commit 4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5.
</pre>
</div>
</content>
</entry>
<entry>
<title>Pass down "stack start" variables from closer to the top of the stack</title>
<updated>2024-01-12T06:29:48+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>kj@kjtsanaktsidis.id.au</email>
</author>
<published>2023-11-12T02:24:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5'/>
<id>4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5</id>
<content type='text'>
The implementation of `native_thread_init_stack` for the various
threading models can use the address of a local variable as part of the
calculation of the machine stack extents:

* pthreads uses it as a lower-bound on the start of the stack, because
  glibc (and maybe other libcs) can store its own data on the stack
  before calling into user code on thread creation.
* win32 uses it as an argument to VirtualQuery, which gets the extent of
  the memory mapping which contains the variable

However, the local being used for this is actually allocated _inside_
the `native_thread_init_stack` frame; that means the caller might
allocate a VALUE on the stack that actually lies outside the bounds
stored in machine.stack_{start,end}.

A local variable from one level above the topmost frame that stores
VALUEs on the stack must be drilled down into the call to
`native_thread_init_stack` to be used in the calculation. This probably
doesn't _really_ matter for the win32 case (they'll be in the same
memory mapping so VirtualQuery should return the same thing), but
definitely could matter for the pthreads case.

[Bug #20001]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The implementation of `native_thread_init_stack` for the various
threading models can use the address of a local variable as part of the
calculation of the machine stack extents:

* pthreads uses it as a lower-bound on the start of the stack, because
  glibc (and maybe other libcs) can store its own data on the stack
  before calling into user code on thread creation.
* win32 uses it as an argument to VirtualQuery, which gets the extent of
  the memory mapping which contains the variable

However, the local being used for this is actually allocated _inside_
the `native_thread_init_stack` frame; that means the caller might
allocate a VALUE on the stack that actually lies outside the bounds
stored in machine.stack_{start,end}.

A local variable from one level above the topmost frame that stores
VALUEs on the stack must be drilled down into the call to
`native_thread_init_stack` to be used in the calculation. This probably
doesn't _really_ matter for the win32 case (they'll be in the same
memory mapping so VirtualQuery should return the same thing), but
definitely could matter for the pthreads case.

[Bug #20001]
</pre>
</div>
</content>
</entry>
<entry>
<title>ruby_cleanup: fix MSVC compile error</title>
<updated>2021-09-10T11:00:06+00:00</updated>
<author>
<name>卜部昌平</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2021-09-09T02:12:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4f03930d04a0185ee9057ee314cfb79eb5a1b73a'/>
<id>4f03930d04a0185ee9057ee314cfb79eb5a1b73a</id>
<content type='text'>
See https://ci.appveyor.com/project/ruby/ruby/builds/40686153/job/1wihxw5m5kybtohj
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See https://ci.appveyor.com/project/ruby/ruby/builds/40686153/job/1wihxw5m5kybtohj
</pre>
</div>
</content>
</entry>
<entry>
<title>include/ruby/internal/interpreter.h: add doxygen</title>
<updated>2021-09-10T11:00:06+00:00</updated>
<author>
<name>卜部昌平</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2020-12-18T05:24:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f83b14af247c56083fa19f2f0ca47ba4088b324f'/>
<id>f83b14af247c56083fa19f2f0ca47ba4088b324f</id>
<content type='text'>
Must not be a bad idea to improve documents. [ci skip]

In fact many functions declared in the header file are already
documented more or less.  They were just copy &amp; pasted, with applying
some style updates.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Must not be a bad idea to improve documents. [ci skip]

In fact many functions declared in the header file are already
documented more or less.  They were just copy &amp; pasted, with applying
some style updates.
</pre>
</div>
</content>
</entry>
<entry>
<title>sed -i 's/. They/.  They/'</title>
<updated>2021-09-10T11:00:06+00:00</updated>
<author>
<name>卜部昌平</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2021-01-14T06:00:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=94e5953b484517234ad476b1e179d1bdbcbafbd7'/>
<id>94e5953b484517234ad476b1e179d1bdbcbafbd7</id>
<content type='text'>
Truly editorial fix for comments.  This works better with Emacs'
set-justification-full function. [ci skip]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Truly editorial fix for comments.  This works better with Emacs'
set-justification-full function. [ci skip]
</pre>
</div>
</content>
</entry>
<entry>
<title>Suppress warnings in C++2a</title>
<updated>2021-08-09T02:21:56+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2021-08-08T08:23:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a14671a6b6ad69bab443df75a3472575e2cc0dbc'/>
<id>a14671a6b6ad69bab443df75a3472575e2cc0dbc</id>
<content type='text'>
* bitwise operation between different enumeration types
  ('ruby_value_type' and 'ruby_fl_type') is deprecated
  [-Wdeprecated-enum-enum-conversion]

* volatile-qualified parameter type 'volatile int' is deprecated
  [-Wdeprecated-volatile]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* bitwise operation between different enumeration types
  ('ruby_value_type' and 'ruby_fl_type') is deprecated
  [-Wdeprecated-enum-enum-conversion]

* volatile-qualified parameter type 'volatile int' is deprecated
  [-Wdeprecated-volatile]
</pre>
</div>
</content>
</entry>
<entry>
<title>ruby_set_stack_size: no longer exists</title>
<updated>2020-12-18T02:18:09+00:00</updated>
<author>
<name>卜部昌平</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2020-12-18T02:18:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=aa82b067cbf24e781fedfe951be153b6b1d21ddf'/>
<id>aa82b067cbf24e781fedfe951be153b6b1d21ddf</id>
<content type='text'>
Deleted since fc3c60f6081d85f6274986a7a08b59db1515fcb5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Deleted since fc3c60f6081d85f6274986a7a08b59db1515fcb5
</pre>
</div>
</content>
</entry>
<entry>
<title>sed -i 's|ruby/impl|ruby/internal|'</title>
<updated>2020-05-11T00:24:08+00:00</updated>
<author>
<name>卜部昌平</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2020-05-08T09:31:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9e41a75255d15765648279629fd3134cae076398'/>
<id>9e41a75255d15765648279629fd3134cae076398</id>
<content type='text'>
To fix build failures.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To fix build failures.
</pre>
</div>
</content>
</entry>
<entry>
<title>mv include/ruby/{impl,internal}</title>
<updated>2020-05-11T00:24:08+00:00</updated>
<author>
<name>卜部昌平</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2020-05-08T09:10:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b85fd1d690b65efaa126cf9c24da73f31eee7a4e'/>
<id>b85fd1d690b65efaa126cf9c24da73f31eee7a4e</id>
<content type='text'>
Devs do not love "impl".
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Devs do not love "impl".
</pre>
</div>
</content>
</entry>
</feed>
