2017-06-14 402 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構建的軟件包。你的解決方案可能會起作用,因爲它可以解決這種不匹配問題,所以我將其標記爲正確 - 但對我而言,重新啓動確實有效。 –