Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/V8Public

Crash caused by some interaction between testthat/V8 #128

Open
@richfitz

Description

@richfitz

This one has me baffled, I've spent a couple of hours narrowing it down, so hopefully something will jump out at you!

The repositoryhttps://github.com/richfitz/crash contains a trivial package using V8 that reliably causes a crash when runningtestthat::test_local

Prepare by running, from the clone ofrichfitz/crash

docker pull wch1/r-debugdocker run -v $PWD:/src:ro -it --rm \       --security-opt seccomp=unconfined \       wch1/r-debugapt-get update && apt-get install -y libv8-devRDcsan -e 'install.packages(c("testthat", "V8"))'

This installs the CRAN version of V8 (3.4.2) from source, which on this container ends up with:

> RDcsan -e 'V8::engine_info()'...$version[1] "6.8.275.32-node.55"

Running the tests (which simply loadV8::v8() within atest_that block, crashes R:

RDcsan -e 'testthat::test_local("/src")'

Top part of the call stack:

✔ | F W S  OK | Context⠏ |         0 | crashException thrown during bootstrapping/usr/include/v8/v8.h:8921:17: runtime error: member call on null pointer of type 'v8::Context'    #0 0x7fa2a092e0a1 in v8::Context::Scope::Scope(v8::Local<v8::Context>) /usr/include/v8/v8.h:8921:17    #1 0x7fa2a092e0a1 in make_context(bool) /tmp/RtmpwYeYmx/R.INSTALL10e91936780e/V8/src/bindings.cpp:314:22    #2 0x7fa2a08ea4c6 in _V8_make_context /tmp/RtmpwYeYmx/R.INSTALL10e91936780e/V8/src/RcppExports.cpp:75:34    #3 0x7fa2b666c766 in R_doDotCall /tmp/r-source/src/main/dotcode.c:601:17

This, outside of testthat, does not crash though:

RDcsan -e 'V8::v8()'

A more interesting example, after starting withRDcsan

test_path <- "/src/tests/testthat"env <- pkgload::load_all(test_path)$envsetwd(test_path)# This is fine:testthat:::source_file("test-crash.R", rlang:::child_env(env), wrap = FALSE)# This crashestestthat:::source_file("test-crash.R", rlang:::child_env(env), wrap = TRUE)

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)

RDcsan -e "Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1); \    install.packages('V8', repos = 'https://cran.r-project.org')"

which giveslist(version = "8.3.110.13") fromV8::engine_info()

This does produce output from the sanitiser during install and every use of the package:

/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:155:46: runtime error: member access within address 0x613000099780 which does not point to an object of type 'std::_Sp_counted_base<__gnu_cxx::_S_atomic>'0x613000099780: note: object has invalid vptr 00 00 00 00  28 85 4a ad 06 7f 00 00  05 00 00 00 01 00 00 00  38 50 4c ad 06 7f 00 00  00 be be be              ^~~~~~~~~~~~~~~~~~~~~~~              invalid vptr    #0 0x7f06ac84d78e in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:155:46    #1 0x7f06ac88a76a in v8::Isolate::Initialize(v8::Isolate*, v8::Isolate::CreateParams const&) (/usr/local/RDcsan/lib/R/site-library/00LOCK-V8/00new/V8/libs/V8.so+0x5a076a)    #2 0x7f06ac88a79c in v8::Isolate::New(v8::Isolate::CreateParams const&) (/usr/local/RDcsan/lib/R/site-library/00LOCK-V8/00new/V8/libs/V8.so+0x5a079c)    #3 0x7f06ac82e279 in start_v8_isolate(void*) /tmp/Rtmp4vStcO/R.INSTALLf2b70824c9e/V8/src/bindings.cpp:62:13    #4 0x7f06ac805e42 in R_init_V8 /tmp/Rtmp4vStcO/R.INSTALLf2b70824c9e/V8/src/RcppExports.cpp:106:5

and a different error for the test

RDcsan  -e 'testthat::test_local("/src")'[ ... UB error as above ]✔ | F W S  OK | Context✖ | 1       0 | crash [0.3s]                                                    ────────────────────────────────────────────────────────────────────────────────Error (test-crash.R:2:3): a simple test<std::runtime_error/C++Error/error/condition>Error in `context_eval(paste("var", global, "= this;", collapse = "\n"),     private$context)`: <string conversion failed>Backtrace: 1. V8::v8() test-crash.R:2:2 2. (function() {... 3. V8:::reset() 4. V8:::context_eval(...)────────────────────────────────────────────────────────────────────────────────══ Results ═════════════════════════════════════════════════════════════════════Duration: 0.7 s[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]

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 V8and 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 onr-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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp