-
Notifications
You must be signed in to change notification settings - Fork 29
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
Crash caused by some interaction between testthat/V8 #128
Comments
You can run the tests like this. Iirc the stacktrace is caused by the testlocal <- function (path = ".", reporter = NULL, ...)
{
package <- pkgload::pkg_name(path)
test_path <- file.path(pkgload::pkg_path(path), "tests", "testthat")
withr::local_envvar(NOT_CRAN = "true")
testthat::test_dir(test_path, package = package, reporter = reporter,
..., load_package = "none")
}
testlocal() |
Thanks for the comment - however, I am fairly sure this is a problem and I disagree that moving to tinytest is a reasonable fix for this. To clarify the ultimate problem - the above was trying to isolate a problem that I am seeing with jsonvalidate (ropensci/jsonvalidate#54) trying to replicate a crash seen on BDR's machine. Closer to the way that CRAN runs tests still crashes (though seemingly not with the simple package)
|
There are a few separate issues here:
|
I don't think any of the bits above ran |
I haven't seen any problems with packages using the regular check_package() during CMD check. But I think But I think at least most of your examples above should be fixed now that I removed the stacklimits when running with sanitizers. |
I just had to fix a really tough double free crash on CRAN's fedora-clang platform with my V8-using package too. Maybe it's the same issue, or related, or at least helpful in some way. For whatever reason, the double free error was being caused by an uncaught exception in V8 there. To reproduce, you can use R-hub's fedora-clang-devel image (Fedora 33 and a bit behind CRAN, but still works). Install V8 using g++, not clang, as CRAN does, and then throw any error in V8 like docker run -it --rm rhub/fedora-clang-devel
dnf install -y v8-devel
# Compile V8 with g++ as CRAN does - there's probably a better way to do this
cp ~/.R/Makevars ~/.R/Makevars.bk
echo 'CXX17=g++' >> ~/.R/Makevars
/opt/R-devel/bin/R -e 'options(repos = "https://cloud.r-project.org"); install.packages("V8")'
mv -f ~/.R/Makevars.bk ~/.R/Makevars
/opt/R-devel/bin/R -e 'ctx <- V8::new_context(); ctx$eval("throw new Error()")'
# > ctx <- V8::new_context(); ctx$eval("throw new Error()")
# free(): double free detected in tcache 2
# Aborted (core dumped) My package was throwing an error to detect the broken V8 package on Fedora <= 36 (#65) to skip some tests, and hitting this crash. My sketchy workaround was to try and test for this in a separate R process like: code <- "V8::new_context()$eval('not_defined')"
output <- suppressWarnings(
system2(R.home("bin/R"), c("-e", shQuote(code)), stdout = TRUE, stderr = TRUE)
)
if (attr(output, "status") > 0 && !grepl("ReferenceError", paste(output, collapse = "\n"))) {
# Then skip any tests that may throw uncaught exceptions
} |
@glin thanks for the reproducer. I think this is a separate issue that is caused by an ABI incompatibility between libcxx (used by R) and libstdc++ (used by Fedora to compile Can you open a new issue for this? |
This one has me baffled, I've spent a couple of hours narrowing it down, so hopefully something will jump out at you!
The repository https://github.com/richfitz/crash contains a trivial package using V8 that reliably causes a crash when running
testthat::test_local
Prepare by running, from the clone of
richfitz/crash
This installs the CRAN version of V8 (3.4.2) from source, which on this container ends up with:
Running the tests (which simply load
V8::v8()
within atest_that
block, crashes R:Top part of the call stack:
This, outside of testthat, does not crash though:
A more interesting example, after starting with
RDcsan
I saw this issue (r-lib/pkgload#96) and tested with an older pkgload (CRAN release 1.2.1, predating that PR) with no effect:
Possibly related to this V8 issue: #119 / rstudio/shiny#3289 (comment)
Following this comment, I tried #119 (comment)
which gives
list(version = "8.3.110.13")
fromV8::engine_info()
This does produce output from the sanitiser during install and every use of the package:
and a different error for the test
This is possibly the same issue as BDR gets on fedora-clang-devel (https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-clang/jsonvalidate-00check.html) though that could be it's own weird thing of course. It's very odd that this does not trigger on any of the V8 tests. My guess is that it might be different pulling V8 in vs testing it so a package that uses V8 and has compiled code may get things showing up on CRAN's additional issues page. One additional weirdness is that the packages that were using jsonvalidate are not showing similar errors (e.g., https://cran.r-project.org/web/checks/check_results_biocompute.html, which does not error on
r-devel-linux-x86_64-fedora-clang
, even though it does run a test using jsonvalidate/V8)I'm also guessing that testthat is sort of a red herring here, and the difference is the call stack depth?
The text was updated successfully, but these errors were encountered: