2017-06-14 401 views
1

每当我尝试使用ggplot2的函数geom_smooth()时,我得到一个段错误。我发现这个问题是由于mcgv软件包造成的,这是一个R推荐的软件包,只要包含它就会出现段错误。下面是从它的安装输出:在R中安装mgcv软件包时发生Segfault

> install.packages('mgcv') 
Installing package into ‘/home/<username>/R/x86_64-pc-linux-gnu-library/3.4’ 
(as ‘lib’ is unspecified) 
trying URL 'https://cran.rstudio.com/src/contrib/mgcv_1.8-17.tar.gz' 
Content type 'unknown' length 849787 bytes (829 KB) 
================================================== 
downloaded 829 KB 
* installing *source* package ‘mgcv’ ... 
** package ‘mgcv’ successfully unpacked and MD5 sums checked 
** libs 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c coxph.c -o coxph.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c discrete.c -o discrete.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c gdi.c -o gdi.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c init.c -o init.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c magic.c -o magic.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c mat.c -o mat.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c matrix.c -o matrix.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c mgcv.c -o mgcv.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c misc.c -o misc.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c mvn.c -o mvn.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c qp.c -o qp.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c soap.c -o soap.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c sparse-smooth.c -o sparse-smooth.o 
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fopenmp -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c tprs.c -o tprs.o 
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o mgcv.so coxph.o discrete.o gdi.o init.o magic.o mat.o matrix.o mgcv.o misc.o mvn.o qp.o soap.o sparse-smooth.o tprs.o -L/usr/lib64/R/lib -lRlapack -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lquadmath -fopenmp -L/usr/lib64/R/lib -lR 
installing to /home/<username>/R/x86_64-pc-linux-gnu-library/3.4/mgcv/libs 
** R 
** data 
** inst 
** byte-compile and prepare package for lazy loading 
Warning in fun(libname, pkgname) : 
    bytecode version mismatch; using eval 
Warning: package ‘nlme’ was built under R version 3.4.0 
*** caught segfault *** 
address 0x6, cause 'memory not mapped' 
Traceback: 
1: dyn.load(file, DLLpath = DLLpath, ...) 
2: library.dynam(lib, package, package.lib) 
3: loadNamespace(package, lib.loc) 
4: doTryCatch(return(expr), name, parentenv, handler) 
5: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 
6: tryCatchList(expr, classes, parentenv, handlers) 
7: 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 = stderr())  .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error", condition = e))}) 
8: try({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps)}) 
9: library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc,  quietly = quietly) 
10: .getRequiredPackages2(pkgInfo, quietly, lib.loc, useImports) 
11: .getRequiredPackages(quietly = TRUE) 
12: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart("muffleMessage")) 
13: suppressPackageStartupMessages(.getRequiredPackages(quietly = TRUE)) 
14: doTryCatch(return(expr), name, parentenv, handler) 
15: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 
16: tryCatchList(expr, classes, parentenv, handlers) 
17: 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 = stderr())  .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error", condition = e))}) 
18: try({ suppressPackageStartupMessages(.getRequiredPackages(quietly = TRUE)) makeLazyLoading(pkg_name, lib, keep.source = keep.source)}) 
19: do_install_source(pkg_name, instdir, pkg, desc) 
20: do_install(pkg) 
21: tools:::.install_packages() 
An irrecoverable exception occurred. R is aborting now ... 
/usr/lib64/R/bin/INSTALL: line 34: 36723 Done     echo 'tools:::.install_packages()' 
    36724 Segmentation fault  | R_DEFAULT_PACKAGES= LC_COLLATE=C "${R_HOME}/bin/R" $myArgs --slave --args ${args} 
Warning in install.packages : 
    installation of package ‘mgcv’ had non-zero exit status 

这里是我的R版本:

> R.version 
       _       
platform  x86_64-redhat-linux-gnu  
arch   x86_64      
os    linux-gnu     
system   x86_64, linux-gnu   
status          
major   3       
minor   3.3       
year   2017       
month   03       
day   06       
svn rev  72310      
language  R       
version.string R version 3.3.3 (2017-03-06) 
nickname  Another Canoe 

有什么想法,什么是怎么回事?

回答

1

将您的R版升级到3.4.0。特别是,编译mgcv是成功的(因为您已达到字节编译阶段)。问题是与它相关的包nlme,这将会要求版本3.4.0

sudo apt-get update 
sudo apt-get upgrade 

我认为一旦你升级R,你不需要做任何事情。 mgcvnlme也会自动升级,因为它们是“推荐”的。

我会给它一个镜头 - 但不幸的是,我没有sudo在这台机器上,所以它需要一段时间才能尝试升级。我想知道是否有任何解决办法可以在此期间尝试。

您是否需要安装额外版本的mgcv?为什么不只是做library(mgcv)并使用与您当前R版本兼容的那个?


允许我重新制定The_Anomaly的决赛中,本地解决方案:

我正确地重新启动[R工作室的R对话后(即手动重启,不只是从崩溃中恢复),我再也无法装载任何我已安装的软件包。所以我开始看.libPaths(),但是发现令人惊讶的是文件夹“R/x86_64-redhat-linux-gnu-library/3.3”没有我的软件包,但是另一个文件夹“.../3.4”没有。出于某种原因,在重新启动之前,R版本3.3使用为R 3.4构建的软件包。你的解决方案可能会起作用,因为它可以解决这种不匹配问题,所以我将其标记为正确 - 但对我而言,重新启动确实有效。

+0

我会给它一个镜头 - 但不幸的是,我没有sudo在这台机器上,所以它需要一段时间来尝试升级。我想知道是否有任何解决办法可以在此期间尝试。 –

+1

在我正确重新启动R studio的R会话(即手动重新启动,而不仅仅是从崩溃中恢复)后,无法再加载我已安装的任何软件包。看完.libPaths()后,我发现文件夹“ R/x86_64-redhat-linux-gnu-library/3.3”没有我的软件包,但另一个文件夹“.../3.4”确实有我的软件包。出于某种原因,在重新启动之前,R版本3.3使用为R 3.4构建的软件包。你的解决方案可能会起作用,因为它可以解决这种不匹配问题,所以我将其标记为正确 - 但对我而言,重新启动确实有效。 –