From simon.urbanek at r-project.org  Fri Jan 15 18:48:10 2010
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 15 Jan 2010 12:48:10 -0500
Subject: [Rd] Using multicore with an open pdf device results in corrupt
	pdf (PR#14186)
In-Reply-To: <20100115141513.A0F5D2831FFE@mail.pubhealth.ku.dk>
References: <20100115141513.A0F5D2831FFE@mail.pubhealth.ku.dk>
Message-ID: <84E58B64-9082-47BB-B4FA-EDB728EDD5AB@r-project.org>

How is this a bug in R? First, multicore is not R. Second, you're  
running multicore with GUI code loaded which it explicitly tells you  
that it won't work. Third, the code you provided does produce correct  
PDFs (tested on the same platform you provided) in a clean session  
(unsurprisingly).

Cheers,
Simon


On Jan 15, 2010, at 9:15 , kollerma at stat.math.ethz.ch wrote:

> The attached code produces corrupted pdfs (test2.pdf, test4.pdf and
> test5.pdf). The resulting pdf depends on how many cores are  
> available on
> the machine.
>
> I don't see why there should be any difference between the pdfs  
> (exept for
> the timestamp). Doing many operations involving mclapply can  
> increase the
> size of the resulting pdf by ten times!
>
> Thank you for checking this.
>
> require(multicore)
>
> pdf('test.pdf')
> y <- unlist(lapply(1:50, identity))
> plot(y)
> print(y)
> dev.off()
>
> options(cores = 3)
>
> pdf('test2.pdf')
> y <- unlist(mclapply(1:50, identity))
> plot(y)
> print(y)
> dev.off()
>
> pdf('test3.pdf')
> y <- unlist(lapply(1:50, identity))
> plot(y)
> print(y)
> dev.off()
>
> options(cores = 2)
>
> pdf('test4.pdf')
> y <- unlist(mclapply(1:50, identity))
> plot(y)
> print(y)
> dev.off()
>
> options(cores = 8)
>
> pdf('test5.pdf')
> y <- unlist(mclapply(1:50, identity))
> plot(y)
> print(y)
> dev.off()
>
>
> --please do not edit the information below--
>
> Version:
> platform = x86_64-unknown-linux-gnu
> arch = x86_64
> os = linux-gnu
> system = x86_64, linux-gnu
> status =
> major = 2
> minor = 10.1
> year = 2009
> month = 12
> day = 14
> svn rev = 50720
> language = R
> version.string = R version 2.10.1 (2009-12-14)
>
> Locale:
> LC_CTYPE 
> = 
> de_CH 
> .UTF 
> -8 
> ;LC_NUMERIC 
> = 
> C 
> ;LC_TIME 
> = 
> en_US 
> .UTF 
> -8 
> ;LC_COLLATE 
> = 
> de_CH 
> .UTF 
> -8 
> ;LC_MONETARY 
> = 
> C 
> ;LC_MESSAGES 
> = 
> de_CH 
> .UTF 
> -8 
> ;LC_PAPER 
> = 
> de_CH 
> .UTF 
> -8 
> ;LC_NAME 
> = 
> C 
> ;LC_ADDRESS 
> =C;LC_TELEPHONE=C;LC_MEASUREMENT=de_CH.UTF-8;LC_IDENTIFICATION=C
>
> Search Path:
> .GlobalEnv, package:skewt, package:rgl, package:ggplot2,  
> package:reshape, package:plyr, package:proto, package:VGAM,  
> package:stats4, package:splines, package:latticeExtra,  
> package:RColorBrewer, package:doMC, package:multicore,  
> package:foreach, package:codetools, package:iterators,  
> package:abind, package:seqinr, package:mvbutils, mvb.session.info,  
> package:tools, package:robust, package:rrcov, package:pcaPP,  
> package:mvtnorm, package:robustbase, package:MASS, package:glmmML,  
> package:playwith, package:grid, package:gWidgetsRGtk2,  
> package:cairoDevice, package:lattice, package:gWidgets,  
> package:graphics, package:grDevices, package:datasets,  
> package:fortunes, package:sfsmisc, package:stats, package:utils,  
> package:methods, Autoloads, package:base
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] Using multicore with an open pdf device results in corrupt pdf (PR#14186)
Simon Urbanek