Project

General

Profile

This project is closed and read-only.

Actions

Backport #7159

closed

SIGSEGV when calling Random#rand after forking

Backport #7159: SIGSEGV when calling Random#rand after forking

Added by kris7t (Kristóf Marussy) almost 14 years ago. Updated almost 14 years ago.

Status:
Closed
[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 1 (0 open — 1 closed)

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

Updated by nobu (Nobuyoshi Nakada) almost 14 years ago Actions #1

  • Tracker changed from Bug to Backport
  • Project changed from Ruby to 13
  • Status changed from Open to Assigned
  • Assignee set to usa (Usaku NAKAMURA)

Updated by usa (Usaku NAKAMURA) almost 14 years ago Actions #2

  • Status changed from Assigned to Closed

This issue was solved with changeset r37208.
Andrew, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 34977: [Backport #5661]

* random.c (random_s_rand): ensure default PRNG is re-initialized
  after fork.  patched by Eric Wong.  [ruby-core:41209][Bug #5661]
Actions

Also available in: PDF Atom