From edd at debian.org  Sun Jul 14 18:20:07 2013
From: edd at debian.org (Dirk Eddelbuettel)
Date: Sun, 14 Jul 2013 11:20:07 -0500
Subject: [Rd] unmapped memory core dump with pure R program?
In-Reply-To: <CAPr7RtUtH37P5e0W8YcFsaJA5VTj3+MhHFJCVpzcwSbzHdsiDg@mail.gmail.com>
References: <CAPr7RtXJMjJ6m8T+LNLQ4_+-ggDXLiXZPLxRJujHSxV5MyYCnQ@mail.gmail.com>
	<20962.30029.747172.113244@max.nulle.part>
	<CAPr7RtVobwHEj20X2JqG7DHWs_VyEgAeLfX7V0jp4sn=Dk36Hw@mail.gmail.com>
	<E085E85D-5C7C-438B-85CE-2503B1572775@r-project.org>
	<CAPr7RtUtH37P5e0W8YcFsaJA5VTj3+MhHFJCVpzcwSbzHdsiDg@mail.gmail.com>
Message-ID: <20962.53175.179933.607310@max.nulle.part>


On 14 July 2013 at 09:04, ivo welch wrote:
| thanks, simon.  it's replicable even on
| 
|    R version 3.0.1 Patched (2013-07-13 r63293) -- "Good Sport"
| 
| (I presume that it is loading its own updated dynamic libraries when I
| installed it in a temporary directory and am invoking it as
| "temp/R-patched/bin/R", and not the system-wide unpatched version.)  the

It "should" stay within its own tree. I call my r-devel builds with a
two-line shell script wrapper to make sure its bin/ directory is prefixed to
the $PATH. 

| program that causes it is small enough to be displayable
| 
| if (interactive()) options(error=recover)
| year <- 1982
| 
| for (yr in (year-6):year) {
|     ifname <- paste0("dbetas/dbetas-",yr, ".Rdata")

That is obviously NOT reproducible as we do not have your files.

If possible, please create a _self-contained reproducible script_ as it ought
to be possible to create such data matrices with random data.

Dirk

|     load(ifname)
|     print(head(dbetas,2))  ## if you remove this, then the core dump goes
| away
|     dm <- if (!exists("dm")) dbetas else rbind(dm, dbetas)
|     cat("[Loaded ", yr,"]\n")
| }
| cat("\n[", now(), "Loaded All Data]\n")
| 
| 
| Reproducing the error,
| 
| # r-devel/R-patched/bin/R --vanilla
| 
| R version 3.0.1 Patched (2013-07-13 r63293) -- "Good Sport"
| Copyright (C) 2013 The R Foundation for Statistical Computing
| Platform: x86_64-unknown-linux-gnu (64-bit)
| 
| R is free software and comes with ABSOLUTELY NO WARRANTY.
| You are welcome to redistribute it under certain conditions.
| Type 'license()' or 'licence()' for distribution details.
| 
|   Natural language support but running in an English locale
| 
| R is a collaborative project with many contributors.
| Type 'contributors()' for more information and
| 'citation()' on how to cite R or R packages in publications.
| 
| Type 'demo()' for some demos, 'help()' for on-line help, or
| 'help.start()' for an HTML browser interface to help.
| Type 'q()' to quit R.
| 
| > source("coredump.R")
|       permno yyyymmdd lagmval        beta
| 31303  10006 19760102  219450 -0.81162794
| 31304  10006 19760105  218025 -0.01280477
| [Loaded  1976 ]
|       permno yyyymmdd  lagmval       beta
| 31556  10006 19770103 304709.4  4.5770379
| 31557  10006 19770104 301456.2 -0.3810519
| [Loaded  1977 ]
|       permno yyyymmdd  lagmval     beta
| 31808  10006 19780103 301219.5 1.277823
| 31809  10006 19780104 296854.0 2.671327
| [Loaded  1978 ]
|       permno yyyymmdd  lagmval        beta
| 32060  10006 19790102 269308.5 -0.06000999
| 32061  10006 19790103 269308.5 -0.83697042
| [Loaded  1979 ]
|       permno yyyymmdd  lagmval       beta
| 32313  10006 19800102 303420.8 -0.3768525
| 32314  10006 19800103 305635.5  2.2475787
| Error in rbind(deparse.level, ...) :
|   'pairlist' object cannot be coerced to type 'double'
| 
| Enter a frame number, or 0 to exit
| 
| 1: source("coredump.R")
| 2: withVisible(eval(ei, envir))
| 3: eval(ei, envir)
| 4: eval(expr, envir, enclos)
| 5: coredump.R#8: rbind(dm, dbetas)
| 6: rbind(deparse.level, ...)
| 
| Selection: 6
| Called from: eval(substitute(browser(skipCalls = skip), list(skip = 7 -
| which)),
|     envir = sys.frame(which))
| Browse[1]> head(dm)
|       permno yyyymmdd lagmval        beta
| 31303  10006 19760102  219450 -0.81162794
| 31304  10006 19760105  218025 -0.01280477
| 31305  10006 19760106  218025  7.26041268
| 31306  10006 19760107  236550 -1.23044474
| 31307  10006 19760108  235125  3.02461687
| 31308  10006 19760109  239400  2.04868169
| Browse[1]> head(rbind(dm,dbetas))
| 
|  *** caught segfault ***
| address 0x10, cause 'memory not mapped'
| 
| Traceback:
|  1: rbind(deparse.level, ...)
|  2: rbind(dm, dbetas)
|  3: head(rbind(dm, dbetas))
|  4: eval(expr, envir, enclos)
|  5: eval(substitute(browser(skipCalls = skip), list(skip = 7 - which)),
| envir = sys.frame(which))
|  6: (function () {    if (.isMethodsDispatchOn()) {        tState <-
| tracingState(FALSE)        on.exit(tracingState(tState))    }    calls <-
| sys.calls()    from <- 0L    n <- length(calls)    if
| (identical(sys.function(n), recover))         n <- n - 1L    for (i in
| rev(seq_len(n))) {        calli <- calls[[i]]        fname <- calli[[1L]]
|      if (!is.na(match(deparse(fname)[1L], c("methods::.doTrace",
|   ".doTrace")))) {            from <- i - 1L            break        }    }
|    if (from == 0L)         for (i in rev(seq_len(n))) {            calli <-
| calls[[i]]            fname <- calli[[1L]]            if (!is.name(fname)
| || is.na(match(as.character(fname),                 c("recover", "stop",
| "Stop")))) {                from <- i                break            }
|    }    if (from > 0L) {        if (!interactive()) {
|  try(dump.frames())            cat(gettext("recover called
| non-interactively; frames dumped, use debugger() to view\n"))
|  return(NULL)        }        else if
| (identical(getOption("show.error.messages"),             FALSE))
|   return(NULL)        calls <- limitedLabels(calls[1L:from])        repeat
| {            which <- menu(calls, title = "\nEnter a frame number, or 0 to
| exit  ")            if (which)
| eval(substitute(browser(skipCalls = skip), list(skip = 7 -
|   which)), envir = sys.frame(which))            else break        }    }
|  else cat(gettext("No suitable frames for recover()\n"))})()
|  7: rbind(deparse.level, ...)
|  8: rbind(dm, dbetas)
|  9: eval(expr, envir, enclos)
| 10: eval(ei, envir)
| 11: withVisible(eval(ei, envir))
| 12: source("coredump.R")
| 
| Possible actions:
| 1: abort (with core dump, if enabled)
| 2: normal R exit
| 3: exit R without saving workspace
| 4: exit R saving workspace
| Selection:
| 
| 
| the data files used are about 60mb.  this is all happening on a home
| machine, which is not easy to ssh into.  however, I can bring it into the
| office and see if I can replicate it there, too.  if I can, I could put it
| up and give you an account on my machine.  or I can tar it up incl the data
| and put it somewhere for download.  whatever you prefer.
| 
| regards,
| 
| /iaw
| ----
| Ivo Welch (ivo.welch at gmail.com)
| 
| 	[[alternative HTML version deleted]]
| 
| ______________________________________________
| R-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



[Rd] unmapped memory core dump with pure R program?
Dirk Eddelbuettel