From hb at biostat.ucsf.edu  Thu Apr  5 22:17:17 2012
From: hb at biostat.ucsf.edu (Henrik Bengtsson)
Date: Thu, 5 Apr 2012 13:17:17 -0700
Subject: [Rd] Unlikely use case of debug() that cause R to crash
Message-ID: <CAFDcVCTGsfYVwrnwV3VYG1Yhov1bQx_PDkxsDEPuL3Bv7FvufQ@mail.gmail.com>

FYI,

PROBLEM:
R will crash if one tries to use debug() during startup, i.e. in a
user profile file.


REPRODUCIBLE EXAMPLE:
Create ~/.Rprofile with:

cat("~/.Rprofile...\n")
debug(cat)
cat("~/.Rprofile...done\n")

and do

% R --no-environ --no-environ --no-restore --silent

~/.Rprofile...
debugging in: cat("~/.Rprofile...done\n")
debug: {
    if (is.character(file))
        if (file == "")
            file <- stdout()
        else if (substring(file, 1L, 1L) == "|") {
            file <- pipe(substring(file, 2L), "w")
            on.exit(close(file))
        }
        else {
            file <- file(file, ifelse(append, "a", "w"))
            on.exit(close(file))
        }
    .Internal(cat(list(...), file, sep, fill, labels, append))
}
Browse[2]>

R will crash as soon as you try to do anything at the debug prompt.


> sessionInfo()
R version 2.15.0 Patched (2012-04-03 r58917)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

/Henrik



[Rd] Unlikely use case of debug() that cause R to crash
Henrik Bengtsson