eddelbuettel / rcppcnpy

Rcpp bindings for NumPy files
GNU General Public License v2.0
26 stars 16 forks source link

Segmentation fault at the installation of the package #24

Closed pierremac closed 5 years ago

pierremac commented 5 years ago

Hello,

I'm a complete R newbie. Sorry if it's something "obvious". I'm trying to install the RcppCNPy package on my local computer and I get a segfault:

> install.packages('RcppCNPy', repos='http://cran.us.r-project.org')
trying URL 'http://cran.us.r-project.org/src/contrib/RcppCNPy_0.2.10.tar.gz'
Content type 'application/x-gzip' length 374200 bytes (365 KB)
==================================================
downloaded 365 KB

* installing *source* package ‘RcppCNPy’ ...
** package ‘RcppCNPy’ successfully unpacked and MD5 sums checked
** libs
g++ -std=gnu++11 -I/home/pierre/anaconda3/envs/Rstuff/lib/R/include -DNDEBUG  -I"/home/pierre/anaconda3/envs/Rstuff/lib/R/library/Rcpp/include" -I/home/pierre/anaconda3/envs/Rstuff/include   -fpic  -I/home/pierre/anaconda3/envs/Rstuff/include -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I/home/pierre/anaconda3/envs/Rstuff/lib/R/include -DNDEBUG  -I"/home/pierre/anaconda3/envs/Rstuff/lib/R/library/Rcpp/include" -I/home/pierre/anaconda3/envs/Rstuff/include   -fpic  -I/home/pierre/anaconda3/envs/Rstuff/include -c cnpy.cpp -o cnpy.o
g++ -std=gnu++11 -I/home/pierre/anaconda3/envs/Rstuff/lib/R/include -DNDEBUG  -I"/home/pierre/anaconda3/envs/Rstuff/lib/R/library/Rcpp/include" -I/home/pierre/anaconda3/envs/Rstuff/include   -fpic  -I/home/pierre/anaconda3/envs/Rstuff/include -c cnpyMod.cpp -o cnpyMod.o
g++ -std=gnu++11 -shared -L/home/pierre/anaconda3/envs/Rstuff/lib/R/lib -L/home/pierre/anaconda3/envs/Rstuff/lib -lgfortran -o RcppCNPy.so RcppExports.o cnpy.o cnpyMod.o -lz -L/home/pierre/anaconda3/envs/Rstuff/lib/R/lib -lR
installing to /home/pierre/anaconda3/envs/Rstuff/lib/R/library/RcppCNPy/libs
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

 *** caught segfault ***
address 0x20, cause 'memory not mapped'

Traceback:
 1: .Call(Module__functions_names, xp)
 2: Module(module, mustStart = TRUE, where = env)
 3: doTryCatch(return(expr), name, parentenv, handler)
 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 5: tryCatchList(expr, classes, parentenv, handlers)
 6: tryCatch(Module(module, mustStart = TRUE, where = env), error = function(e) e)
 7: loadModule(module = "cnpy", what = TRUE, env = ns, loadNow = TRUE)
 8: (function (ns) loadModule(module = "cnpy", what = TRUE, env = ns, loadNow = TRUE))(<environment>)
 9: doTryCatch(return(expr), name, parentenv, handler)
10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
11: tryCatchList(expr, classes, parentenv, handlers)
12: tryCatch((function (ns) loadModule(module = "cnpy", what = TRUE, env = ns, loadNow = TRUE))(<environment>),     error = function(e) e)
13: eval(substitute(tryCatch(FUN(WHERE), error = function(e) e),     list(FUN = f, WHERE = where)), where)
14: eval(substitute(tryCatch(FUN(WHERE), error = function(e) e),     list(FUN = f, WHERE = where)), where)
15: .doLoadActions(where, attach)
16: methods::cacheMetaData(ns, TRUE, ns)
17: loadNamespace(package, lib.loc)
18: doTryCatch(return(expr), name, parentenv, handler)
19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
20: tryCatchList(expr, classes, parentenv, handlers)
21: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
22: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE)
23: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart("muffleMessage"))
24: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE))
25: doTryCatch(return(expr), name, parentenv, handler)
26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
27: tryCatchList(expr, classes, parentenv, handlers)
28: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
29: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE)))
30: tools:::.test_load_package("RcppCNPy", "/home/pierre/anaconda3/envs/Rstuff/lib/R/library")
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault (core dumped)
ERROR: loading failed
* removing ‘/home/pierre/anaconda3/envs/Rstuff/lib/R/library/RcppCNPy’

The downloaded source packages are in
    ‘/tmp/Rtmpvu9zdk/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("RcppCNPy", repos = "http://cran.us.r-project.org") :
  installation of package ‘RcppCNPy’ had non-zero exit status

Any idea? Thanks!

eddelbuettel commented 5 years ago

That is not a bug in the package -- see the CRAN status page.

What you are seeing is typically due to object code mixed from different compilers. Try to install all CRAN package in the foodchain for RcppCNPy ... which in this case is only Rcpp.

Also, I do not use Anaconda. I have no doubt it works for some people who know what they are doing. But I do see a fair number of posts on StackOverflow and here where people have trouble mixing Anaconda and R. So if in doubt -- don't do that. As CRAN shows, it works fine in a clean and consistent environment.

I'll close this. Feel free to reopen if you can identify a pertinent issue, and feel free to use the rcpp-devel for Rcpp related questions.