jeroen / V8

Embedded JavaScript Engine for R
https://cran.r-project.org/package=V8
Other
199 stars 29 forks source link

Install fails on Ubuntu with V8 4.0.0 #136

Closed karldw closed 2 years ago

karldw commented 2 years ago

I noticed V8 4.0.0 fails to install on Ubuntu, unless I set DISABLE_STATIC_LIBV8=1.

Install log - fails to install with default settings ```r Sys.setenv(DISABLE_STATIC_LIBV8="") install.packages("V8") #> Installing package into ‘~/.R/4.1’ #> (as ‘lib’ is unspecified) #> trying URL 'https://cloud.r-project.org/src/contrib/V8_4.0.0.tar.gz' #> Content type 'application/x-gzip' length 680178 bytes (664 KB) #> ================================================== #> downloaded 664 KB #> #> * installing *source* package ‘V8’ ... #> ** package ‘V8’ successfully unpacked and MD5 sums checked #> ** using staged installation #> Found C++14 compiler: g++ #> > curl::curl_download("http://jeroen.github.io/V8/get-v8-linux.sh","get-v8-linux.sh") #> > #> > #> > curl::curl_download('https://github.com/jeroen/V8/releases/download/v3.6.0/v8-9.6.180.12-amd64.tar.gz','libv8.tar.gz',quiet=FALSE) #> [100%] Downloaded 663 bytes... #> [100%] Downloaded 12126286 bytes... #> > #> > #> Using CXXCPP=g++ -std=gnu++14 -E #> Using PKG_CFLAGS=-I/tmp/RtmpttH0UP/R.INSTALL2beb16756a21/V8/.deps/include #> Using PKG_LIBS=-L/tmp/RtmpttH0UP/R.INSTALL2beb16756a21/V8/.deps/lib -lv8_monolith #> Running feature test for pointer compression... #> Enabling pointer compression #> ** libs #> rm -f V8.so RcppExports.o bindings.o #> g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I/tmp/RtmpttH0UP/R.INSTALL2beb16756a21/V8/.deps/include -DV8_COMPRESS_POINTERS -I'~/.R/4.1/Rcpp/include' -fvisibility=hidden -fpic -g -O2 -ffile-prefix-map=/build/r-base-kbcSEe/r-base-4.1.1=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o #> g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I/tmp/RtmpttH0UP/R.INSTALL2beb16756a21/V8/.deps/include -DV8_COMPRESS_POINTERS -I'~/.R/4.1/Rcpp/include' -fvisibility=hidden -fpic -g -O2 -ffile-prefix-map=/build/r-base-kbcSEe/r-base-4.1.1=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bindings.cpp -o bindings.o #> g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -Wl,-z,relro -o V8.so RcppExports.o bindings.o -L/tmp/RtmpttH0UP/R.INSTALL2beb16756a21/V8/.deps/lib -lv8_monolith -L/usr/lib/R/lib -lR #> installing to ~/.R/4.1/00LOCK-V8/00new/V8/libs #> ** R #> ** inst #> ** byte-compile and prepare package for lazy loading #> ** help #> *** installing help indices #> ** building package indices #> ** installing vignettes #> ** testing if installed package can be loaded from temporary location #> #> #> # #> # Fatal error in , line 0 #> # Fatal process out of memory: Failed to reserve virtual memory for process-wide V8 pointer compression cage #> # #> # #> # #> #FailureMessage Object: 0x7ffcee15d580 #> ==== C stack trace =============================== #> #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(v8::base::debug::StackTrace::StackTrace()+0x16) [0x7f1e07934b86] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(+0x49de3b) [0x7f1e0723fe3b] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(V8_Fatal(char const*, ...)+0x177) [0x7f1e0792a3c7] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(+0x4a5939) [0x7f1e07247939] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(+0x65a472) [0x7f1e073fc472] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(v8::internal::V8::InitializeOncePerProcessImpl()+0x340) [0x7f1e073fc9a0] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(v8::base::CallOnceImpl(std::atomic*, std::function)+0x2d) [0x7f1e0793029d] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(v8::internal::V8::InitializeOncePerProcess()+0x6a) [0x7f1e073fd03a] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(v8::internal::V8::Initialize()+0x9) [0x7f1e073fd069] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(v8::V8::Initialize(int)+0x20) [0x7f1e072554f0] #> ~/.R/4.1/00LOCK-V8/00new/V8/libs/V8.so(R_init_V8+0xab) [0x7f1e07237fcb] #> /usr/lib/R/lib/libR.so(+0x6b7b5) [0x7f1e1794c7b5] #> /usr/lib/R/lib/libR.so(+0x6c159) [0x7f1e1794d159] #> /usr/lib/R/lib/libR.so(+0x129d45) [0x7f1e17a0ad45] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x116afb) [0x7f1e179f7afb] #> /usr/lib/R/lib/libR.so(+0x1210d8) [0x7f1e17a020d8] #> /usr/lib/R/lib/libR.so(+0x12cff2) [0x7f1e17a0dff2] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x116afb) [0x7f1e179f7afb] #> /usr/lib/R/lib/libR.so(+0x1210d8) [0x7f1e17a020d8] #> /usr/lib/R/lib/libR.so(+0x12cff2) [0x7f1e17a0dff2] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x116afb) [0x7f1e179f7afb] #> /usr/lib/R/lib/libR.so(+0x1210d8) [0x7f1e17a020d8] #> /usr/lib/R/lib/libR.so(+0x12cff2) [0x7f1e17a0dff2] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x116afb) [0x7f1e179f7afb] #> /usr/lib/R/lib/libR.so(+0x1210d8) [0x7f1e17a020d8] #> /usr/lib/R/lib/libR.so(+0x12cff2) [0x7f1e17a0dff2] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> /usr/lib/R/lib/libR.so(Rf_eval+0x88) [0x7f1e179f0df8] #> /usr/lib/R/lib/libR.so(+0x10ed56) [0x7f1e179efd56] #> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x268) [0x7f1e179f0c38] #> /usr/lib/R/lib/libR.so(+0x132db6) [0x7f1e17a13db6] #> Trace/breakpoint trap (core dumped) #> ERROR: loading failed #> * removing ‘~/.R/4.1/V8’ #> * restoring previous ‘~/.R/4.1/V8’ #> Warning in install.packages("V8") : #> installation of package ‘V8’ had non-zero exit status #> #> The downloaded source packages are in #> ‘/tmp/RtmpDuYLyo/downloaded_packages’ ```
Install log - succeeds with `DISABLE_STATIC_LIBV8=1` ```r Sys.setenv(DISABLE_STATIC_LIBV8="1") install.packages("V8") #> Installing package into ‘~/.R/4.1’ #> (as ‘lib’ is unspecified) #> trying URL 'https://cloud.r-project.org/src/contrib/V8_4.0.0.tar.gz' #> Content type 'application/x-gzip' length 680178 bytes (664 KB) #> ================================================== #> downloaded 664 KB #> #> * installing *source* package ‘V8’ ... #> ** package ‘V8’ successfully unpacked and MD5 sums checked #> ** using staged installation #> Found C++14 compiler: g++ #> Using CXXCPP=g++ -std=gnu++14 -E #> Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14 #> Using PKG_LIBS=-lv8 -lv8_libplatform #> Running feature test for pointer compression... #> Pointer compression not needed #> ** libs #> rm -f V8.so RcppExports.o bindings.o #> g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -DV8_ENABLE_CHECKS -I'~/.R/4.1/Rcpp/include' -fvisibility=hidden -fpic -g -O2 -ffile-prefix-map=/build/r-base-kbcSEe/r-base-4.1.1=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o #> g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -DV8_ENABLE_CHECKS -I'~/.R/4.1/Rcpp/include' -fvisibility=hidden -fpic -g -O2 -ffile-prefix-map=/build/r-base-kbcSEe/r-base-4.1.1=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bindings.cpp -o bindings.o #> g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -Wl,-z,relro -o V8.so RcppExports.o bindings.o -lv8 -lv8_libplatform -L/usr/lib/R/lib -lR #> installing to ~/.R/4.1/00LOCK-V8/00new/V8/libs #> ** R #> ** inst #> ** byte-compile and prepare package for lazy loading #> ** help #> *** installing help indices #> ** building package indices #> ** installing vignettes #> ** testing if installed package can be loaded from temporary location #> ** checking absolute paths in shared objects and dynamic libraries #> ** testing if installed package can be loaded from final location #> ** testing if installed package keeps a record of temporary installation path #> * DONE (V8) #> #> The downloaded source packages are in #> ‘/tmp/RtmpeFasOB/downloaded_packages’ ```
Session info ``` R version 4.1.1 (2021-08-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 21.10 Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.13.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.1.1 tools_4.1.1 rlang_0.4.12 ```
jeroen commented 2 years ago

I can't reproduce this on my ubuntu machine, but your log says out of memory so that explains it. I guess the linking step is taking some more memory with the static library.

It shouldn't be too bad though, how much free memory do you have? Can you try system("free -m") before installing?

karldw commented 2 years ago

Thanks for pointing that out! It looks like the issue is that I was running R with limited address space size. Somewhat interestingly, the address space size V8 seems to require (8.4 GiB) is bigger than the physical memory of my machine (7.5 GiB) or the amount of memory free (~4.2 GiB), but as long as I'm not artificially limiting the size too much, it works fine.

unset DISABLE_STATIC_LIBV8
ulimit -v
# unlimited
R -e "unix::rlimit_as(8.35 * 1024^3); install.packages('V8')" # fails with same error as above
R -e "unix::rlimit_as(8.40 * 1024^3); install.packages('V8')" # succeeds
jeroen commented 2 months ago

This may be solved by further raising the memory limits. Try creating a file /etc/opencpu/server.conf.d/memory.conf on the server which contains:

{"rlimit.as":1e10}