Closed NRBPerdijk closed 5 years ago
Hello Nathan,
it seems that we've seen this issue before and we believe that this time it is a problem on the side of R package Rcpp
used by pdftools
. The issue was reported here: https://github.com/RcppCore/Rcpp/issues/935. In the meantime as a workaround you can patch Rcpp
sources:
--- a/inst/include/Rcpp/protection/Shelter.h
+++ b/inst/include/Rcpp/protection/Shelter.h
@@ -26,7 +26,7 @@ namespace Rcpp {
Shelter() : nprotected(0){}
inline SEXP operator()(SEXP x){
- nprotected++;
+ if ( x != R_NilValue ) nprotected++;
return Rcpp_protect(x) ;
}
in case you're not that familiar with R ecosystem: you'll have to download the Rcpp
sources (e.g., to ~/Rcpp
), apply the patch and then install the patched Rcpp
via R CMD INSTALL ~/Rcpp
and then re-install pdftools
via install.packages("pdftools")
so that it's built with the new Rcpp
headers.
With the patched version of Rcpp
, the provided example gives me:
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
[1] 9
[1] 10
[1] 11
<std::runtime_error in poppler_render_page(loadfile(pdf), page, dpi, opw, upw, antialiasing, text_antialiasing): Invalid page.>
[1] "Yah, finished!"
which seems to be the same as GNU-R.
but it is a work around we were trying for other issues in RC11
if you can, please report those issues as well even if you have a workaround. It will be appreciated. (Including how you worked around the issue would be great too).
The "other issues" for which this is a workaround can all be traced back to #49, so we expect them to disappear with the next GraalVM RC.
Thanks for the local fix of the RCCP
-issue. Patching local sources and reinstalling pdftools
does indeed make the problem go away! 👍
FYI, we changed the behavior and FastR is now tolerant to unbalanced protect/unprotect, you only get a warning instead of an error, so if you don't mind that warning, you can use unpatched version of Rcpp.
Good to know!
Hello!
(Unsure if this is related to #50 )
When I run the code snippet below using
GraalVM
, it prints the numbers 1 through 11 and then dies with a stacktrace (see further below), statingjava.lang.ArrayIndexOutOfBoundsException
. The snippet works fine in regularR
(catching & printing the error and "Yah, finished"). Depending on throwing errors for application logic is certainly not pretty, but it is a work around we were trying for other issues inRC11
and it is behaviour that is different from regularR
, so we were surprised!