<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/random.c, 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>Win32: Drop support for older than MSVC 8.0/_MSC_VER 1400</title>
<updated>2025-11-19T02:03:42+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2024-12-09T05:56:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cdb9893c552f67a6065dcb165b2040d35c57aee3'/>
<id>cdb9893c552f67a6065dcb165b2040d35c57aee3</id>
<content type='text'>
Visual C++ 2005 (8.0):
- _MSC_VER: 1400
- MSVCRT_VERSION: 80
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Visual C++ 2005 (8.0):
- _MSC_VER: 1400
- MSVCRT_VERSION: 80
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Clarify differences between Kernel.rand and Random.rand when given a Float `max`</title>
<updated>2025-09-03T04:44:47+00:00</updated>
<author>
<name>Jason Garber</name>
<email>8061+jgarber@users.noreply.github.com</email>
</author>
<published>2025-09-03T04:44:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=01e27acbec4d8ce1b7a78f07dc8f9080f71854a9'/>
<id>01e27acbec4d8ce1b7a78f07dc8f9080f71854a9</id>
<content type='text'>
* [DOC] Clarify differences between Kernel.rand and Random.rand

* `Kernel.rand` converts the `max` Float argument to Integer and returns Integer values
* `Random.rand` preserves the `max` Float argument and returns Float values
* Added examples demonstrating the behavioral differences
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* [DOC] Clarify differences between Kernel.rand and Random.rand

* `Kernel.rand` converts the `max` Float argument to Integer and returns Integer values
* `Random.rand` preserves the `max` Float argument and returns Float values
* Added examples demonstrating the behavioral differences
</pre>
</div>
</content>
</entry>
<entry>
<title>Add missing write barriers to Random</title>
<updated>2025-08-18T19:00:15+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2025-08-12T17:41:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0b098a93dbb9cb2112e7c0c8519e09cca4478fd0'/>
<id>0b098a93dbb9cb2112e7c0c8519e09cca4478fd0</id>
<content type='text'>
We recently converted this to be WB_PROTECTED, but missed some locations
the seed was set.

This is a little bit confusing because as far as I can tell some of the
seeds are set in Ractor local storage, and others on actual objects.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We recently converted this to be WB_PROTECTED, but missed some locations
the seed was set.

This is a little bit confusing because as far as I can tell some of the
seeds are set in Ractor local storage, and others on actual objects.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make Random write-barrier protected</title>
<updated>2025-08-07T13:27:22+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-08-06T15:09:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=24d0b458cd6ccde1e052c1db15af120def349693'/>
<id>24d0b458cd6ccde1e052c1db15af120def349693</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #21448] Reorder trials in `fill_random_bytes`</title>
<updated>2025-06-21T17:00:56+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-06-21T17:00:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d84a811f31a65821642b165d712f380c0cc060e0'/>
<id>d84a811f31a65821642b165d712f380c0cc060e0</id>
<content type='text'>
First try dedicated system calls, such as `getrandom` or `getentropy`,
next possible libraries, then fallback to `/dev/urandom`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
First try dedicated system calls, such as `getrandom` or `getentropy`,
next possible libraries, then fallback to `/dev/urandom`.
</pre>
</div>
</content>
</entry>
<entry>
<title>Restore getrandom(2) path for Linux with glibc 2.36 or later</title>
<updated>2025-06-21T10:57:19+00:00</updated>
<author>
<name>Kazuki Yamaguchi</name>
<email>k@rhe.jp</email>
</author>
<published>2025-06-20T10:21:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0cec4a14fb832aed4b498a21ec0c19765642d408'/>
<id>0cec4a14fb832aed4b498a21ec0c19765642d408</id>
<content type='text'>
This is a follow-up to commit b120f5e38d9c (avoid fork-unsafe arc4random
implementations, 2018-09-04).

Avoid defining a no-op fill_random_bytes_syscall() if arc4random_buf(3)
exists, but we are unsure if it is fork-safe. Check for other options
instead. IOW, see if getrandom(2) is available.

glibc 2.36, released in 2022, started to provide arc4random_buf(3) on
Linux. This causes fill_random_bytes_syscall() to use neither of them
and makes Random.urandom solely rely on getentropy(3) via
fill_random_bytes_urandom().

While the glibc implementation is safe, I did not add it to the list
because using getrandom(2) directly is preferable on Linux.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a follow-up to commit b120f5e38d9c (avoid fork-unsafe arc4random
implementations, 2018-09-04).

Avoid defining a no-op fill_random_bytes_syscall() if arc4random_buf(3)
exists, but we are unsure if it is fork-safe. Check for other options
instead. IOW, see if getrandom(2) is available.

glibc 2.36, released in 2022, started to provide arc4random_buf(3) on
Linux. This causes fill_random_bytes_syscall() to use neither of them
and makes Random.urandom solely rely on getentropy(3) via
fill_random_bytes_urandom().

While the glibc implementation is safe, I did not add it to the list
because using getrandom(2) directly is preferable on Linux.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #21448] Use `getentropy(2)` only on macOS</title>
<updated>2025-06-21T07:52:16+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-06-21T07:52:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1181a682a6c314c92686e3701defa1eb44068c4e'/>
<id>1181a682a6c314c92686e3701defa1eb44068c4e</id>
<content type='text'>
If this is not a system call, then it is using getrandom (which would
have been tried already), and cannot be used as a replacement for the
random devices.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If this is not a system call, then it is using getrandom (which would
have been tried already), and cannot be used as a replacement for the
random devices.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove a useless condition expression</title>
<updated>2024-11-29T15:03:07+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-29T14:33:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8aeb67de7dd9c8cf505985be45cd0efcea88f895'/>
<id>8aeb67de7dd9c8cf505985be45cd0efcea88f895</id>
<content type='text'>
`len` is always at least 1 here.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`len` is always at least 1 here.
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid illegal pointer</title>
<updated>2024-11-28T18:01:46+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-28T17:16:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=50a34637a4bdd64a709937f09c839195a2b1d967'/>
<id>50a34637a4bdd64a709937f09c839195a2b1d967</id>
<content type='text'>
When loading a crafted marshal data of Random, a pointer to an illegal
address was created. I don't think there is any harm since the data is
normalized before access, but just to be safe, I add a check to make it
an error.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When loading a crafted marshal data of Random, a pointer to an illegal
address was created. I don't think there is any harm since the data is
normalized before access, but just to be safe, I add a check to make it
an error.
</pre>
</div>
</content>
</entry>
<entry>
<title>Do not try random devices immediately twice</title>
<updated>2024-06-07T01:42:41+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2024-06-06T18:15:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=335cb28886dda81b5c3dad1bb02cf7b7450e05e9'/>
<id>335cb28886dda81b5c3dad1bb02cf7b7450e05e9</id>
<content type='text'>
Do not retry `fill_random_bytes` in `Init_RandomSeedCore`, just after
it failed first.

In other places, `rand_init_default` and `random_seed`, no more tweeks
needed once it succeeded
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Do not retry `fill_random_bytes` in `Init_RandomSeedCore`, just after
it failed first.

In other places, `rand_init_default` and `random_seed`, no more tweeks
needed once it succeeded
</pre>
</div>
</content>
</entry>
</feed>
