Backport #2559

IO#write raises Errno::EINVAL instead of expected Errno::EPIPE

Added by Hongli Lai about 2 years ago. Updated 9 months ago.

[ruby-core:27425]
Status:Closed Start date:01/06/2010
Priority:Normal Due date:
Assignee:Shyouhei Urabe % Done:

100%

Category:-
Target version:-

Description

Test case:

  require 'thread'

  a, b = IO.pipe
  Thread.new do
    a.read(1)
    a.close
  end

  sleep 0.1  # wait for thread to begin
  b.write("x" * (1024 * 16))  # should be larger than pipe/socket buffer size

b.write on 1.8.7-p174 raises Errno::EPIPE, as expected.
1.8.7-p248 raises Errno::EINVAL.

It looks like this bug was introduced in revision 25918. Unapplying that revision fixes the problem.

io-write-fix.diff (1.3 kB) Hongli Lai, 01/06/2010 03:37 am

Associated revisions

Revision 26253
Added by nobu about 2 years ago

* io.c (io_fwrite): preserve errno. [ruby-core:27425]

Revision 27913
Added by shyouhei over 1 year ago

merge revision(s) 26253: * io.c (io_fwrite): preserve errno. [ruby-core:27425]

History

Updated by Hongli Lai about 2 years ago

Simpler test case:

  a, b = IO.pipe
  a.close
  b.write("x")

Updated by Hongli Lai about 2 years ago

Attached patch fixes the problem. Includes unit test.

Updated by Nobuyoshi Nakada about 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r26253.
Hongli, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Updated by Nobuyoshi Nakada about 2 years ago

  • Status changed from Closed to Assigned
  • Assignee set to Shyouhei Urabe

Updated by Eric Wong almost 2 years ago

Nobuyoshi Nakada <redmine@ruby-lang.org> wrote:
> Issue #2559 has been updated by Nobuyoshi Nakada.
> 
> Status changed from Open to Closed
> % Done changed from 0 to 100
> 
> This issue was solved with changeset r26253.

This affects a FreeBSD user on 1.8.7-p248.  Can somebody please backport
this to the 1.8.7 branch?

Thanks

-- 
Eric Wong

Updated by Shyouhei Urabe over 1 year ago

  • Status changed from Assigned to Closed
This issue was solved with changeset r27913.
Hongli, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF