James Smith
2014-May-20 15:02 UTC
[Rd] Question about fifo behavior on Linux between versions 3.0.3 and 3.1.0
Version 3.1.0 of R has imposed a very small data limit on writing to fifos on Linux. Consider the following R code (Assumes that "ff" is a fifo in the R process's current directory): con <- fifo("ff", "a+b") writeBin(raw(12501), con) In R 3.0.3, this returns without error and the data is available on the fifo. In R 3.1.0, however, this returns the following error: Error in writeBin(raw(12501), con) : too large a block specified In investigating R's source, the difference seems to be in src/main/connections.c, in the function fifo_write() (around line 932). In R 3.0.3, fifo_write() has these lines: if ((double) size * (double) nitems > SSIZE_MAX) error(_("too large a block specified")); R 3.1.0 has these lines changed to this: if ((size * sizeof(wchar_t) * nitems) > 50000) { error(_("too large a block specified")); } The change effectively places a limit of 12500 bytes on writes (since sizeof(wchar_t) == 4). Does anyone know why this change was made? I understand that fifos on Windows were implemented for R 3.1.0, but the code for fifos on Windows is in a separate part of connections.c that doesn't get compiled on Linux (i.e., the code given is Unix only). I also couldn't find any references to fifo behavior changes under Linux in any of R's documentation. My platform is Fedora 20 (64-bit) and I have built and installed R from source. Thank you for your time and consideration. James O Smith Harmonia Holdings Group, LLC
Prof Brian Ripley
2014-May-20 19:03 UTC
[Rd] Question about fifo behavior on Linux between versions 3.0.3 and 3.1.0
It _was_ part of the fifo for Windows patch. As if does not seem to be needed for Windows, it has been reverted. On 20/05/2014 16:02, James Smith wrote:> Version 3.1.0 of R has imposed a very small data limit on writing to fifos on Linux. Consider the following R code (Assumes that "ff" is a fifo in the R process's current directory): > > con <- fifo("ff", "a+b") > writeBin(raw(12501), con) > > In R 3.0.3, this returns without error and the data is available on the fifo. In R 3.1.0, however, this returns the following error: > > Error in writeBin(raw(12501), con) : too large a block specified > > In investigating R's source, the difference seems to be in src/main/connections.c, in the function fifo_write() (around line 932). In R 3.0.3, fifo_write() has these lines: > > if ((double) size * (double) nitems > SSIZE_MAX) > error(_("too large a block specified")); > > R 3.1.0 has these lines changed to this: > > if ((size * sizeof(wchar_t) * nitems) > 50000) { > error(_("too large a block specified")); > } > > The change effectively places a limit of 12500 bytes on writes (since sizeof(wchar_t) == 4). Does anyone know why this change was made? I understand that fifos on Windows were implemented for R 3.1.0, but the code for fifos on Windows is in a separate part of connections.c that doesn't get compiled on Linux (i.e., the code given is Unix only). I also couldn't find any references to fifo behavior changes under Linux in any of R's documentation. > > My platform is Fedora 20 (64-bit) and I have built and installed R from source. > > Thank you for your time and consideration. > > James O Smith > Harmonia Holdings Group, LLC > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595