caught segfault - 'memory not mapped' error in R

后端 未结 3 1615
自闭症患者
自闭症患者 2021-02-12 13:26

I have a problem running some R scripts on our cluster. The problems appeared suddenly (all the scripts were working just fine but one day they started giving a caught seg

相关标签:
3条回答
  • 2021-02-12 14:06

    It is highly recommended to clean the workspace, probably it is the core problem:

    unlink(".RData")

    0 讨论(0)
  • 2021-02-12 14:08

    The problem is a mismatch between currently installed shared libraries and the libraries that were built to install R or packages.

    I got this error for the first time today. See below. I've solved it, can explain situation.

    This is an Ubuntu system that was recently upgraded from 17.10 to 18.04, running R-3.4.4. A lot of C and C++ libraries were replaced. But not all programs were replaced. Immediately I noticed that lots of programs were getting segmentation faults. Anything that touched the tidyverse was a fail. The stringi package could not find the shared libraries with which it was compiled.

    The example here is a bit interesting because it happens when running the "R CMD check" for a package, which, at least in theory, should be safe. I found the fix was to remove the packages "RCurl" and "url" and rebuild them.

    Here's the symptom, anyway

    * checking for file ‘kutils.gitex/DESCRIPTION’ ... OK
    * preparing ‘kutils’:
    * checking DESCRIPTION meta-information ... OK
    * installing the package to build vignettes
    * creating vignettes ... OK
    * checking for LF line-endings in source and make files and shell scripts
    * checking for empty or unneeded directories
    * looking to see if a ‘data/datalist’ file should be added
    * re-saving image files
    * building ‘kutils_1.40.tar.gz’
    Warning: invalid uid value replaced by that for user 'nobody'
    Warning: invalid gid value replaced by that for user 'nobody'
    
    Run check: OK? (y or n)y
    * using log directory ‘/home/pauljohn/GIT/CRMDA/software/kutils/package/kutils.Rcheck’
    * using R version 3.4.4 (2018-03-15)
    * using platform: x86_64-pc-linux-gnu (64-bit)
    * using session charset: UTF-8
    * using option ‘--as-cran’
    * checking for file ‘kutils/DESCRIPTION’ ... OK
    * checking extension type ... Package
    * this is package ‘kutils’ version ‘1.40’
    * checking CRAN incoming feasibility ...
     *** caught segfault ***
    address 0x68456, cause 'memory not mapped'
    
    Traceback:
     1: curlGetHeaders(u)
     2: doTryCatch(return(expr), name, parentenv, handler)
     3: tryCatchOne(expr, names, parentenv, handlers[[1L]])
     4: tryCatchList(expr, classes, parentenv, handlers)
     5: tryCatch(curlGetHeaders(u), error = identity)
     6: .fetch(u)
     7: .check_http_A(u)
     8: FUN(X[[i]], ...)
     9: lapply(urls[pos], .check_http)
    10: do.call(rbind, lapply(urls[pos], .check_http))
    11: check_url_db(url_db_from_package_sources(dir), remote = !localOnly)
    12: doTryCatch(return(expr), name, parentenv, handler)
    13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    14: tryCatchList(expr, classes, parentenv, handlers)
    15: tryCatch(check_url_db(url_db_from_package_sources(dir), remote = !localOnly),     error = identity)
    16: .check_package_CRAN_incoming(pkgdir, localOnly)
    17: check_CRAN_incoming(!check_incoming_remote)
    18: tools:::.check_packages()
    An irrecoverable exception occurred. R is aborting now ...
    Segmentation fault
    
    0 讨论(0)
  • 2021-02-12 14:13

    It's not really an explanation of the problem or a satisfactory answer but I examined the codes more closely and figured out that in the first example, the problem appears when using acast from the reshape2 package. I deleted it in this case because I realized it's not actually needed there but it can be replaced with reshape from the reshape package (as shown in another question): reshape(input, idvar="x", timevar="y", direction="wide")[-1].

    As for the second example, it's not easy to find the exact cause of the problem but as a workaround in my case helped to set a smaller number of cores used for parallel computation - the cluster has 48, I was using only 15 since even before this issue R was running out of memory if the code was run using all 48 cores. When I reduced the number of cores to 10 it suddenly started working like before.

    0 讨论(0)
提交回复
热议问题