Forum: Ruby-core [ruby-trunk - Bug #8669][Open] outbuf can be "temporarily" locked forever in IO#read

C042517d59bed4761cc88681bf71fca8?d=identicon&s=25 Glass_saga (Masaki Matsushita) (Guest)
on 2013-07-23 11:07
(Received via mailing list)
Issue #8669 has been reported by Glass_saga (Masaki Matsushita).

----------------------------------------
Bug #8669: outbuf can be "temporarily" locked forever in IO#read
https://bugs.ruby-lang.org/issues/8669

Author: Glass_saga (Masaki Matsushita)
Status: Open
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: UNKNOWN, 2.0.0: UNKNOWN


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?
18813f71506ebad74179bf8c5a136696?d=identicon&s=25 Eric Wong (Guest)
on 2013-07-23 13:09
(Received via mailing list)
"Glass_saga (Masaki Matsushita)" <glass.saga@gmail.com> wrote:
> Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN

I can confirm the issue under 1.9.3-p448 and 2.0.0-p247

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

Nasty bug. I might've hit this soon in new project I'm working on(!)

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

Untested, but looks correct.  Thanks.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-07-24 04:46
(Received via mailing list)
Issue #8669 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Assigned
Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED,
2.0.0: REQUIRED

Seems fine.

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

----------------------------------------
Bug #8669: outbuf can be "temporarily" locked forever in IO#read
https://bugs.ruby-lang.org/issues/8669#change-40635

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?
C042517d59bed4761cc88681bf71fca8?d=identicon&s=25 Glass_saga (Masaki Matsushita) (Guest)
on 2013-07-25 06:59
(Received via mailing list)
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?
5cf8f058a4c094bb708174fb43e7a387?d=identicon&s=25 nagachika (Tomoyuki Chikanaga) (Guest)
on 2013-07-28 14:59
(Received via mailing list)
Issue #8669 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED to 1.9.3:
REQUIRED, 2.0.0: DONE

Backported to ruby_2_0_0 at r42216.
----------------------------------------
Bug #8669: outbuf can be "temporarily" locked forever in IO#read
https://bugs.ruby-lang.org/issues/8669#change-40739

Author: Glass_saga (Masaki Matsushita)
Status: Closed
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: DONE


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?
8cbb39dadafaf2287a83a13ee4981ec9?d=identicon&s=25 usa (Usaku NAKAMURA) (Guest)
on 2013-08-02 13:40
(Received via mailing list)
Issue #8669 has been updated by usa (Usaku NAKAMURA).

Backport changed from 1.9.3: REQUIRED, 2.0.0: DONE to 1.9.3: DONE,
2.0.0: DONE

Backported to ruby_1_9_3 at r42327.
----------------------------------------
Bug #8669: outbuf can be "temporarily" locked forever in IO#read
https://bugs.ruby-lang.org/issues/8669#change-40827

Author: Glass_saga (Masaki Matsushita)
Status: Closed
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: DONE, 2.0.0: DONE


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?
This topic is locked and can not be replied to.