Issue #8669 has been updated by Glass_saga (Masaki Matsushita).

File io_fread_callback.diff added
File read_internal_callback.diff added

> Furthermore, should we introduce a function to callback with locking temporarily?

I made rb_str_locktmp_ensure() to callback with locktmp.
----------------------------------------
Bug #8669: outbuf can be "temporarily" locked forever in IO#read
https://bugs.ruby-lang.org/issues/8669#change-40660

Author: Glass_saga (Masaki Matsushita)
Status: Assigned
Priority: Normal
Assignee: Glass_saga (Masaki Matsushita)
Category: core
Target version: current: 2.1.0
ruby -v: ruby 2.1.0dev (2013-07-23 trunk 42132) [x86_64-linux]
Backport: 1.9.3: REQUIRED, 2.0.0: REQUIRED


Following code make outbuf "temporarily" locked forever.
It is needed to ensure rb_str_unlocktmp().

str = ""
t = Thread.new(str) do |str|
  r, = IO.pipe
  r.read(nil, str)
end
sleep 1
t.raise
sleep 1
str.clear #=> can't modify string; temporarily locked (RuntimeError)

I have attached two patches.
One fixes io_fread(), another does io_getpartial() and rb_io_sysread().
May I commit these changes?


-- 
http://bugs.ruby-lang.org/