Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault with NULLs #438

Closed
muschellij2 opened this issue Feb 2, 2022 · 3 comments
Closed

Segfault with NULLs #438

muschellij2 opened this issue Feb 2, 2022 · 3 comments

Comments

@muschellij2
Copy link

muschellij2 commented Feb 2, 2022

I don't know why I get a segault here exactly, but I boiled it down to the case where you have a URL and NULL for credentials and repo. I ran into this when using remotes::install_bioc test.

Libgit2 version

git2r::libgit2_version()
#> $major
#> [1] 0
#> 
#> $minor
#> [1] 27
#> 
#> $rev
#> [1] 7
git2r::libgit2_features()
#> $threads
#> [1] TRUE
#> 
#> $https
#> [1] TRUE
#> 
#> $ssh
#> [1] TRUE

Created on 2022-02-10 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> Warning in system("timedatectl", intern = TRUE): running command 'timedatectl'
#> had status 1
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Debian GNU/Linux 10 (buster)
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       Etc/UTC
#>  date     2022-02-10
#>  pandoc   2.14.0.3 @ /usr/lib/rstudio-server/bin/pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  cli           3.1.1.9000 2022-02-09 [1] Github (r-lib/cli@00d1770)
#>  digest        0.6.29     2021-12-01 [1] CRAN (R 4.1.2)
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.2)
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.1.2)
#>  fs            1.5.2      2021-12-08 [1] CRAN (R 4.1.2)
#>  git2r         0.29.0     2021-11-22 [1] CRAN (R 4.1.2)
#>  glue          1.6.1      2022-01-22 [1] CRAN (R 4.1.2)
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.1.2)
#>  htmltools     0.5.2      2021-08-25 [1] CRAN (R 4.1.0)
#>  knitr         1.37       2021-12-16 [1] CRAN (R 4.1.2)
#>  lifecycle     1.0.1      2021-09-24 [1] CRAN (R 4.1.0)
#>  magrittr      2.0.2      2022-01-26 [1] CRAN (R 4.1.2)
#>  reprex        2.0.1      2021-08-05 [1] CRAN (R 4.1.0)
#>  rlang         1.0.1      2022-02-03 [1] CRAN (R 4.1.2)
#>  rmarkdown     2.11       2021-09-14 [1] CRAN (R 4.1.0)
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.2)
#>  sessioninfo   1.2.2.9000 2022-02-10 [1] Github (r-lib/sessioninfo@6c683ac)
#>  stringi       1.7.6      2021-11-29 [1] CRAN (R 4.1.0)
#>  stringr       1.4.0.9000 2021-12-14 [1] xgit ([email protected]:tidyverse/stringr.git@dd909b7)
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.2)
#>  withr         2.4.3      2021-11-30 [1] CRAN (R 4.1.0)
#>  xfun          0.29       2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml          2.2.2      2022-01-25 [1] CRAN (R 4.1.2)
#> 
#>  [1] /home/jupyter/.R/library
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Code that segfaults

url <- "https://git.bioconductor.org/packages/MeasurementError.cor"
res <- git2r::remote_ls(url)

Output of Segfault

This reprex appears to crash R.
See standard output and standard error for more details.

Standard output and error

x Install the styler package in order to use `style = TRUE`.

 *** caught segfault ***
address 0xc800010009, cause 'memory not mapped'

Traceback:
 1: git2r::remote_ls(url)
 2: eval(expr, envir, enclos)
 3: eval(expr, envir, enclos)
 4: withVisible(eval(expr, envir, enclos))
 5: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,     error = eHandler, message = mHandler)
 6: doTryCatch(return(expr), name, parentenv, handler)
 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 8: tryCatchList(expr, classes, parentenv, handlers)
 9: 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, nlines = 1L)        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\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 && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
10: try(f, silent = TRUE)
11: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,     enclos)), warning = wHandler, error = eHandler, message = mHandler))
12: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,     envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
13: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,     debug = debug, last = i == length(out), use_try = stop_on_error !=         2L, keep_warning = keep_warning, keep_message = keep_message,     output_handler = output_handler, include_timing = include_timing)
14: evaluate::evaluate(...)
15: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),     keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else {        if (options$error && options$include)             0L        else 2L    }, output_handler = knit_handlers(options$render, options))
16: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,     keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),     stop_on_error = if (is.numeric(options$error)) options$error else {        if (options$error && options$include)             0L        else 2L    }, output_handler = knit_handlers(options$render, options)))
17: eng_r(options)
18: block_exec(params)
19: call_block(x)
20: process_group.block(group)
21: process_group(group)
22: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),     error = function(e) {        setwd(wd)        cat(res, sep = "\n", file = output %n% "")        message("Quitting from lines ", paste(current_lines(i),             collapse = "-"), " (", knit_concord$get("infile"),             ") ")    })
23: process_file(text, output)
24: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
25: rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
26: (function (input) {    rmarkdown::render(input, quiet = TRUE, envir = globalenv(),         encoding = "UTF-8")})(input = base::quote("grave-cobra_reprex.R"))
27: (function (what, args, quote = FALSE, envir = parent.frame()) {    if (!is.list(args))         stop("second argument must be a list")    if (quote)         args <- lapply(args, enquote)    .Internal(do.call(what, args, envir))})(base::quote(function (input) {    rmarkdown::render(input, quiet = TRUE, envir = globalenv(),         encoding = "UTF-8")}), base::quote(list(input = "grave-cobra_reprex.R")), envir = base::quote(<environment>),     quote = base::quote(TRUE))
28: do.call(do.call, c(readRDS("/tmp/Rtmpv9dmjG/callr-fun-5e4c4c920ef4"),     list(envir = .GlobalEnv, quote = TRUE)), envir = .GlobalEnv,     quote = TRUE)
29: saveRDS(do.call(do.call, c(readRDS("/tmp/Rtmpv9dmjG/callr-fun-5e4c4c920ef4"),     list(envir = .GlobalEnv, quote = TRUE)), envir = .GlobalEnv,     quote = TRUE), file = "/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941")
30: withCallingHandlers({    NULL    saveRDS(do.call(do.call, c(readRDS("/tmp/Rtmpv9dmjG/callr-fun-5e4c4c920ef4"),         list(envir = .GlobalEnv, quote = TRUE)), envir = .GlobalEnv,         quote = TRUE), file = "/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941")    flush(stdout())    flush(stderr())    NULL    invisible()}, error = function(e) {    {        callr_data <- as.environment("tools:callr")$`__callr_data__`        err <- callr_data$err        assign(".Traceback", .traceback(4), envir = callr_data)        dump.frames("__callr_dump__")        assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)        rm("__callr_dump__", envir = .GlobalEnv)        e$call <- deparse(conditionCall(e), nlines = 6)        e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))        class(e2) <- c("callr_remote_error", class(e2))        e2$error <- e        calls <- sys.calls()        dcframe <- which(vapply(calls, function(x) length(x) >=             1 && identical(x[[1]], quote(do.call)), logical(1)))[1]        if (!is.na(dcframe))             e2$`_ignore` <- list(c(1, dcframe + 1L))        e2$`_pid` <- Sys.getpid()        e2$`_timestamp` <- Sys.time()        if (inherits(e, "rlib_error_2_0"))             e2$parent <- e$parent        e2 <- err$add_trace_back(e2, embed = FALSE)        saveRDS(list("error", e2), file = paste0("/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941",             ".error"))    }}, interrupt = function(e) {    {        callr_data <- as.environment("tools:callr")$`__callr_data__`        err <- callr_data$err        assign(".Traceback", .traceback(4), envir = callr_data)        dump.frames("__callr_dump__")        assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)        rm("__callr_dump__", envir = .GlobalEnv)        e$call <- deparse(conditionCall(e), nlines = 6)        e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))        class(e2) <- c("callr_remote_error", class(e2))        e2$error <- e        calls <- sys.calls()        dcframe <- which(vapply(calls, function(x) length(x) >=             1 && identical(x[[1]], quote(do.call)), logical(1)))[1]        if (!is.na(dcframe))             e2$`_ignore` <- list(c(1, dcframe + 1L))        e2$`_pid` <- Sys.getpid()        e2$`_timestamp` <- Sys.time()        if (inherits(e, "rlib_error_2_0"))             e2$parent <- e$parent        e2 <- err$add_trace_back(e2, embed = FALSE)        saveRDS(list("error", e2), file = paste0("/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941",             ".error"))    }}, callr_message = function(e) {    try(signalCondition(e))})
31: doTryCatch(return(expr), name, parentenv, handler)
32: tryCatchOne(expr, names, parentenv, handlers[[1L]])
33: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
34: doTryCatch(return(expr), name, parentenv, handler)
35: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parentenv, handlers[[nh]])
36: tryCatchList(expr, classes, parentenv, handlers)
37: tryCatch(withCallingHandlers({    NULL    saveRDS(do.call(do.call, c(readRDS("/tmp/Rtmpv9dmjG/callr-fun-5e4c4c920ef4"),         list(envir = .GlobalEnv, quote = TRUE)), envir = .GlobalEnv,         quote = TRUE), file = "/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941")    flush(stdout())    flush(stderr())    NULL    invisible()}, error = function(e) {    {        callr_data <- as.environment("tools:callr")$`__callr_data__`        err <- callr_data$err        assign(".Traceback", .traceback(4), envir = callr_data)        dump.frames("__callr_dump__")        assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)        rm("__callr_dump__", envir = .GlobalEnv)        e$call <- deparse(conditionCall(e), nlines = 6)        e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))        class(e2) <- c("callr_remote_error", class(e2))        e2$error <- e        calls <- sys.calls()        dcframe <- which(vapply(calls, function(x) length(x) >=             1 && identical(x[[1]], quote(do.call)), logical(1)))[1]        if (!is.na(dcframe))             e2$`_ignore` <- list(c(1, dcframe + 1L))        e2$`_pid` <- Sys.getpid()        e2$`_timestamp` <- Sys.time()        if (inherits(e, "rlib_error_2_0"))             e2$parent <- e$parent        e2 <- err$add_trace_back(e2, embed = FALSE)        saveRDS(list("error", e2), file = paste0("/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941",             ".error"))    }}, interrupt = function(e) {    {        callr_data <- as.environment("tools:callr")$`__callr_data__`        err <- callr_data$err        assign(".Traceback", .traceback(4), envir = callr_data)        dump.frames("__callr_dump__")        assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)        rm("__callr_dump__", envir = .GlobalEnv)        e$call <- deparse(conditionCall(e), nlines = 6)        e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))        class(e2) <- c("callr_remote_error", class(e2))        e2$error <- e        calls <- sys.calls()        dcframe <- which(vapply(calls, function(x) length(x) >=             1 && identical(x[[1]], quote(do.call)), logical(1)))[1]        if (!is.na(dcframe))             e2$`_ignore` <- list(c(1, dcframe + 1L))        e2$`_pid` <- Sys.getpid()        e2$`_timestamp` <- Sys.time()        if (inherits(e, "rlib_error_2_0"))             e2$parent <- e$parent        e2 <- err$add_trace_back(e2, embed = FALSE)        saveRDS(list("error", e2), file = paste0("/tmp/Rtmpv9dmjG/callr-res-5e4c1d5e941",             ".error"))    }}, callr_message = function(e) {    try(signalCondition(e))}), error = function(e) {    NULL    try(stop(e))}, interrupt = function(e) {    NULL    e})
An irrecoverable exception occurred. R is aborting now ...
@muschellij2
Copy link
Author

This may have to do with the fact I'm running on a docker image, so I think when credentials queries the SSH agent, there may be some odd stuff going on or permissions issues.

@muschellij2
Copy link
Author

Same as #264

@muschellij2
Copy link
Author

Fixed in libgit2 1.3.0 via (shell):

wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.3.0.tar.gz
mkdir build && cd build
cmake ..
cmake --build .
sudo make install
R -e 'install.packages("git2r", type = "source")'

path is set to a repo:

path = "~/targets-minimal-original/"
git2r::libgit2_features()
#> $threads
#> [1] TRUE
#> 
#> $https
#> [1] TRUE
#> 
#> $ssh
#> [1] TRUE
git2r::libgit2_version()
#> $major
#> [1] 1
#> 
#> $minor
#> [1] 3
#> 
#> $rev
#> [1] 0
ssh_cred = git2r::cred_ssh_key()
repo = git2r::init(path = path)
git2r::remote_ls("origin", repo = repo)
#>                                       HEAD 
#> "f699789c97a350c1106a661a524672fc6816a4c2" 
#>                            refs/heads/main 
#> "f699789c97a350c1106a661a524672fc6816a4c2" 
#>                    refs/heads/targets-runs 
#> "00c523c790332bfd9ebf3690889cc2e124e653f5" 
#>                           refs/pull/5/head 
#> "d358f04517b2a2b66a7d39c1f798515359e6b98c" 
#>                           refs/pull/6/head 
#> "aa0b0e7f34bd16479065e524b571f84107aff006" 
#>                            refs/tags/0.0.1 
#> "3a2269f707a9dbfeb9ff8eddd41b63efcf643b15"

Created on 2022-02-10 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> Warning in system("timedatectl", intern = TRUE): running command 'timedatectl'
#> had status 1
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Debian GNU/Linux 10 (buster)
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       Etc/UTC
#>  date     2022-02-10
#>  pandoc   2.14.0.3 @ /usr/lib/rstudio-server/bin/pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  cli           3.1.1.9000 2022-02-09 [1] Github (r-lib/cli@00d1770)
#>  digest        0.6.29     2021-12-01 [1] CRAN (R 4.1.2)
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.2)
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.1.2)
#>  fs            1.5.2      2021-12-08 [1] CRAN (R 4.1.2)
#>  git2r         0.29.0     2021-11-22 [1] CRAN (R 4.1.2)
#>  glue          1.6.1      2022-01-22 [1] CRAN (R 4.1.2)
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.1.2)
#>  htmltools     0.5.2      2021-08-25 [1] CRAN (R 4.1.0)
#>  knitr         1.37       2021-12-16 [1] CRAN (R 4.1.2)
#>  lifecycle     1.0.1      2021-09-24 [1] CRAN (R 4.1.0)
#>  magrittr      2.0.2      2022-01-26 [1] CRAN (R 4.1.2)
#>  reprex        2.0.1      2021-08-05 [1] CRAN (R 4.1.0)
#>  rlang         1.0.1      2022-02-03 [1] CRAN (R 4.1.2)
#>  rmarkdown     2.11       2021-09-14 [1] CRAN (R 4.1.0)
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.2)
#>  sessioninfo   1.2.2.9000 2022-02-10 [1] Github (r-lib/sessioninfo@6c683ac)
#>  stringi       1.7.6      2021-11-29 [1] CRAN (R 4.1.0)
#>  stringr       1.4.0.9000 2021-12-14 [1] xgit ([email protected]:tidyverse/stringr.git@dd909b7)
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.2)
#>  withr         2.4.3      2021-11-30 [1] CRAN (R 4.1.0)
#>  xfun          0.29       2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml          2.2.2      2022-01-25 [1] CRAN (R 4.1.2)
#> 
#>  [1] /home/jupyter/.R/library
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant