Project

General

Profile

Actions

Bug #17661

closed

IO#each will segfault when if file is closed inside an `each_byte` block

Added by tenderlovemaking (Aaron Patterson) about 3 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:102634]

Description

As reported here: https://twitter.com/asterite/status/1363487990203506689 when iterating through a file's contents with #each_byte, if the filehandle is closed inside of the block yielded to by #each byte, this condition is not detected, and a segmentation fault is thrown.

Repro:

file = http://File.open(__FILE__)
file.each_byte do |byte|
  p byte
  file.close
end

Proposed fix is here: https://github.com/ruby/ruby/pull/4217

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0