<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/thread_pthread_mn.c, branch v3_4_9</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>mn timer thread: force wakeups for timeouts</title>
<updated>2025-11-01T15:51:57+00:00</updated>
<author>
<name>Andre Muta</name>
<email>andremuta@gmail.com</email>
</author>
<published>2025-10-30T03:55:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7ec94afa8faad31d8b973edc53347973062e4d20'/>
<id>7ec94afa8faad31d8b973edc53347973062e4d20</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix threads stuck as zombie under M:N</title>
<updated>2024-12-13T21:57:14+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2024-11-13T17:51:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1cf32b2d7f2bb0dafce6108ecfc496491b19ad8a'/>
<id>1cf32b2d7f2bb0dafce6108ecfc496491b19ad8a</id>
<content type='text'>
In this case thread_sched_switch0 never returns, so we would never
end up setting finished to true.

Fixes [Bug #20638]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In this case thread_sched_switch0 never returns, so we would never
end up setting finished to true.

Fixes [Bug #20638]
</pre>
</div>
</content>
</entry>
<entry>
<title>Annotate anonymous mmap</title>
<updated>2024-11-21T18:48:05+00:00</updated>
<author>
<name>Kunshan Wang</name>
<email>wks1986@gmail.com</email>
</author>
<published>2024-11-19T08:07:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8ae7c22972d82b14d7308e16c26389fa4412727f'/>
<id>8ae7c22972d82b14d7308e16c26389fa4412727f</id>
<content type='text'>
Use PR_SET_VMA_ANON_NAME to set human-readable names for anonymous
virtual memory areas mapped by `mmap()` when compiled and run on Linux
5.17 or higher.  This makes it convenient for developers to debug mmap.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use PR_SET_VMA_ANON_NAME to set human-readable names for anonymous
virtual memory areas mapped by `mmap()` when compiled and run on Linux
5.17 or higher.  This makes it convenient for developers to debug mmap.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't crash if madvise(MADV_FREE or MADV_DONTNEED) fails</title>
<updated>2024-07-19T03:44:01+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>kj@kjtsanaktsidis.id.au</email>
</author>
<published>2024-07-12T05:13:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ca0dae25ed51627c411dfdbe9dec3901a321bff9'/>
<id>ca0dae25ed51627c411dfdbe9dec3901a321bff9</id>
<content type='text'>
The M:N threading stack cleanup machinery tries to call MADV_FREE on the native
thread's stack, and calls rb_bug if it fails. Unfortunately, there's no way to
distinguish between "You passed bad parameters to madvise" and "MADV_FREE is
not supported on the kernel you are running on"; both cases just return EINVAL.
This means that if you have a Ruby on a system that was built on a system with
MADV_FREE and run it on a system without it, you get a crash in nt_free_stack.

I ran into this because rr actually emulates MADV_FREE by just returning EINVAL
and pretending it's not supported (since it can otherwise introduce
nondeterministic behaviour). So if you run bootstraptest/test_ractor.rb under
rr, you get this crash.

I think we should just get rid of the error handling here; freeing memory like
this is strictly optional anyway.

[Bug #20632]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The M:N threading stack cleanup machinery tries to call MADV_FREE on the native
thread's stack, and calls rb_bug if it fails. Unfortunately, there's no way to
distinguish between "You passed bad parameters to madvise" and "MADV_FREE is
not supported on the kernel you are running on"; both cases just return EINVAL.
This means that if you have a Ruby on a system that was built on a system with
MADV_FREE and run it on a system without it, you get a crash in nt_free_stack.

I ran into this because rr actually emulates MADV_FREE by just returning EINVAL
and pretending it's not supported (since it can otherwise introduce
nondeterministic behaviour). So if you run bootstraptest/test_ractor.rb under
rr, you get this crash.

I think we should just get rid of the error handling here; freeing memory like
this is strictly optional anyway.

[Bug #20632]
</pre>
</div>
</content>
</entry>
<entry>
<title>`struct rb_thread_sched_waiting`</title>
<updated>2024-07-08T20:57:03+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2024-04-27T22:19:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ffc69eec0a5746d48ef3cf649639c67631a6a609'/>
<id>ffc69eec0a5746d48ef3cf649639c67631a6a609</id>
<content type='text'>
Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
can contain other than `rb_thread_t`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
can contain other than `rb_thread_t`.
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] fix some comments</title>
<updated>2024-03-05T09:50:47+00:00</updated>
<author>
<name>cui fliter</name>
<email>imcusg@gmail.com</email>
</author>
<published>2024-03-05T09:50:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=226a889dc7688cbd0c96cce1005adbda69b03ec4'/>
<id>226a889dc7688cbd0c96cce1005adbda69b03ec4</id>
<content type='text'>
Signed-off-by: cui fliter &lt;imcusg@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: cui fliter &lt;imcusg@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>`rb_thread_lock_native_thread()`</title>
<updated>2024-02-21T06:38:29+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2024-02-20T10:09:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d578684989fd2d75f086a259719e3eb0fe57ccb2'/>
<id>d578684989fd2d75f086a259719e3eb0fe57ccb2</id>
<content type='text'>
Introduce `rb_thread_lock_native_thread()` to allocate dedicated
native thread to the current Ruby thread for M:N threads.
This C API is similar to Go's `runtime.LockOSThread()`.

Accepted at https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-08-24.md
(and missed to implement on Ruby 3.3.0)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Introduce `rb_thread_lock_native_thread()` to allocate dedicated
native thread to the current Ruby thread for M:N threads.
This C API is similar to Go's `runtime.LockOSThread()`.

Accepted at https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-08-24.md
(and missed to implement on Ruby 3.3.0)
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix a warning with USE_RUBY_DEBUG_LOG=1 on macOS</title>
<updated>2024-02-14T01:40:26+00:00</updated>
<author>
<name>Kazuhiro NISHIYAMA</name>
<email>zn@mbf.nifty.com</email>
</author>
<published>2024-02-14T01:35:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c54622c657cbdd8fd13790d5c339b8dbadff8b14'/>
<id>c54622c657cbdd8fd13790d5c339b8dbadff8b14</id>
<content type='text'>
```
compiling ../thread.c
In file included from ../thread.c:263:
In file included from ../thread_pthread.c:2870:
../thread_pthread_mn.c:777:43: warning: format specifies type 'unsigned long' but the argument has type 'rb_hrtime_t' (aka 'unsigned long long') [-Wformat]
		RUBY_DEBUG_LOG("abs:%lu", abs);
				    ~~~   ^~~
				    %llu
../vm_debug.h:110:74: note: expanded from macro 'RUBY_DEBUG_LOG'
	ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
									 ^~~~~~~~~~~
1 warning generated.
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
```
compiling ../thread.c
In file included from ../thread.c:263:
In file included from ../thread_pthread.c:2870:
../thread_pthread_mn.c:777:43: warning: format specifies type 'unsigned long' but the argument has type 'rb_hrtime_t' (aka 'unsigned long long') [-Wformat]
		RUBY_DEBUG_LOG("abs:%lu", abs);
				    ~~~   ^~~
				    %llu
../vm_debug.h:110:74: note: expanded from macro 'RUBY_DEBUG_LOG'
	ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
									 ^~~~~~~~~~~
1 warning generated.
```
</pre>
</div>
</content>
</entry>
<entry>
<title>notify ASAN about M:N threading stack switches</title>
<updated>2024-02-06T11:23:42+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>kj@kjtsanaktsidis.id.au</email>
</author>
<published>2024-01-28T06:15:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=719db18b50a996f3df4f76854f7dc9d69f875582'/>
<id>719db18b50a996f3df4f76854f7dc9d69f875582</id>
<content type='text'>
In a similar way to how we do it with fibers in cont.c, we need to call
__sanitize_start_switch_fiber and __sanitize_finish_switch_fiber around
the call to coroutine_transfer to let ASAN save &amp; restore the fake stack
pointer.

When a M:N thread is exiting, we pass `to_dead` to the new
coroutine_transfer0 function, so that we can pass NULL for saving the
stack pointer. This signals to ASAN that the fake stack can be freed
(otherwise it would be leaked)

[Bug #20220]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In a similar way to how we do it with fibers in cont.c, we need to call
__sanitize_start_switch_fiber and __sanitize_finish_switch_fiber around
the call to coroutine_transfer to let ASAN save &amp; restore the fake stack
pointer.

When a M:N thread is exiting, we pass `to_dead` to the new
coroutine_transfer0 function, so that we can pass NULL for saving the
stack pointer. This signals to ASAN that the fake stack can be freed
(otherwise it would be leaked)

[Bug #20220]
</pre>
</div>
</content>
</entry>
<entry>
<title>Adjust styles and indents [ci skip]</title>
<updated>2024-01-07T15:50:41+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2024-01-07T15:50:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c30b8ae947e4e0e01df74b07282b27b1b1c70df8'/>
<id>c30b8ae947e4e0e01df74b07282b27b1b1c70df8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
