5

I have been getting the following a Segmentation Fault on my Shiny Server running on a Linux machine:

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

It started three days ago on an application that was previously working fine. The application does not give an error on my Windows machine. I have renewed all the packages and RStudio on the machine. I have tried to find an answer, but there is very little info about Segfaults.

I have tried to reproduce the error and stripped the code to bare minimum. I discovered that rendering text and tables (base and DataTables) is OK, but rendering any plot (base, ggplot, plotly) produces the segmentation error. The code that gives an error and the error messege from JavaScript console is below.

I also tried starting the code through a web browser from the RStudio on the Linux machine to see if I can get more info, but it just crached giving me the following error message: 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')

  )

)

server.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 error console:

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\.

Do you have any idea what might be behind it or how to fix it?

Thank you in advance.

PS: I am using Shiny Dashboard, but I get the same message, when I run it as a regular Shiny app

  • are you using an Nvidia graphics card? – Phi Jun 14 '17 at 10:22
  • No. It is a server (dell R620 with an Intel processor and graphics card) – Karmen Kütt Jun 14 '17 at 10:27
  • @KarmenKütt did you resolve this? I have the same issue – CPhil Jun 28 '17 at 09:37
  • Did you find the problem and solution for it? I have the same problem and was wondering. – Fisseha Berhane Aug 03 '17 at 04:01
  • 3
    Hey everyone who is experiencing this: See this Github issue (especially [the comment here](https://github.com/rstudio/shiny/issues/1810#issuecomment-321199508) -- TLDR version: add `options(java.parameters = "-Xss2560k")` at the top of your app). If this answers the problem, either me or someone else can write up an answer for future users struggling with the same thing. If not, also do let me know! – Bárbara Borges Aug 09 '17 at 21:50
  • Sorry for the delayed reply, but I was on vacation. The solution did not unfortunately work for me. @bárbara – Karmen Kütt Aug 21 '17 at 11:00
  • @BárbaraBorges, your hack worked great for me. I was using the `xlsx` package with Shiny. – Mark Nielsen Oct 23 '17 at 16:24

2 Answers2

0

Update rJava to the latest version resolved my problem.

-2

I was experiencing the exact same issue (shiny dashboard + rhandsontable + ggplot2).

Bárbara Borges suggested in a comment,to add options(java.parameters = "-Xss2560k") in ui.Rand that resolved my issue.

pa3m
  • 1
  • 2