oracle / fastr

A high-performance implementation of the R programming language, built on GraalVM.
Other
626 stars 64 forks source link

Raw Vector is turned into `RDoubleVector` where an instance of RAbstractIntVector is expected using `pdftools` and underlying `poppler` #46

Closed NRBPerdijk closed 5 years ago

NRBPerdijk commented 5 years ago

Hello!

I am using GraalVM rc10 with fastR to make our R-functions executable from our Scala codebase. I have made some nice progress, but I’m now stuck on what appears to be an internal issue with how graal/fastr handles R vectors. I am trying to render a pdf using the R package pdftools, but when passing the function pdf_render_page a raw vector (as it demands) I get the stack trace printed below, saying it dies in the underlying poppler_render_page call. Apparently, somewhere internally, the raw vector gets converted to an RDoubleVector, which cannot be cast to an RAbstractIntVector (makes sense). The same raw vector works fine when passed to pdf_info (which is from the same pdftools package).

The original data is an Array of Integers handed over from Scala code, using GraalVM, so there is nothing in the data that precludes making it an IntVector. I also explicitly convert it to raw using as.raw().

Not sure if this is relevant, but I am on MacOS and have poppler 0.72.0 installed using brew (required for the pdftools package)

Thanks in advance!

Stacktrace

    at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:325)
    at <R>.poppler_render_page(Unknown)
    at <R>.pdf_render_page(unknown.r:1)
    at <R>.[my application]
steve-s commented 5 years ago

Hello Nathan,

thank you for the report. I could reproduce ClassCastException involving double vector to int vector conversion using this snippet:

pdf_render_page("doc/NEWS.pdf")

the stack trace is

Caused by: java.lang.ClassCastException: com.oracle.truffle.r.runtime.data.RDoubleVector cannot be cast to com.oracle.truffle.r.runtime.data.model.RAbstractIntVector
        at com.oracle.truffle.r.runtime.data.RVector.setAttr(RVector.java:209)
        at com.oracle.truffle.r.ffi.impl.common.JavaUpCallsRFFIImpl.Rf_setAttrib(JavaUpCallsRFFIImpl.java:347)
        at com.oracle.truffle.r.ffi.impl.upcalls.Rf_setAttribCall$Rf_setAttribCallFactory$1.execute(Rf_setAttribCall.java:61)
        at com.oracle.truffle.api.impl.DefaultCallTarget.callDirectOrIndirect(DefaultCallTarget.java:81)
        at com.oracle.truffle.api.impl.DefaultDirectCallNode.call(DefaultDirectCallNode.java:59)
        ...

We're working on a fix.

steve-s commented 5 years ago

Should be fixed now. The fixes will probably make it to the next RC, or you can compile GraalVM from the sources to have them right now.