[Rd] possible bug: stderr() connection truncates output at 8191 characters when R_Consolefile is not used

Gábor Csárdi csardi.gabor at gmail.com
Tue Apr 10 23:27:53 CEST 2018


This is recent R-devel, but AFAICT all R versions are affected.
Also AFAICT, currently only happens on macOS with Aqua, and on
Windows, unless you are in RTerm. These do not use R_Consolefile

Code to reproduce:

x <- paste0(strrep(".", 8191), "MIA")
nchar(x)
#> [1] 8194

## This is fine:
cat(x, file = stdout())

## This truncates silently:
cat(x, file = stderr())

It happens because the vfprintf callback of stderr() is stderr_vfprintf [1],
and that just calls REvprintf [2], which truncates at 8191 characters [3], if
R_Consolefile is not used.

[1] https://github.com/wch/r-source/blob/fed0444824567e1c4edff234fc5c2fb1c99bbc84/src/main/connections.c#L5122
[2] https://github.com/wch/r-source/blob/fed0444824567e1c4edff234fc5c2fb1c99bbc84/src/main/connections.c#L2562
[3] https://github.com/wch/r-source/blob/fed0444824567e1c4edff234fc5c2fb1c99bbc84/src/main/printutils.c#L972



More information about the R-devel mailing list