Skip to content
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

nul byte returned #5

Open
daroczig opened this issue Feb 10, 2021 · 4 comments
Open

nul byte returned #5

daroczig opened this issue Feb 10, 2021 · 4 comments

Comments

@daroczig
Copy link

daroczig commented Feb 10, 2021

Hi @jeroen,

First of all -- as always, thanks a lot for this fantastic package!

I've run into an issue when using eval_fork to return an SVG object (please find attached):

> library(unix)
> x <- readRDS('svg')

> str(x)
 chr "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3."| __truncated__

> str(eval_fork(x))
Error in eval_fork_internal(expr = clexpr, envir = clenv, tmp = tmp, timeout = timeout,  : 
  embedded nul in string: '<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' id='svg_e1ac679b-b9c0-4635-85ef-0895857227fe' viewBox='0 0 630.00 360.00'>\n  <g>\n    <defs>\n      <clipPath id='svg_e1ac679b-b9c0-4635-85ef-0895857227fe_cl_1'>\n        <rect x='0.00' y='0.00' width='630.00' height='360.00'/>\n      </clipPath>\n    </defs>\n    <rect x='0.00' y='0.00' width='630.00' height='360.00' id='svg_e1ac679b-b9c0-4635-85ef-0895857227fe_el_1' clip-path='url(#svg_e1ac679b-b9c0-4635-85ef-0895857227fe_cl_1)' fill='#FFFFFF' fill-opacity='1' stroke='#FFFFFF' stroke-opacity='1' stroke-width='0.75' stroke-linejoin='round' stroke-linecap='round'/>\n    <defs>\n      <clipPath id='svg_e1ac679b-b9c0-4635-85ef-0895857227fe_cl_2'>\n        <rect x='0.00' y='0.00' width='630.00' height='360.00'/>\n      </clipPath>\n    </defs>\n    <rect x='0.00' y='0.00' width='630.00' height='360.00' id='svg_e1ac679b-b9c0-4635-85e
Session info
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux bullseye/sid

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     

other attached packages:
[1] unix_1.5.1

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2   

Example file: svg.zip (EDIT: deleted, as better minimal, reproducible examples shared below)

Any ideas where the serialization might go wrong?

@jeroen
Copy link
Owner

jeroen commented Feb 10, 2021

Hmm this seems to work:

eval_safe(x)

Maybe the problem is that the expression gets substituted for a very long inline string whichs hits some limit on the size of the R call/expression.

Here is a minimal example:

library(unix)
x <- strrep("a", 65000)
y <- strrep("a", 66000)
x2 <- eval_fork(x)
y2 <- eval_fork(y)

@daroczig
Copy link
Author

Ah, right - hitting 2^16 characters results in this error 👍

> eval_fork(paste(rep('a', 2^16 + 1), collapse = ''))
Error in eval_fork_internal(expr = clexpr, envir = clenv, tmp = tmp, timeout = timeout,  : 
  embedded nul in string: 

Let me debug further my original issue and come up with a better minimal example, as it's actually a pretty long and complex list.

@daroczig
Copy link
Author

Hm, I did not manage to get your eval_fork + list example working:

> library(unix)
> y <- strrep("a", 66000)
> eval_fork(list(x = y))
Error in eval_fork_internal(expr = clexpr, envir = clenv, tmp = tmp, timeout = timeout,  : 
  embedded nul in string

Anyway, I guess I should stick with eval_safe where serialization doesn't seem to be an issue. Feel free to close the ticket, and thanks a lot again.

@jeroen
Copy link
Owner

jeroen commented Feb 10, 2021

You are right. I won't close the issue just yet I'd like to understand it better first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants