[PATCH] D39444: [Support] Make the default chunk size of raw_fd_ostream to 1 GiB.

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 20:07:46 PDT 2017


krytarowski added inline comments.


================
Comment at: llvm/lib/Support/raw_ostream.cpp:580
   pos += Size;
+  size_t MaxWriteSize = SIZE_MAX;
 
----------------
ruiu wrote:
> krytarowski wrote:
> > ```
> > If the value of nbyte is greater than {SSIZE_MAX}, the result is implementation-defined.
> > ```
> > 
> > http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html#tag_16_685
> Ah. Then, maybe that's what Saleem observed? The existing code could make a write request that is larger than SSIZE_MAX (= 2 GiB - 1) on a 32-bit machine.
> 
> If so, we can just remove the ifdef for Linux and use SSIZE_T as the default MaxWriteSize.
`SSIZE_MAX` is POSIX only (unless it was added to C++, but I don't see a reference).

NetBSD specific behavior allows length up to SSIZE_MAX:

```
	/*
	 * Writes return ssize_t because -1 is returned on error.  Therefore
	 * we must restrict the length to SSIZE_MAX to avoid garbage return
	 * values.
	 */
	if (auio.uio_resid > SSIZE_MAX) {
		error = EINVAL;
		goto out;
}
```

--- src/sys/kern/sys_generic.c


https://reviews.llvm.org/D39444





More information about the llvm-commits mailing list