Project

General

Profile

Actions

Backport #7159

closed

SIGSEGV when calling Random#rand after forking

Added by kris7t (Kristóf Marussy) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:47976]

Description

When Kernel#fork is called,
Ruby uninitializes the default random generator Random::DEFAULT
by setting the next field of the struct MT that provides its state to 0.

Kernel#rand correctly initializes this random generator by a seed
when it detects this.
However, Random#rand does not do this and therefore attempting to
call Random#rand in a newly forked child process results in a
segmentation fault, because a null pointer is being dereferenced.

This irb session illustrates the problem:
https://gist.github.com/3888930


Related issues

Is duplicate of Backport193 - Backport #5661: Segfault in Random.rand with Spork gemClosedusa (Usaku NAKAMURA)11/23/2011Actions
Actions

Also available in: Atom PDF