Commit 633307e
committed
Handle large read/write/sendfile to File; return actual bytes written
The return value for the `jl_fs_write/read/sendfile` functions is an `int`, even
through they all take `size_t` length arguments, resulting in potentially
truncated counts for large file operations. Instead, on success (including
partial read/write), we should return the `uv_fs_t.result` field.
I have added a test for this but have left it disabled because it allocates a 5
GiB Vector to read into.
One consequence of the truncated return values is that we previously mangled
large files while copying them with sendfile. If the return value is truncated
to a random negative value, it manifests as #30723 or #39868. If it is
truncated to a positive value, sendfile will create a very large destination
file with thousands of repeated sections of the source file, causing #56537.
The bug will only manifest if LLVM decides to zero-extend the return value.
This also changes `jl_fs_write` to return the actual number of bytes written,
rather than the number of bytes it was asked to write. If a write returns
EAGAIN (usually because the file is O_NONBLOCK/O_NODELAY), we never see the
actual number of bytes written.1 parent f513309 commit 633307e
3 files changed
+53
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
236 | 236 | | |
237 | | - | |
238 | | - | |
| 237 | + | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
587 | | - | |
| 586 | + | |
| 587 | + | |
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
595 | | - | |
| 595 | + | |
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
639 | 647 | | |
640 | 648 | | |
641 | 649 | | |
| |||
654 | 662 | | |
655 | 663 | | |
656 | 664 | | |
657 | | - | |
| 665 | + | |
658 | 666 | | |
659 | 667 | | |
660 | | - | |
| 668 | + | |
661 | 669 | | |
662 | 670 | | |
663 | 671 | | |
664 | 672 | | |
665 | 673 | | |
666 | 674 | | |
667 | 675 | | |
668 | | - | |
| 676 | + | |
669 | 677 | | |
670 | 678 | | |
671 | 679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2200 | 2200 | | |
2201 | 2201 | | |
2202 | 2202 | | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
0 commit comments