[R-SIG-Mac] png() segfaults inside a parallel::mclapply loop?
Simon Urbanek
simon.urbanek at r-project.org
Tue May 1 20:26:07 CEST 2012
Steve,
you can't use certain graphics devices/backends in forked processes (see multicore docs). What is known to work is the Cairo package.
Cheers,
Simon
On May 1, 2012, at 12:30 PM, Steve Lianoglou <mailinglist.honeypot at gmail.com> wrote:
> Hi,
>
> I can't figure this out -- I have to (slightly different) OSX boxes
> running the same version of R that I grabbed from r.research.att.com a
> little while ago:
>
> R version 2.15.0 Patched (2012-04-18 r59079)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> Simply calling png() w/in a parallel loop always crashed the
> subprocesses on one machine. This code, for example:
>
> library(parallel)
> mclapply(1:10, function(i) {
> png(paste("~/tmp/p", i, "png", sep="."))
> plot(1:10)
> dev.off()
> }, mc.cores=8)
>
> The error (from each subprocess) is pasted below, however swapping out
> the png() call to pdf() works on both.
>
> The machine that png() fails on is a ~ 2008 2x4-core mac pro. The one
> that doesn't have a problem is a late 2010 core2duo macbook pro 13"
>
> Both are running OSX.6.8
>
> Anybody else have this problem?
>
> -steve
>
> Error from one process:
>
> *** caught segfault ***
> address 0x108, cause 'memory not mapped'
>
> Traceback:
> 1: png(paste("~/tmp/p", i, "png", sep = "."))
> 2: FUN(7L[[1L]], ...)
> 3: lapply(X = S, FUN = FUN, ...)
> 4: doTryCatch(return(expr), name, parentenv, handler)
> 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
> 6: tryCatchList(expr, classes, parentenv, handlers)
> 7: tryCatch(expr, error = function(e) { call <- conditionCall(e)
> if (!is.null(call)) { if (identical(call[[1L]],
> quote(doTryCatch))) call <- sys.call(-4L) dcall <-
> deparse(call)[1L] prefix <- paste("Error in", dcall, ": ")
> LO
> NG <- 75L msg <- conditionMessage(e) sm <- strsplit(msg,
> "\n")[[1L]] w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L],
> type = "w") if (is.na(w)) w <- 14L + nchar(dcall,
> type = "b") + nchar(sm[1L], type = "b")
> if (w > LONG) prefix <- paste0(prefix, "\n ") }
> else prefix <- "Error : " msg <- paste0(prefix,
> conditionMessage(e), "\n") .Internal(seterrmessage(msg[1L])) if
> (!silent && identical(getOption("show.error.messages"), TRUE))
> { ca
> t(msg, file = stderr()) .Internal(printDeferredWarnings()) }
> invisible(structure(msg, class = "try-error", condition = e))})
> 8: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
> 9: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
> 10: FUN(1:8[[7L]], ...)
> 11: lapply(seq_len(cores), inner.do)
> 12: mclapply(1:10, function(i) { png(paste("~/tmp/p", i, "png", sep
> = ".")) plot(1:10) dev.off()}, mc.cores = 8)
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
> | Memorial Sloan-Kettering Cancer Center
> | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
More information about the R-SIG-Mac
mailing list