Project

General

Profile

Bug #13753 ยป 0001-Re-initialise-Random-DEFAULT-after-forking-Bug-13753.patch

owst (Owen Stephens), 07/18/2017 04:41 PM

View differences:

random.c
1568 1568
{
1569 1569
    rb_random_t *r = &default_rand;
1570 1570
    uninit_genrand(&r->mt);
1571
    r->seed = INT2FIX(0);
1571
    rand_start(r);
1572 1572
}
1573 1573

  
1574 1574
/*
test/ruby/test_rand.rb
456 456
  rescue NotImplementedError
457 457
  end
458 458

  
459
  def test_default_rand_reseed_after_fork
460
    r1 = Random::DEFAULT.rand(42).to_s
461
    r2 = assert_fork_status(1, 'Random::DEFAULT reseed after fork') {  Random::DEFAULT.rand(42) }
462

  
463
    assert_not_equal(r1, r2, 'Random::DEFAULT correctly reseeded after fork')
464
  end
465

  
459 466
  def test_seed
460 467
    bug3104 = '[ruby-core:29292]'
461 468
    rand_1 = Random.new(-1).rand
462
-