【发布时间】:2015-04-26 20:35:12
【问题描述】:
我正在使用 Shiny 和 ggplot2 用 R 编写一个相当复杂的仪表板。
在编写时一切正常,但过了一段时间(数据每天更新)它在渲染特定页面时开始出现段错误。
我可以通过打开带有 12 个 ggplot 图的特定选项卡来重现该问题。
失败时的控制台输出如下所示:
dashboard_1 | address 0x194b1, cause 'memory not mapped'
dashboard_1 |
dashboard_1 | Traceback:
dashboard_1 | 1: mapply(FUN = f, ..., SIMPLIFY = FALSE)
dashboard_1 | 2: Map(build_grob, plot$layer, data)
dashboard_1 | 3: ggplot_gtable(data)
dashboard_1 | 4: print.ggplot(result$value)
dashboard_1 | 5: print(result$value)
dashboard_1 | 6: eval(expr, envir, enclos)
dashboard_1 | 7: eval(expr, pf)
dashboard_1 | 8: withVisible(eval(expr, pf))
dashboard_1 | 9: evalVis(expr)
dashboard_1 | 10: capture.output(print(result$value))
...
dashboard_1 | 65: tryCatchOne(expr, names, parentenv, handlers[[1L]])
dashboard_1 | 66: tryCatchList(expr, classes, parentenv, handlers)
dashboard_1 | 67: 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() } }})("62978544", FALSE, "{\"method\":\"update\",\"data\":{\"daterange:shiny.date\":[\"2014-04-26\",\"2015-04-26\"],\"group_by\":\"weeks\"}}"), <environment>), error = .rcpp_error_recorder)
dashboard_1 | 68: withCallingHandlers(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() } }})("62978544", FALSE, "{\"method\":\"update\",\"data\":{\"daterange:shiny.date\":[\"2014-04-26\",\"2015-04-26\"],\"group_by\":\"weeks\"}}"), <environment>), error = .rcpp_error_recorder), warning = .rcpp_warning_recorder)
dashboard_1 | aborting ...
dashboard_1 | Segmentation fault
rmreports_dashboard_1 exited with code 139
我想追踪根本原因并引入更改以防止发生段错误。解决这个问题的最佳方法是什么?
【问题讨论】:
-
你能在闪亮之外重现这个吗?这可能指向一个 ggplot 错误。无论如何,在 C 代码级别调试东西是非常依赖于操作系统的,你没有提到你的操作系统(或 R 版本......)
-
不幸的是,我无法在 RStudio 中一一重现执行 ggplot 的错误,似乎该错误是闪亮和 ggplot 的协作。我能够在 MacOS X (dev) 和 Ubuntu 14.10 (prod) 上重现问题。