William Dunlap
2017-Nov-09 00:43 UTC
[Rd] check does not check that package examples remove tempdir()
I was looking at the CRAN package 'bfork-0.1.2', which exposes the Unix fork() and waitpid() calls at the R code level, and noticed that the help file example for bfork::fork removes R's temporary directory, the value of tempdir(). I think it happens because the forked process shares the value of tempdir() with the parent process and removes it when it exits. This seems like a serious problem - should 'check' make sure that running code in a package's examples, vignettes, etc. leaves tempdir() intact?> dir.exists(tempdir())[1] TRUE> library(bfork) > example(fork)fork> ## create a function to be run as a separate process fork> fn <- function() { fork+ Sys.sleep(4) fork+ print("World!") fork+ } fork> ## fork the process fork> pid <- fork(fn) fork> ## do work in the parent process fork> print("Hello") [1] "Hello" fork> ## wait for the child process fork> waitpid(pid) [1] "World!" [1] 7063> dir.exists(tempdir())[1] FALSE Bill Dunlap TIBCO Software wdunlap tibco.com [[alternative HTML version deleted]]
Henrik Bengtsson
2017-Nov-09 00:55 UTC
[Rd] check does not check that package examples remove tempdir()
Related to this problem - from R-devel NEWS (https://cran.r-project.org/doc/manuals/r-devel/NEWS.html): * tempdir(check = TRUE) recreates the tmpdir() if it is no longer valid (e.g. because some other process has cleaned up the ?/tmp? directory). Not sure if there's a plan to make check = TRUE the default though. /Henrik On Wed, Nov 8, 2017 at 4:43 PM, William Dunlap via R-devel <r-devel at r-project.org> wrote:> I was looking at the CRAN package 'bfork-0.1.2', which exposes the Unix > fork() and waitpid() calls at the R code level, and noticed that the help > file example for bfork::fork removes R's temporary directory, the value of > tempdir(). I think it happens because the forked process shares the value > of tempdir() with the parent process and removes it when it exits. > > This seems like a serious problem - should 'check' make sure that running > code in a package's examples, vignettes, etc. leaves tempdir() intact? > >> dir.exists(tempdir()) > [1] TRUE >> library(bfork) >> example(fork) > > fork> ## create a function to be run as a separate process > fork> fn <- function() { > fork+ Sys.sleep(4) > fork+ print("World!") > fork+ } > > fork> ## fork the process > fork> pid <- fork(fn) > > fork> ## do work in the parent process > fork> print("Hello") > [1] "Hello" > > fork> ## wait for the child process > fork> waitpid(pid) > [1] "World!" > [1] 7063 >> dir.exists(tempdir()) > [1] FALSE > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
William Dunlap
2017-Nov-09 01:01 UTC
[Rd] check does not check that package examples remove tempdir()
I think recreating tempdir() is ok in an emergency situation, but package code should not be removing tempdir() - it may contain important information. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Nov 8, 2017 at 4:55 PM, Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote:> Related to this problem - from R-devel NEWS > (https://cran.r-project.org/doc/manuals/r-devel/NEWS.html): > > * tempdir(check = TRUE) recreates the tmpdir() if it is no longer > valid (e.g. because some other process has cleaned up the ?/tmp? > directory). > > Not sure if there's a plan to make check = TRUE the default though. > > /Henrik > > On Wed, Nov 8, 2017 at 4:43 PM, William Dunlap via R-devel > <r-devel at r-project.org> wrote: > > I was looking at the CRAN package 'bfork-0.1.2', which exposes the Unix > > fork() and waitpid() calls at the R code level, and noticed that the help > > file example for bfork::fork removes R's temporary directory, the value > of > > tempdir(). I think it happens because the forked process shares the > value > > of tempdir() with the parent process and removes it when it exits. > > > > This seems like a serious problem - should 'check' make sure that running > > code in a package's examples, vignettes, etc. leaves tempdir() intact? > > > >> dir.exists(tempdir()) > > [1] TRUE > >> library(bfork) > >> example(fork) > > > > fork> ## create a function to be run as a separate process > > fork> fn <- function() { > > fork+ Sys.sleep(4) > > fork+ print("World!") > > fork+ } > > > > fork> ## fork the process > > fork> pid <- fork(fn) > > > > fork> ## do work in the parent process > > fork> print("Hello") > > [1] "Hello" > > > > fork> ## wait for the child process > > fork> waitpid(pid) > > [1] "World!" > > [1] 7063 > >> dir.exists(tempdir()) > > [1] FALSE > > > > > > Bill Dunlap > > TIBCO Software > > wdunlap tibco.com > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]
Jeroen Ooms
2017-Nov-10 15:19 UTC
[Rd] check does not check that package examples remove tempdir()
On Thu, Nov 9, 2017 at 1:43 AM, William Dunlap via R-devel <r-devel at r-project.org> wrote:> I was looking at the CRAN package 'bfork-0.1.2', which exposes the Unix > fork() and waitpid() calls at the R code level, and noticed that the help > file example for bfork::fork removes R's temporary directory, the value of > tempdir(). I think it happens because the forked process shares the value > of tempdir() with the parent process and removes it when it exits.This has come up a few times: - https://stat.ethz.ch/pipermail/r-devel/2017-February/073748.html - https://stat.ethz.ch/pipermail/r-devel/2017-April/074149.html You may want to read up on the latter discussion.
Maybe Matching Threads
- check does not check that package examples remove tempdir()
- check does not check that package examples remove tempdir()
- tempdir() may be deleted during long-running R session
- tempdir() may be deleted during long-running R session
- tempdir() may be deleted during long-running R session