我最近切换到 Manjaro Linux,但我无法运行使用来自 shinyjs 包的 extendedjs 的 Shiny 应用程序。每次 R 会话中止(即消息 R 遇到致命错误会话已终止)。我设法将问题缩小到 V8 rpackage。当我在 R 控制台(即在 Rstudio 外部)中运行它时,我得到与以下跟踪相同的错误:
V8::v8()
*** caught segfault ***
address 0x18, cause 'memory not mapped'
Traceback:
1:.Call("V8_make_context", PACKAGE = "V8", set_console)
2:make_context(private$console)
3:reset()
4:eval(quote({
eval <-
function(src) {
get_str_output(context_eval(join(src), private$context))
} validate <-
function(src) {
context_validate(join(src), private$context)
} call <-
function(fun, ..., auto_unbox = TRUE) {
stopifnot(is.character(fun)) stopifnot(this$validate(c("fun=", fun))) jsargs <-
list(...) if (!is.null(names(jsargs))) {
stop("Named arguments are not supported in JavaScript.")
} jsargs <-
vapply(jsargs, function(x) {
if (is.atomic(x) &&
inherits(x, "JS_EVAL")) {
as.character(x)
} else {
toJSON(x, auto_unbox = auto_unbox)
}
}, character(1)) jsargs <-
paste(jsargs, collapse = ",") src <-
paste0("JSON.stringify((", fun, ")(", jsargs, "));") out <-
this$eval(src) get_json_output(out)
} source <-
function(file) {
if (is.character(file) &&
length(file) == 1 &&
grepl("^https?://", file)) {
file <-
curl(file, open = "r") on.exit(close(file))
} this$eval(readLines(file, encoding = "UTF-8", warn = FALSE))
} get <-
function(name, ...) {
stopifnot(is.character(name)) get_json_output(this$eval(c("JSON.stringify(", name, ")")), ...)
} assign <-
function(name, value, auto_unbox = TRUE, ...) {
stopifnot(is.character(name)) obj <-
if (inherits(value, "JS_EVAL")) {
invisible(this$eval(paste("var", name, "=", value)))
} else {
invisible(this$eval(paste(
"var",
name,
"=",
toJSON(value, auto_unbox = auto_unbox, ...)
)))
}
} reset <-
function() {
private$context <-
make_context(private$console) private$created <-
Sys.time() if (length(global)) {
context_eval(paste("var", global, "= this;", collapse = "\n"),
private$context)
} if (isTRUE(typed_arrays)) {
context_enable_typed_arrays(private$context)
} invisible()
} console <-
function() {
this$eval("") message("This is V8 version ", version(), ". Press ESC or CTRL+C to exit.") on.exit(message("Exiting V8 console.")) buffer <-
character() has_history <-
!inherits(try(savehistory(tempfile()), silent = T)
, "try-error") if (has_history) {
savehistory() on.exit(loadhistory(), add = TRUE) histfile <-
".V8history" if (file.exists(histfile)) {
loadhistory(histfile)
} else {
file.create(histfile)
}
} rc.options(
custom.completer = function(env) {
env$comps <-
tab_complete(this, env$token)
}
) on.exit({
rc.options(custom.completer = NULL)
}, add = TRUE) repeat {
prompt <-
ifelse(length(buffer), " ", "~ ") if (nchar(line <-
readline(prompt))) {
buffer <-
c(buffer, line)
} if (identical(buffer, "exit"))
break if (length(buffer) &&
(this$validate(buffer) ||
!nchar(line))) {
if (has_history) {
write(buffer, histfile, append = TRUE) loadhistory(histfile)
} tryCatch(
cat(undefined_to_null(this$eval(buffer))),
error = function(e) {
message(e$message)
}
) buffer <-
character()
}
}
} reset() lockEnvironment(environment(), TRUE) structure(environment(), class = c("V8", "environment"))
}), new.env())
5:eval(quote({
eval <-
function(src) {
get_str_output(context_eval(join(src), private$context))
} validate <-
function(src) {
context_validate(join(src), private$context)
} call <-
function(fun, ..., auto_unbox = TRUE) {
stopifnot(is.character(fun)) stopifnot(this$validate(c("fun=", fun))) jsargs <-
list(...) if (!is.null(names(jsargs))) {
stop("Named arguments are not supported in JavaScript.")
} jsargs <-
vapply(jsargs, function(x) {
if (is.atomic(x) &&
inherits(x, "JS_EVAL")) {
as.character(x)
} else {
toJSON(x, auto_unbox = auto_unbox)
}
}, character(1)) jsargs <-
paste(jsargs, collapse = ",") src <-
paste0("JSON.stringify((", fun, ")(", jsargs, "));") out <-
this$eval(src) get_json_output(out)
} source <-
function(file) {
if (is.character(file) &&
length(file) == 1 &&
grepl("^https?://", file)) {
file <-
curl(file, open = "r") on.exit(close(file))
} this$eval(readLines(file, encoding = "UTF-8", warn = FALSE))
} get <-
function(name, ...) {
stopifnot(is.character(name)) get_json_output(this$eval(c("JSON.stringify(", name, ")")), ...)
} assign <-
function(name, value, auto_unbox = TRUE, ...) {
stopifnot(is.character(name)) obj <-
if (inherits(value, "JS_EVAL")) {
invisible(this$eval(paste("var", name, "=", value)))
} else {
invisible(this$eval(paste(
"var",
name,
"=",
toJSON(value, auto_unbox = auto_unbox, ...)
)))
}
} reset <-
function() {
private$context <-
make_context(private$console) private$created <-
Sys.time() if (length(global)) {
context_eval(paste("var", global, "= this;", collapse = "\n"),
private$context)
} if (isTRUE(typed_arrays)) {
context_enable_typed_arrays(private$context)
} invisible()
} console <-
function() {
this$eval("") message("This is V8 version ", version(), ". Press ESC or CTRL+C to exit.") on.exit(message("Exiting V8 console.")) buffer <-
character() has_history <-
!inherits(try(savehistory(tempfile()), silent = T)
, "try-error") if (has_history) {
savehistory() on.exit(loadhistory(), add = TRUE) histfile <-
".V8history" if (file.exists(histfile)) {
loadhistory(histfile)
} else {
file.create(histfile)
}
} rc.options(
custom.completer = function(env) {
env$comps <-
tab_complete(this, env$token)
}
) on.exit({
rc.options(custom.completer = NULL)
}, add = TRUE) repeat {
prompt <-
ifelse(length(buffer), " ", "~ ") if (nchar(line <-
readline(prompt))) {
buffer <-
c(buffer, line)
} if (identical(buffer, "exit"))
break if (length(buffer) &&
(this$validate(buffer) ||
!nchar(line))) {
if (has_history) {
write(buffer, histfile, append = TRUE) loadhistory(histfile)
} tryCatch(
cat(undefined_to_null(this$eval(buffer))),
error = function(e) {
message(e$message)
}
) buffer <-
character()
}
}
} reset() lockEnvironment(environment(), TRUE) structure(environment(), class = c("V8", "environment"))
}), new.env())
6:eval(expr, p)
7:eval(expr, p)
8:eval.parent(substitute(eval(quote(expr), envir)))
9:local({
eval <-
function(src) {
get_str_output(context_eval(join(src), private$context))
} validate <-
function(src) {
context_validate(join(src), private$context)
} call <-
function(fun, ..., auto_unbox = TRUE) {
stopifnot(is.character(fun)) stopifnot(this$validate(c("fun=", fun))) jsargs <-
list(...) if (!is.null(names(jsargs))) {
stop("Named arguments are not supported in JavaScript.")
} jsargs <-
vapply(jsargs, function(x) {
if (is.atomic(x) &&
inherits(x, "JS_EVAL")) {
as.character(x)
} else {
toJSON(x, auto_unbox = auto_unbox)
}
}, character(1)) jsargs <-
paste(jsargs, collapse = ",") src <-
paste0("JSON.stringify((", fun, ")(", jsargs, "));") out <-
this$eval(src) get_json_output(out)
} source <-
function(file) {
if (is.character(file) &&
length(file) == 1 &&
grepl("^https?://", file)) {
file <-
curl(file, open = "r") on.exit(close(file))
} this$eval(readLines(file, encoding = "UTF-8", warn = FALSE))
} get <-
function(name, ...) {
stopifnot(is.character(name)) get_json_output(this$eval(c("JSON.stringify(", name, ")")), ...)
} assign <-
function(name, value, auto_unbox = TRUE, ...) {
stopifnot(is.character(name)) obj <-
if (inherits(value, "JS_EVAL")) {
invisible(this$eval(paste("var", name, "=", value)))
} else {
invisible(this$eval(paste(
"var",
name,
"=",
toJSON(value, auto_unbox = auto_unbox, ...)
)))
}
} reset <-
function() {
private$context <-
make_context(private$console) private$created <-
Sys.time() if (length(global)) {
context_eval(paste("var", global, "= this;", collapse = "\n"),
private$context)
} if (isTRUE(typed_arrays)) {
context_enable_typed_arrays(private$context)
} invisible()
} console <-
function() {
this$eval("") message("This is V8 version ", version(), ". Press ESC or CTRL+C to exit.") on.exit(message("Exiting V8 console.")) buffer <-
character() has_history <-
!inherits(try(savehistory(tempfile()), silent = T)
, "try-error") if (has_history) {
savehistory() on.exit(loadhistory(), add = TRUE) histfile <-
".V8history" if (file.exists(histfile)) {
loadhistory(histfile)
} else {
file.create(histfile)
}
} rc.options(
custom.completer = function(env) {
env$comps <-
tab_complete(this, env$token)
}
) on.exit({
rc.options(custom.completer = NULL)
}, add = TRUE) repeat {
prompt <-
ifelse(length(buffer), " ", "~ ") if (nchar(line <-
readline(prompt))) {
buffer <-
c(buffer, line)
} if (identical(buffer, "exit"))
break if (length(buffer) &&
(this$validate(buffer) ||
!nchar(line))) {
if (has_history) {
write(buffer, histfile, append = TRUE) loadhistory(histfile)
} tryCatch(
cat(undefined_to_null(this$eval(buffer))),
error = function(e) {
message(e$message)
}
) buffer <-
character()
}
}
} reset() lockEnvironment(environment(), TRUE) structure(environment(), class = c("V8", "environment"))
})
10:V8::v8()
这是我的会话信息:
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Manjaro Linux
Matrix products: default
BLAS: /usr/lib/libblas.so.3.8.0
LAPACK: /usr/lib/liblapack.so.3.8.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] 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
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] V8_1.5
loaded via a namespace (and not attached):
[1] compiler_3.4.3 curl_3.1 Rcpp_0.12.15 jsonlite_1.5
我的系统上安装了V8 3.1.14,它用于编译 V8 R 包。
编辑解决方法
我找到了解决我的问题的方法。以下是步骤:
- 通过运行安装V8 3.1.14
yaourt v8-3.14
- 完成第一步后,您将拥有编译 R 包所需的所有文件,以便您可以继续进行(
install.packages("V8")
在 R 控制台中运行) - 现在您已经安装了 V8 R 包,您可以安装v8-3.14-bin(通过运行
yaourt v8-3.14-bin
),它实际上可以工作,而不是您在步骤 1 中编译的那个。这两个包v8-3.14和v8-3.14-bin存在冲突所以它们不能同时安装在系统上。这就是为什么您需要首先使用具有所有开发头文件的那个,然后使用带有工作二进制文件的那个。
如果有人提出更好的解决方案,我会留下这个问题。
编辑 2
更多信息: