Project

General

Profile

Actions

Bug #1859

closed

Random#int Segfaults with Non-Integer Ranges

Added by runpaint (Run Paint Run Run) almost 15 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-08-01 trunk 24343) [i686-linux]
Backport:
[ruby-core:24679]

Description

=begin
$ ruby -e 'Random.new.int(3.1..4)'
-e:1: [BUG] Segmentation fault
ruby 1.9.2dev (2009-08-01 trunk 24343) [i686-linux]

-- control frame ----------
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :int
c:0003 p:0027 s:0006 b:0006 l:001edc d:00244c EVAL -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001edc d:001edc TOP

-e:1:in <main>' -e:1:in int'

-- C level backtrace information -------------------------------------------
ruby(rb_vm_bugreport+0xb5) [0x8165715]
ruby [0x81a117b]
ruby(rb_bug+0x28) [0x81a1208]
ruby [0x80fa1d5]
[0xb7fc1410]
ruby [0x80c5338]
ruby(rb_random_int+0x4f) [0x80c5d7f]
ruby [0x8151877]
ruby [0x8162025]
ruby [0x8156105]
ruby [0x815ca32]
ruby(rb_iseq_eval_main+0x1a3) [0x815cc93]
ruby(ruby_exec_node+0x97) [0x805d6a7]
ruby(ruby_run_node+0x46) [0x805ef86]
ruby(main+0x60) [0x805cac0]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7de1775]
ruby [0x805c9c1]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted
=end

Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24358.
=end

Actions #2

Updated by runpaint (Run Paint Run Run) almost 15 years ago

=begin
Thanks, nobu. Could you double check the bounds for a Float..Integer Range? #int(3.1..5) seems to be resolved to #int(3...5):

prng = Random.new(2)
=> #Random:0x92fd6c8
20.times.map { prng.int(3.1..5) }
=> [3, 4, 4, 3, 3, 4, 3, 4, 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 3, 3]
prng = Random.new(2)
=> #Random:0x92ee27c
20.times.map { prng.int(3..5) }
=> [3, 4, 3, 5, 5, 3, 5, 4, 4, 5, 3, 3, 3, 4, 5, 3, 5, 5, 5, 4]

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0