https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112016-04-13T22:03:21ZRuby Issue Tracking SystemRuby master - Feature #12280: IO.copy_stream(IO, IO) fails with "pread() not implemented"https://redmine.ruby-lang.org/issues/12280?journal_id=580682016-04-13T22:03:21Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:eregontp@gmail.com" class="email">eregontp@gmail.com</a> wrote:</p>
<blockquote>
<p>IO.copy_stream on Windows with IO having an offset fails with:<br>
NotImplementedError: pread() not implemented</p>
<p>This seems suboptimal, should a clearer be reported?</p>
</blockquote>
<p>Not sure. Maybe include a bug report address to get pread<br>
implemented in Windows? :)</p>
<blockquote>
<p>Is it a platform limitation?</p>
</blockquote>
<p>Yes, it's a platform limitation.</p>
<p>lseek+read can be used to workaround the limitation in<br>
single-threaded programs only (and only as long as the FD is not<br>
shared across fork; maybe FD sharing across fork isn't possible<br>
in Windows...)</p>
<p>But I guess an error message is better than a racy workaround<br>
which can corrupt data with concurrent access.</p> Ruby master - Feature #12280: IO.copy_stream(IO, IO) fails with "pread() not implemented"https://redmine.ruby-lang.org/issues/12280?journal_id=580692016-04-13T22:12:30ZEregon (Benoit Daloze)
<ul></ul><p>Eric Wong wrote:</p>
<blockquote>
<p><a href="mailto:eregontp@gmail.com" class="email">eregontp@gmail.com</a> wrote:</p>
<blockquote>
<p>IO.copy_stream on Windows with IO having an offset fails with:<br>
NotImplementedError: pread() not implemented</p>
<p>This seems suboptimal, should a clearer be reported?</p>
</blockquote>
<p>Not sure. Maybe include a bug report address to get pread<br>
implemented in Windows? :)</p>
<blockquote>
<p>Is it a platform limitation?</p>
</blockquote>
<p>Yes, it's a platform limitation.</p>
<p>lseek+read can be used to workaround the limitation in<br>
single-threaded programs only (and only as long as the FD is not<br>
shared across fork; maybe FD sharing across fork isn't possible<br>
in Windows...)</p>
<p>But I guess an error message is better than a racy workaround<br>
which can corrupt data with concurrent access.</p>
</blockquote>
<p>Thanks for the quick reply!</p>
<p>For me, having a message like:<br>
"NotImplementedError: IO.copy_stream with offset is not supported on Windows since it is not atomic"<br>
would be a good enough fix for this.</p> Ruby master - Feature #12280: IO.copy_stream(IO, IO) fails with "pread() not implemented"https://redmine.ruby-lang.org/issues/12280?journal_id=583472016-04-27T06:06:23Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>Benoit Daloze wrote:</p>
<blockquote>
<p>For me, having a message like:<br>
"NotImplementedError: IO.copy_stream with offset is not supported on Windows since it is not atomic"<br>
would be a good enough fix for this.</p>
</blockquote>
<p>IO.copy_stream is a utility method.<br>
It works as expected and fast if there's a suitable API like sendfile.</p>
<p>On this precondition, IO.copy_stream should work even on Windows.<br>
You can simply acquire GVL or fine grained lock to achieve multithread safety.</p>
<p>Anyway you can provide pread with ReadFile.<br>
You may know, on Windows read() is our own function and the real name is rb_w32_read.<br>
You can implement rb_w32_pread with ReadFile in win32/win32.c.</p> Ruby master - Feature #12280: IO.copy_stream(IO, IO) fails with "pread() not implemented"https://redmine.ruby-lang.org/issues/12280?journal_id=583632016-04-28T05:27:30Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>+1 to add a fallback implementation when pread is unavailable.</p> Ruby master - Feature #12280: IO.copy_stream(IO, IO) fails with "pread() not implemented"https://redmine.ruby-lang.org/issues/12280?journal_id=583652016-04-28T05:51:33Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:naruse@airemix.jp" class="email">naruse@airemix.jp</a> wrote:</p>
<blockquote>
<p>Benoit Daloze wrote:</p>
<blockquote>
<p>For me, having a message like:<br>
"NotImplementedError: IO.copy_stream with offset is not supported on Windows since it is not atomic"<br>
would be a good enough fix for this.</p>
</blockquote>
<p>IO.copy_stream is a utility method.<br>
It works as expected and fast if there's a suitable API like sendfile.</p>
<p>On this precondition, IO.copy_stream should work even on Windows.<br>
You can simply acquire GVL or fine grained lock to achieve multithread safety.</p>
</blockquote>
<p>Can open files be shared across processes in Windows?<br>
If so, thread-safety is not enough; pread provides atomicity across<br>
forked processes (and also send_io/recv_io) in *nix; not just threads.</p>
<blockquote>
<p>Anyway you can provide pread with ReadFile.<br>
You may know, on Windows read() is our own function and the real name is rb_w32_read.<br>
You can implement rb_w32_pread with ReadFile in win32/win32.c.</p>
</blockquote>
<p>Anyways, I'll leave Windows devs to implement if it is possible<br>
and safe :)</p> Ruby master - Feature #12280: IO.copy_stream(IO, IO) fails with "pread() not implemented"https://redmine.ruby-lang.org/issues/12280?journal_id=1042312023-08-23T17:50:02Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Feature</i></li><li><strong>Backport</strong> deleted (<del><i>2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN</i></del>)</li></ul>