Closed MichaelChirico closed 4 years ago
Here's how I could reliably trigger the problem (on Ubuntu 14.04) ...
## Make tempdir() unwritable system(paste("chmod a-w", tempdir()))
## compression is on by default pdf() ## Incorrect error message is in PDF_NewPage() plot.new() ## This triggers a segfault (for me at least) dev.off()
I have committed a fix to r-devel (r71752) so that, in addition to giving a better message (and not segfaulting), the error is now a warning and compression is turned off for the PDF device.
Thanks!
NA
NA
It's hard to reproduce this problem, but looking at the code it's pretty clear what the problem is.
In R-3.3.2/src/library/grDevices/src/devPS.c, function PDF_NewPage, around line 7221:
Note that tmp is freed before the error message is created. On my system, the memory manager appears to write a null byte at the beginning of the buffer when free() is called, resulting in this error message:
Error in plot.new() : cannot open file '', reason No such file or directory
The original problem is not R's bug -- I think the file system TMPDIR is pointing to gets unmounted by a long-running R job. However, the fact that the error message is broken made it harder for me to diagnose the problem. I don't know what kind of try/catch/finally mechanism R uses, but ideally free(tmp) would happen after error() is called.
Note also that R eventually dumps core, which I care about less than the broken error message.
0 0x00000037ff467934 in fwrite () from /lib64/libc.so.6
1 0x00002ae33b8c10e2 in PDF_endpage () at devPS.c:6509
2 0x00002ae33b8c284b in PDF_Close () at devPS.c:7257
3 0x00002ae338dbf05e in removeDevice.part.0 ()
from /broad/software/free/Linux/redhat_6_x86_64/pkgs/r_3.3.0/lib64/R/lib/libR.so
4 0x00002ae338dbf4c9 in Rf_KillAllDevices ()
from /broad/software/free/Linux/redhat_6_x86_64/pkgs/r_3.3.0/lib64/R/lib/libR.so
5 0x00002ae338ee42e4 in Rstd_CleanUp ()
from /broad/software/free/Linux/redhat_6_x86_64/pkgs/r_3.3.0/lib64/R/lib/libR.so
6 0x00002ae338e21947 in run_Rmainloop ()
from /broad/software/free/Linux/redhat_6_x86_64/pkgs/r_3.3.0/lib64/R/lib/libR.so
7 0x00000000004007bb in main () at Rmain.c:29
Thanks!
METADATA