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

tikzDevice + R 4.1.0 +ggplot2 = segfault address (nil), cause 'memory not mapped' #212

Open
DanielBonnery opened this issue Jun 21, 2021 · 7 comments

Comments

@DanielBonnery
Copy link

Seg fault.

lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal

`R

R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

library(ggplot2);library(tikzDevice);
tikz("toto.tex");ggplot(data=cars,aes(x=speed))+geom_histogram();dev.off()

*** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
1: .setMask(NULL, NULL)
2: resolveMask.NULL(NULL)
3: (function (path) { UseMethod("resolveMask")})(NULL)
4: grid.newpage()
5: print.ggplot(x)
6: (function (x, ...) UseMethod("print"))(x)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
`

@DanielBonnery
Copy link
Author

sudo apt-get install r-cran-tikzdevice
solved the issue...

@rstub
Copy link
Member

rstub commented Jun 22, 2021

That is expected since the graphics API has changed. Which version of tikzDevice did you use before?

@jamarav
Copy link

jamarav commented Jun 30, 2021

I installed with devtools the master branch and I got the same issue with R version 4.1.0. With the previous version (R 4.0.5) I constructed succesfully the master branch. I need the master branch in order to use knitr + tikzDevice using child documents and cutom *.cls classes.

> print(sessionInfo())
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C               LC_TIME=es_ES.UTF-8        LC_COLLATE=es_ES.UTF-8    
 [5] LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=es_ES.UTF-8    LC_PAPER=es_ES.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=es_ES.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.0 tools_4.1.0   

@jamarav
Copy link

jamarav commented Jul 1, 2021

Installing the package from the cran repository seems to work but I can't build from the repository correctly.

I tried to buid the package with the following options:

  • install.packages( 'tikzDevice', repos = 'https://rforge.net', type = 'source' )
  • devtools::install_github( 'daqana/tikzDevice' )
  • git clone git://github.com/daqana/tikzDevice.git and devtools::install()

The 3 options get the same result when I run a .Rnw with tikzplots:

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: .setMask(NULL, NULL)
 2: resolveMask.NULL(NULL)
 3: (function (path) {    UseMethod("resolveMask")})(NULL)
 4: grid.newpage()
 5: print.ggplot(p)
 6: print(p)
 7: print(p)
 8: printTikz(p1$plot, cwd)
 9: eval(expr, envir, enclos)
10: eval(expr, envir, enclos)
11: withVisible(eval(expr, envir, enclos))
12: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,     error = eHandler, message = mHandler)
13: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,     enclos)), warning = wHandler, error = eHandler, message = mHandler))
14: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,     envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
15: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,     debug = debug, last = i == length(out), use_try = stop_on_error !=         2L, keep_warning = keep_warning, keep_message = keep_message,     output_handler = output_handler, include_timing = include_timing)
16: evaluate::evaluate(...)
17: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),     keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else {        if (options$error && options$include)             0L        else 2L    }, output_handler = knit_handlers(options$render, options))
18: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,     keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),     stop_on_error = if (is.numeric(options$error)) options$error else {        if (options$error && options$include)             0L        else 2L    }, output_handler = knit_handlers(options$render, options)))
19: eng_r(options)
20: block_exec(params)
21: call_block(x)
22: process_group.block(group)
23: process_group(group)
24: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),     error = function(e) {        setwd(wd)        cat(res, sep = "\n", file = output %n% "")        message("Quitting from lines ", paste(current_lines(i),             collapse = "-"), " (", knit_concord$get("infile"),             ") ")    })
25: process_file(text, output)
26: knit(..., tangle = opts_knit$get("tangle"), envir = envir)
27: FUN(X[[i]], ...)
28: lapply(sc_split(params$child), knit_child, options = block$params)
29: call_block(x)
30: process_group.block(group)
31: process_group(group)
32: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),     error = function(e) {        setwd(wd)        cat(res, sep = "\n", file = output %n% "")        message("Quitting from lines ", paste(current_lines(i),             collapse = "-"), " (", knit_concord$get("infile"),             ") ")    })
33: process_file(text, output)
34: knit("main.Rnw", encoding = "UTF-8")
An irrecoverable exception occurred. R is aborting now ...

@kylebutts
Copy link

kylebutts commented Jul 27, 2021

I'm facing the same issue. The first function will run and the second fails, so I suspect there is something wrong with ggplot2?

tikzDevice::tikz("example.tex"); plot(mtcars[["mpg"]]); dev.off()
tikzDevice::tikz("example2.tex"); ggplot2::qplot(mtcars[["mpg"]]); dev.off()

This, however does work!!

tikzDevice::tikz("example2.tex"); plot(cowplot::as_grob(ggplot2::qplot(mtcars[["mpg"]]))); dev.off()

@rstub
Copy link
Member

rstub commented Jul 24, 2022

I have finally merged PR #206 which should fix this issue. Can you please recheck?

@kylebutts
Copy link

My comment works for me! That's fantastic, thanks @rstub

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

4 participants