<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/thread_pthread.c, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) c8155822c460a5734d700cd468d306ca03b44ce4: [Backport #21959]</title>
<updated>2026-03-24T05:49:12+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2026-03-24T05:06:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=75de62b79bb1af97a905b2dce0a8cf6ffd64b083'/>
<id>75de62b79bb1af97a905b2dce0a8cf6ffd64b083</id>
<content type='text'>
	[PATCH] reinit rb_internal_thread_event_hooks_rw_lock at fork

	[Bug #21959]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] reinit rb_internal_thread_event_hooks_rw_lock at fork

	[Bug #21959]
</pre>
</div>
</content>
</entry>
<entry>
<title>[3.3] Fix deadlock on th-&gt;interrupt_lock after fork</title>
<updated>2026-02-05T06:48:56+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2026-02-04T12:12:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=91f0a5a11006d7d6ba72c4d9128ae909c3adaaf8'/>
<id>91f0a5a11006d7d6ba72c4d9128ae909c3adaaf8</id>
<content type='text'>
[Bug #21860]

If a thread was holding this lock before fork, it will not exist in the
child process. We should re-initialize these locks as we do with the VM
locks when forking.

Co-Authored-By: John Hawthorn &lt;john@hawthorn.email&gt;
Co-authored-by: Aaron Patterson &lt;tenderlove@ruby-lang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #21860]

If a thread was holding this lock before fork, it will not exist in the
child process. We should re-initialize these locks as we do with the VM
locks when forking.

Co-Authored-By: John Hawthorn &lt;john@hawthorn.email&gt;
Co-authored-by: Aaron Patterson &lt;tenderlove@ruby-lang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) e500222de1a8d5e7a844209a7e912b03db8cdf76:</title>
<updated>2025-11-03T01:10:57+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2025-11-03T01:10:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2da2d33cc49efd5508757aadc7e97db2968dfdfa'/>
<id>2da2d33cc49efd5508757aadc7e97db2968dfdfa</id>
<content type='text'>
	[PATCH] fix last commit

	`th` is gone.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] fix last commit

	`th` is gone.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) ffc69eec0a5746d48ef3cf649639c67631a6a609, 0531fa4d6fea100f69f0bac9e03973fe49ecd570: [Backport #21560]</title>
<updated>2025-11-02T05:50:06+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2025-11-02T05:50:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=609f957ebede1a062b1f34515382e4c306f77444'/>
<id>609f957ebede1a062b1f34515382e4c306f77444</id>
<content type='text'>
	[PATCH] `struct rb_thread_sched_waiting`

	Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
	can contain other than `rb_thread_t`.

	[PATCH] mn timer thread: force wakeups for timeouts
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] `struct rb_thread_sched_waiting`

	Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
	can contain other than `rb_thread_t`.

	[PATCH] mn timer thread: force wakeups for timeouts
</pre>
</div>
</content>
</entry>
<entry>
<title>Re-initialize vm-&gt;ractor.sched.lock after fork (#11372)</title>
<updated>2024-08-14T17:19:53+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2024-08-14T17:19:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=66312ad913d67bfd3c2c83b174eabf537f5def84'/>
<id>66312ad913d67bfd3c2c83b174eabf537f5def84</id>
<content type='text'>
[Bug #20633] Re-initialize vm-&gt;ractor.sched.lock after fork

Previously under certain conditions it was possible to encounter a
deadlock in the forked child process if ractor.sched.lock was held.

Co-authored-by: Nathan Froyd &lt;froydnj@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #20633] Re-initialize vm-&gt;ractor.sched.lock after fork

Previously under certain conditions it was possible to encounter a
deadlock in the forked child process if ractor.sched.lock was held.

Co-authored-by: Nathan Froyd &lt;froydnj@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) ef3803ed4028810f9088019f0db1a366370ab53a: [Backport #20502]</title>
<updated>2024-05-29T23:48:51+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2024-05-29T23:48:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d65da20eb4ebf5fcbc7cd0333e1406e1dd3c373b'/>
<id>d65da20eb4ebf5fcbc7cd0333e1406e1dd3c373b</id>
<content type='text'>
	Ignore the result of pthread_kill in ubf_wakeup_thread

	After an upgrade to Ruby 3.3.0, I experienced reproducible production crashes
	of the form:

	[BUG] pthread_kill: No such process (ESRCH)

	This is the only pthread_kill call in Ruby. The result of pthread_kill was
	previously ignored in Ruby 3.2 and below. Checking the result was added in
	be1bbd5b7d40ad863ab35097765d3754726bbd54 (MaNy).

	I have not yet been able to create a minimal self-contained example,
	but it should be safe to remove the checks.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Ignore the result of pthread_kill in ubf_wakeup_thread

	After an upgrade to Ruby 3.3.0, I experienced reproducible production crashes
	of the form:

	[BUG] pthread_kill: No such process (ESRCH)

	This is the only pthread_kill call in Ruby. The result of pthread_kill was
	previously ignored in Ruby 3.2 and below. Checking the result was added in
	be1bbd5b7d40ad863ab35097765d3754726bbd54 (MaNy).

	I have not yet been able to create a minimal self-contained example,
	but it should be safe to remove the checks.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use native_thread_init_stack on cygwin</title>
<updated>2023-12-23T23:06:03+00:00</updated>
<author>
<name>Daisuke Fujimura (fd0)</name>
<email>booleanlabel@gmail.com</email>
</author>
<published>2023-12-16T15:02:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=daefbf8fbfa1bd2109315bab7658f52460f7ed59'/>
<id>daefbf8fbfa1bd2109315bab7658f52460f7ed59</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>MN: ceil timeout milli seconds</title>
<updated>2023-12-22T20:56:02+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-12-22T20:23:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a4b737213eb1d8f352f1f148c27e96a3f09f5d08'/>
<id>a4b737213eb1d8f352f1f148c27e96a3f09f5d08</id>
<content type='text'>
`hrrel / RB_HRTIME_PER_MSEC` floor the timeout value and it can
return wrong value by `Mutex#sleep` (return Integer even if
it should return nil (timeout'ed)).

This patch ceil the value and the issue was solved.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`hrrel / RB_HRTIME_PER_MSEC` floor the timeout value and it can
return wrong value by `Mutex#sleep` (return Integer even if
it should return nil (timeout'ed)).

This patch ceil the value and the issue was solved.
</pre>
</div>
</content>
</entry>
<entry>
<title>KQueue support for M:N threads</title>
<updated>2023-12-20T07:23:38+00:00</updated>
<author>
<name>JP Camara</name>
<email>jp@jpcamara.com</email>
</author>
<published>2023-12-07T01:01:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8782e02138e6fe18b6c0dcc29bb877d6cdae57e5'/>
<id>8782e02138e6fe18b6c0dcc29bb877d6cdae57e5</id>
<content type='text'>
* Allows macOS users to use M:N threads (and technically FreeBSD, though it has not been verified on FreeBSD)

* Include sys/event.h header check for macros, and include sys/event.h when present

* Rename epoll_fd to more generic kq_fd (Kernel event Queue) for use by both epoll and kqueue

* MAP_STACK is not available on macOS so conditionall apply it to mmap flags

* Set fd to close on exec

* Log debug messages specific to kqueue and epoll on creation

* close_invalidate raises an error for the kqueue fd on child process fork. It's unclear rn if that's a bug, or if it's kqueue specific behavior

Use kq with rb_thread_wait_for_single_fd

* Only platforms with `USE_POLL` (linux) had changes applied to take advantage of kernel event queues. It needed to be applied to the `select` so that kqueue could be properly applied

* Clean up kqueue specific code and make sure only flags that were actually set are removed (or an error is raised)

* Also handle kevent specific errnos, since most don't apply from epoll to kqueue

* Use the more platform standard close-on-exec approach of `fcntl` and `FD_CLOEXEC`. The io-event gem uses `ioctl`, but fcntl seems to be the recommended choice. It is also what Go, Bun, and Libuv use

* We're making changes in this file anyways - may as well fix a couple spelling mistakes while here

Make sure FD_CLOEXEC carries over in dup

* Otherwise the kqueue descriptor should have FD_CLOEXEC, but doesn't and fails in assert_close_on_exec
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Allows macOS users to use M:N threads (and technically FreeBSD, though it has not been verified on FreeBSD)

* Include sys/event.h header check for macros, and include sys/event.h when present

* Rename epoll_fd to more generic kq_fd (Kernel event Queue) for use by both epoll and kqueue

* MAP_STACK is not available on macOS so conditionall apply it to mmap flags

* Set fd to close on exec

* Log debug messages specific to kqueue and epoll on creation

* close_invalidate raises an error for the kqueue fd on child process fork. It's unclear rn if that's a bug, or if it's kqueue specific behavior

Use kq with rb_thread_wait_for_single_fd

* Only platforms with `USE_POLL` (linux) had changes applied to take advantage of kernel event queues. It needed to be applied to the `select` so that kqueue could be properly applied

* Clean up kqueue specific code and make sure only flags that were actually set are removed (or an error is raised)

* Also handle kevent specific errnos, since most don't apply from epoll to kqueue

* Use the more platform standard close-on-exec approach of `fcntl` and `FD_CLOEXEC`. The io-event gem uses `ioctl`, but fcntl seems to be the recommended choice. It is also what Go, Bun, and Libuv use

* We're making changes in this file anyways - may as well fix a couple spelling mistakes while here

Make sure FD_CLOEXEC carries over in dup

* Otherwise the kqueue descriptor should have FD_CLOEXEC, but doesn't and fails in assert_close_on_exec
</pre>
</div>
</content>
</entry>
<entry>
<title>clear `sched-&gt;lock_onwer` at fork</title>
<updated>2023-12-18T17:26:37+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-12-18T12:40:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6c4b04de5cba36077f86b08d54c4c316f3df1d87'/>
<id>6c4b04de5cba36077f86b08d54c4c316f3df1d87</id>
<content type='text'>
`sched-&gt;lock_owner` can be non-NULL at fork because the timer thread
can acquire the lock while forking. `lock_owner` information is for
debugging, so we only need to clear it at fork.

I hope this patch fixes the following assertion failure:
```
thread_pthread.c:354:thread_sched_lock_:sched-&gt;lock_owner == NULL
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`sched-&gt;lock_owner` can be non-NULL at fork because the timer thread
can acquire the lock while forking. `lock_owner` information is for
debugging, so we only need to clear it at fork.

I hope this patch fixes the following assertion failure:
```
thread_pthread.c:354:thread_sched_lock_:sched-&gt;lock_owner == NULL
```
</pre>
</div>
</content>
</entry>
</feed>
