randy3k / radian

A 21 century R console
MIT License
1.96k stars 73 forks source link

Bus error using gurobi package on vs code #371

Open zhan-gao opened 1 year ago

zhan-gao commented 1 year ago

It's been wonderful to work on R projects on VS code with radian until I needed to use the gurobi solver. Sending code involving the gurobi solver to radian causes a bus error. The code works well in Rstudio or plain R in terminal, so I believe the problem is with radian.

For example, if we run the following simple problem.

library(Matrix)
library(gurobi)

model <- list()
model$A          <- matrix(c(1,1,0,0,1,1), nrow=2, byrow=T)
model$obj        <- c(1,2,3)
model$modelsense <- 'max'
model$rhs        <- c(1,1)
model$sense      <- c('<', '<')

result <- gurobi(model)

Here is the error message.

 *** caught bus error ***
address 0x1013da0f8, cause 'invalid alignment'

Traceback:
 1: doTryCatch(return(expr), name, parentenv, handler)
 2: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 3: tryCatchList(expr, classes, parentenv, handlers)
 4: tryCatch({    .Call("gurobi_common", params_args, model_args, action_args,         PACKAGE = "gurobi")}, error = function(err) {    if (grepl("cannot allocate vector of size ", err$message))         stop_msg("Out of memory -- restart R to avoid potential memory leaks")    else stop_msg(err$message)})
 5: gurobi_common_wrapper(params_args(env, params), model_args(model),     list(optimize = list()))
 6: gurobi(model, params)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Here is the information of my installed radian.

radian version: 0.5.13
r executable: /Library/Frameworks/R.framework/Resources/bin/R
r version: 4.1.3
python executable: /Library/Developer/CommandLineTools/usr/bin/python3
python version: 3.8.9

I'm using a M1 Max chip mac.

Would appreciate a lot if anyone can help. Thank you!

vitallish commented 10 months ago

I have run into a similar issue and I'm using an intel mac (maybe this person as well #209). I'm getting a bus error with the survival package

r$> library(survival)

 *** caught bus error ***
address 0x10f092b00, cause 'non-existent physical address'

Traceback:
 1: dyn.load(file, DLLpath = DLLpath, ...)
 2: library.dynam(lib, package, package.lib)
 3: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
 4: asNamespace(ns)
 5: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc,     .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
 6: loadNamespace(package, lib.loc)
 7: doTryCatch(return(expr), name, parentenv, handler)
 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 9: tryCatchList(expr, classes, parentenv, handlers)
10: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return && !quietly)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
11: library(survival)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Same as you - it works in regular R terminal.

clabornd commented 9 months ago

Sry if this is super unhelpful, but I was getting a similar error as @vitallish when calling devtools::load_all():

 *** caught bus error ***
address 0x10b262570, cause 'non-existent physical address'

Traceback:
 1: dyn.load(file, DLLpath = DLLpath, ...)
 2: library.dynam(lib, package, package.lib)
 3: loadNamespace(package, ...)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)
 7: tryCatch(loadNamespace(package, ...), error = function(e) e)
 8: requireNamespace(pkg, quietly = TRUE)
 9: (function (pkg, cmp, ver) {    if (is_string(pkg, "base")) {        is_fully_loaded <- TRUE    }    else {        is_fully_loaded <- is_on_disk(pkg)        is_fully_loaded <- is_fully_loaded && requireNamespace(pkg,             quietly = TRUE) && env_is_locked(ns_env(pkg))    }    if (is_fully_loaded) {        is_na(ver) || exec(cmp, utils::packageVersion(pkg), ver)    }    else {        FALSE    }})(pkg = dots[[1L]][[2L]], cmp = dots[[2L]][[2L]], ver = dots[[3L]][[2L]])
10: mapply(FUN = .f, pkg = c("Amelia", "dplyr", "embed", "forcats", "foreach", "ggplot2", "magrittr", "parsnip", "plotly", "pmartR", "purrr", "recipes", "rsample", "tidyclust", "tidyr", "yardstick"), cmp = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_), ver = c(NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, NA_character_),     MoreArgs = list(...), SIMPLIFY = FALSE, USE.NAMES = FALSE)
11: do.call("mapply", c(FUN = list(quote(.f)), args, MoreArgs = quote(list(...)),     SIMPLIFY = FALSE, USE.NAMES = FALSE))
12: pmap(info, function(pkg, cmp, ver) {    if (is_string(pkg, "base")) {        is_fully_loaded <- TRUE    }    else {        is_fully_loaded <- is_on_disk(pkg)        is_fully_loaded <- is_fully_loaded && requireNamespace(pkg,             quietly = TRUE) && env_is_locked(ns_env(pkg))    }    if (is_fully_loaded) {        is_na(ver) || exec(cmp, utils::packageVersion(pkg), ver)    }    else {        FALSE    }})
13: enexpr(expr)
14: inject(c(!!!x))
15: list_c(pmap(info, function(pkg, cmp, ver) {    if (is_string(pkg, "base")) {        is_fully_loaded <- TRUE    }    else {        is_fully_loaded <- is_on_disk(pkg)        is_fully_loaded <- is_fully_loaded && requireNamespace(pkg,             quietly = TRUE) && env_is_locked(ns_env(pkg))    }    if (is_fully_loaded) {        is_na(ver) || exec(cmp, utils::packageVersion(pkg), ver)    }    else {        FALSE    }}))
16: detect_installed(info)
17: check_installed(pkg, action = action, call = call)
18: deps_check_installed(path, imports)
19: load_imports(path)
20: pkgload::load_all(path = path, reset = reset, recompile = recompile,     export_all = export_all, helpers = helpers, quiet = quiet,     ...)
21: devtools::load_all()

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

or library(dplyr):

*** caught bus error ***
address 0x10065b570, cause 'non-existent physical address'

Traceback:
 1: dyn.load(file, DLLpath = DLLpath, ...)
 2: library.dynam(lib, package, package.lib)
 3: loadNamespace(package, lib.loc)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)
 7: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return && !quietly)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
 8: library(dplyr)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

With the same behavior that it worked in a regular R terminal but not radian. I reinstalled dplyr and everything magically works now...hope this is somehow useful.