简体   繁体   中英

Building R package causes R to crash

I'm trying to diagnose what's causing R to crash when I try to build a package I've created and I'm not sure what steps to take next.

I initially created the package using RStudio and devtools . After writing several functions, I ran devtools::document() , however this caused RStudio to crash. When I reopened the project, document() ran without a crash, but then RStudio crashed after devtools::build() . I reopened RStudio and this time build() ran without an error and I was able to click Install and Restart to install the package. After clicking Install and Restart RStudio sometimes crashes and sometimes doesn't.

I decided to try the build and document commands by running R directly without RStudio. I removed the man folder and NAMESPACE file from the project directory. Then, after setting the working directory to the directory for the package, I ran devtools::document() , which ran without error and generated a man folder and NAMESPACE file. Then I ran devtools::build() which crashed R. The crash message is below. However, when I restarted R and ran build() again, it ran without error. I then ran R CMD INSTALL from the command line and it installed the package without error.

I'm not sure what steps to take next. All of the functions in the package run without error when I create and use them directly in R scripts. Could there be something in the roxygen documentation comments for one or more functions that's causing the crash?

In case it might be helpful to know, the package includes a file imports.r with the following imports:

#' @importFrom fst read.fst
#' @importFrom lubridate today
#' @import readr
#' @import readxl
#' @import dplyr
NULL

I can provide other information, such as details about and code for the package, crash logs, etc. I'm on a Macbook Pro running Sierra (10.12.6), R 3.4.2, devtools 1.13.3.9000, roxygen2 6.0.1, and RStudio 1.1.383.

Here's the crash message from R after the running build() for the first time:

 *** caught illegal operation ***
address 0x7fff9f32eae4, cause 'illegal opcode'

Traceback:
 1: process_initialize(self, private, command, args, commandline,     stdout, stderr, cleanup, echo_cmd, windows_verbatim_args,     windows_hide_window)
 2: .subset2(public_bind_env, "initialize")(...)
 3: process$new(command, args, commandline, echo_cmd = echo_cmd,     windows_verbatim_args = windows_verbatim_args, windows_hide_window = windows_hide_window,     stdout = "|", stderr = "|")
 4: run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),     stderr_line_callback = real_callback(stderr), stdout_callback = real_block_callback,     stderr_callback = real_block_callback, echo_cmd = echo, echo = show,     spinner = spinner, error_on_status = fail_on_status, timeout = timeout)
 5: force(code)
 6: with_envvar(env, run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),     stderr_line_callback = real_callback(stderr), stdout_callback = real_block_callback,     stderr_callback = real_block_callback, echo_cmd = echo, echo = show,     spinner = spinner, error_on_status = fail_on_status, timeout = timeout))
 7: eval(substitute(expr), data, enclos = parent.frame())
 8: eval(substitute(expr), data, enclos = parent.frame())
 9: with.default(options, with_envvar(env, run(bin, args = real_cmdargs,     stdout_line_callback = real_callback(stdout), stderr_line_callback = real_callback(stderr),     stdout_callback = real_block_callback, stderr_callback = real_block_callback,     echo_cmd = echo, echo = show, spinner = spinner, error_on_status = fail_on_status,     timeout = timeout)))
10: with(options, with_envvar(env, run(bin, args = real_cmdargs,     stdout_line_callback = real_callback(stdout), stderr_line_callback = real_callback(stderr),     stdout_callback = real_block_callback, stderr_callback = real_block_callback,     echo_cmd = echo, echo = show, spinner = spinner, error_on_status = fail_on_status,     timeout = timeout)))
11: run_r(options)
12: callr::rcmd_safe(..., env = env)
13: with_build_tools(callr::rcmd_safe(..., env = env), required = required)
14: rcmd_build_tools(cmd, c(path, args), wd = out_dir, show = !quiet,     echo = !quiet, fail_on_status = TRUE, required = FALSE)
15: force(code)
16: withr::with_temp_libpaths(rcmd_build_tools(cmd, c(path, args),     wd = out_dir, show = !quiet, echo = !quiet, fail_on_status = TRUE,     required = FALSE))
17: pkgbuild::build(path = path, dest_path = dest_path, binary = binary,     vignettes = vignettes, manual = manual, args = args, quiet = quiet,     ...)
18: devtools::build()

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

Just to close this out: Marcus Klik, the developer of the fst package , was able to track down and fix the issue. The github issue page has the details. Scroll down to Marcus Klik's comment near the end of the thread for the key findings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM