R Shiny 服务器分段错误

Posted

技术标签:

【中文标题】R Shiny 服务器分段错误【英文标题】:R Shiny Server Segmentation Fault 【发布时间】:2017-11-16 10:19:12 【问题描述】:

我在 Linux 机器上运行的 Shiny 服务器上遇到以下分段错误:

-bash: line 1: 29254 Segmentation fault      R --no-save --slave -f \/opt\/shiny-server\/R\/SockJSAdapter\.R
"

三天前在一个以前运行良好的应用程序上开始。该应用程序在我的 Windows 机器上没有给出错误。我已经更新了机器上的所有包和 RStudio。我试图找到答案,但关于 Segfaults 的信息很少。

我已尝试重现该错误并将代码剥离到最低限度。我发现渲染文本和表格(base 和 DataTables)是可以的,但是渲染任何图(base、ggplot、plotly)都会产生分割错误。下面是给出错误的代码和来自 javascript 控制台的错误消息。

我还尝试通过 Linux 机器上的 RStudio 的 Web 浏览器启动代码,以查看是否可以获得更多信息,但它只是给我以下错误消息: Rstudio browser error message

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0 

ui.R

library(shinydashboard)

dashboardPage(

  dashboardHeader(),


  dashboardSidebar(),


  dashboardBody(
    h4('Text'),
    textOutput('TextT'),
    dataTableOutput('Tabel'),
    plotOutput('Plot')

  )

)

服务器.R

server <- function(input, output, session)  

  output$TextT = renderText('text text')

  output$Tabel = renderDataTable(data.frame(A = 1))

  output$Plot = renderPlot(plot(data.frame(x = c(1:10), y = c(11:20))))


JavaScript 错误控制台:

68: messageHandler(binary, msg)
69: withCallingHandlers(expr, error = function(e)     if (is.null(attr(e, "stack.trace", exact = TRUE)))         calls <- sys.calls()        attr(e, "stack.trace") <- calls        stop(e)    )
70: captureStackTraces(expr)
71: withCallingHandlers(captureStackTraces(expr), error = function(cond)     if (inherits(cond, "shiny.silent.error"))         return()    if (isTRUE(getOption("show.error.messages")))         printError(cond, full = full, offset = offset)    )
72: withLogErrors(messageHandler(binary, msg))
73: handler(binary, message)
74: doTryCatch(return(expr), name, parentenv, handler)
75: tryCatchOne(expr, names, parentenv, handlers[[1L]])
76: tryCatchList(expr, classes, parentenv, handlers)
77: 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)))
78: try(handler(binary, message))
79: (function (handle, binary, message)     for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks)         result <- try(handler(binary, message))        if (inherits(result, "try-error"))             .wsconns[[as.character(handle)]]$close()            return()            )("60893360", FALSE, "\"method\":\"init\",\"data\":\"sidebarItemExpanded\":null,\"sidebarCollapsed\":false,\".clientdata_output_Plot_width\":1190,\".clientdata_output_Plot_height\":400,\".clientdata_output_TextT_hidden\":false,\".clientdata_output_Tabel_hidden\":false,\".clientdata_output_Plot_hidden\":false,\".clientdata_pixelratio\":0.8695651888847351,\".clientdata_url_protocol\":\"http:\",\".clientdata_url_hostname\":\"apps.teed.ee\",\".clientdata_url_port\":\"\",\".clientdata_url_pathname\":\"/VisualiseerimineVer2/\",\".clientdata_url_search\":\"\",\".clientdata_url_hash_initial\":\"\",\".clientdata_url_hash\":\"\",\".clientdata_singletons\":\"\",\".clientdata_allowDataUriScheme\":true")
80: evalq((function (handle, binary, message)     for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks)         result <- try(handler(binary, message))        if (inherits(result, "try-error"))             .wsconns[[as.character(handle)]]$close()            return()            )("60893360", FALSE, "\"method\":\"init\",\"data\":\"sidebarItemExpanded\":null,\"sidebarCollapsed\":false,\".clientdata_output_Plot_width\":1190,\".clientdata_output_Plot_height\":400,\".clientdata_output_TextT_hidden\":false,\".clientdata_output_Tabel_hidden\":false,\".clientdata_output_Plot_hidden\":false,\".clientdata_pixelratio\":0.8695651888847351,\".clientdata_url_protocol\":\"http:\",\".clientdata_url_hostname\":\"apps.teed.ee\",\".clientdata_url_port\":\"\",\".clientdata_url_pathname\":\"/VisualiseerimineVer2/\",\".clientdata_url_search\":\"\",\".clientdata_url_hash_initial\":\"\",\".clientdata_url_hash\":\"\",\".clientdata_singletons\":\"\",\".clientdata_allowDataUriScheme\":true"),     <environment>)
81: evalq((function (handle, binary, message)     for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks)         result <- try(handler(binary, message))        if (inherits(result, "try-error"))             .wsconns[[as.character(handle)]]$close()            return()            )("60893360", FALSE, "\"method\":\"init\",\"data\":\"sidebarItemExpanded\":null,\"sidebarCollapsed\":false,\".clientdata_output_Plot_width\":1190,\".clientdata_output_Plot_height\":400,\".clientdata_output_TextT_hidden\":false,\".clientdata_output_Tabel_hidden\":false,\".clientdata_output_Plot_hidden\":false,\".clientdata_pixelratio\":0.8695651888847351,\".clientdata_url_protocol\":\"http:\",\".clientdata_url_hostname\":\"apps.teed.ee\",\".clientdata_url_port\":\"\",\".clientdata_url_pathname\":\"/VisualiseerimineVer2/\",\".clientdata_url_search\":\"\",\".clientdata_url_hash_initial\":\"\",\".clientdata_url_hash\":\"\",\".clientdata_singletons\":\"\",\".clientdata_allowDataUriScheme\":true"),     <environment>)
82: doTryCatch(return(expr), name, parentenv, handler)
83: tryCatchOne(expr, names, parentenv, handlers[[1L]])
84: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
85: doTryCatch(return(expr), name, parentenv, handler)
86: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parentenv, handlers[[nh]])
87: tryCatchList(expr, classes, parentenv, handlers)
88: tryCatch(evalq((function (handle, binary, message)     for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks)         result <- try(handler(binary, message))        if (inherits(result, "try-error"))             .wsconns[[as.character(handle)]]$close()            return()            )("60893360", FALSE, "\"method\":\"init\",\"data\":\"sidebarItemExpanded\":null,\"sidebarCollapsed\":false,\".clientdata_output_Plot_width\":1190,\".clientdata_output_Plot_height\":400,\".clientdata_output_TextT_hidden\":false,\".clientdata_output_Tabel_hidden\":false,\".clientdata_output_Plot_hidden\":false,\".clientdata_pixelratio\":0.8695651888847351,\".clientdata_url_protocol\":\"http:\",\".clientdata_url_hostname\":\"apps.teed.ee\",\".clientdata_url_port\":\"\",\".clientdata_url_pathname\":\"/VisualiseerimineVer2/\",\".clientdata_url_search\":\"\",\".clientdata_url_hash_initial\":\"\",\".clientdata_url_hash\":\"\",\".clientdata_singletons\":\"\",\".clientdata_allowDataUriScheme\":true"),     <environment>), error = function (x) x, interrupt = function (x) x)
89: .Call("httpuv_run", PACKAGE = "httpuv", timeoutMillis)
90: run(timeoutMs)
91: service(timeout)
92: serviceApp()
93: withCallingHandlers(expr, error = function(e)     if (is.null(attr(e, "stack.trace", exact = TRUE)))         calls <- sys.calls()        attr(e, "stack.trace") <- calls        stop(e)    )
94: captureStackTraces(    scheduleFlush()    while (!.globals$stopped)         serviceApp()        Sys.sleep(0.001)    )
95: ..stacktraceoff..(captureStackTraces(    scheduleFlush()    while (!.globals$stopped)         serviceApp()        Sys.sleep(0.001)    ))
96: runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE)
An irrecoverable exception occurred. R is aborting now ...
-bash: line 1:  3049 Segmentation fault      R --no-save --slave -f \/opt\/shiny-server\/R\/SockJSAdapter\.

您知道它背后的原因或如何解决它吗?

提前谢谢你。

PS:我正在使用 Shiny Dashboard,但是当我将它作为常规 Shiny 应用程序运行时,我收到了相同的消息

【问题讨论】:

您使用的是 Nvidia 显卡吗? 没有。它是一台服务器(带有英特尔处理器和显卡的戴尔 R620) @KarmenKütt 你解决了吗?我有同样的问题 你找到问题和解决方法了吗?我有同样的问题,想知道。 大家好,遇到这个问题的人:查看这个 Github 问题(尤其是the comment here -- TLDR 版本:在您的应用顶部添加options(java.parameters = "-Xss2560k"))。如果这能解决问题,我或其他人都可以为未来遇到同样问题的用户写下答案。如果没有,也请告诉我! 【参考方案1】:

将 rJava 更新到最新版本解决了我的问题。

【讨论】:

【参考方案2】:

我遇到了完全相同的问题(闪亮的仪表板 + rhandsontable + ggplot2)。

Bárbara Borges suggested in a comment,在ui.R中添加options(java.parameters = "-Xss2560k"),这解决了我的问题。

【讨论】:

以上是关于R Shiny 服务器分段错误的主要内容,如果未能解决你的问题,请参考以下文章

如何避免 Shiny R 图中的闪烁错误?

分段错误(核心转储)

R Shiny(selectizeInput):找不到对象“选择”

无法使用 R Shiny 显示统计测试的结果

R Shiny Reactive 值,dplyr 过滤器错误?

R Shiny:交互式输入从 rds 文件进入 ggplot 时出错(评估中的错误:找不到对象'x')