Project

General

Profile

Bug #4274

SEGFAULT: ARGF.gets will crash if first file is not readable!

Added by rbjl (Jan Lelis) almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p136 (2010-12-25) [i686-linux]
Backport:
[ruby-core:34446]

Description

=begin
Hi, welcome to crash golf ;).

ruby -e 'gets rescue gets' CRASH!

or some alternative forms of it:

ARGV.unshift 'filename_that_does_not_exist'
ARGF.gets rescue nil
ARGF.gets

or

$*.unshift'X'
$<.fileno rescue $<.fileno

However, if the first arg is readable, everything will be fine.

I've produced that error on various 1.9 versions.

1.8.7 (tested on p330) does not segfault, but displays a weird error message:

ruby -e 'gets rescue gets' CRASH!
-e:1:in gets': private methodgets' called for false:FalseClass (NoMethodError)

Appended the segfault info and a patch.

J-_-L
=end


Files

argf_segfault.segfault (1.38 KB) argf_segfault.segfault rbjl (Jan Lelis), 01/13/2011 05:45 AM
argf_segfault.backtrace (2.03 KB) argf_segfault.backtrace rbjl (Jan Lelis), 01/13/2011 05:45 AM
argf_segfault.patch (1023 Bytes) argf_segfault.patch rbjl (Jan Lelis), 01/13/2011 05:45 AM

History

#1

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

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

=begin
This issue was solved with changeset r30536.
Jan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF