[Rd] weird bug with parallel, RSQlite and tcltk

Paul Johnson pauljohn32 at gmail.com
Thu Jan 3 21:16:49 CET 2013


Happy new year.

On Mon, Dec 31, 2012 at 12:08 PM, Karl Forner <karl.forner at gmail.com> wrote:
> Hello,
>
> I spent a lot of a time on a weird bug, and I just managed to narrow it down.
>
> In parallel code (here with parallel::mclappy, but I got it
> doMC/multicore too), if the library(tcltk) is loaded, R hangs when
> trying to open a DB connection.
> I got the same behaviour on two different computers, one dual-core,
> and one 2 xeon quad-core.
>

I believe this is the same problem discussed here:

https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15040

I am interested to know the long term implications of the discussion
going on here, but can I interject to ask the short term question:

With R-2.15.2, is there something I can do to defend myself before
calling mclapply? Suppose I don't intentionally use tcltk, but some
package I use has loaded it. Or somebody ran install.packages(). What
to do?

I thought this would work:

detach(package:tcltk, unload=TRUE)

I ran one test case where it seemed to work, but then started a
several new sessions and got a big crashes.

Example 1. detach(package:tcltk) without unload=TRUE hangs

> library(parallel)
> library(tcltk)
Loading Tcl/Tk interface ... done
> detach(package:tcltk)
> example(mclapply)

mclppl> ## No test:
mclppl> simplify2array(mclapply(rep(4, 5), rnorm))
           [,1]       [,2]       [,3]       [,4]        [,5]
[1,] -0.1499368 -0.7511576  0.7675234 -0.1324973 -0.01118655
[2,] -0.5989764  0.6605780 -0.9417879  0.2295157 -0.16750436
[3,]  1.4585402  0.2513995  1.6857897 -0.1200986  1.19094290
[4,] -0.1459071 -1.7570450  0.2968794  1.1964827  1.87066283

mclppl> # use the same random numbers for all values
mclppl> set.seed(1)

mclppl> simplify2array(mclapply(rep(4, 5), rnorm, mc.preschedule = FALSE,
mclppl+                 mc.set.seed = FALSE))

Example 2. detach with unload=TRUE dies

> library(tcltk)
Loading Tcl/Tk interface ... done
> library(parallel)
> detach(package:tcltk, unload=TRUE)
> example(mclapply)
called Tcl_FindHashEntry on deleted table
Aborted

Ouch. Back to the shell, completely unceremonious. Does it matter in
which order they are loaded?

> library(parallel)
> library(tcltk)
Loading Tcl/Tk interface ... done
> detach(package:tcltk, unload=TRUE)
> example(mclapply)
called Tcl_FindHashEntry on deleted table
Aborted

In the short term, It would really help if we just had a foolproof way
to close, kill, remove, delete, detach and otherwise block tcltk, its
functions, its anything!

pj

> Here's the code:
>
> library(parallel)
> library(RSQLite)
> library(tcltk)
> #unloadNamespace("tcltk")
>
> res <- mclapply(1:2, function(x) {
>         db <- DBI::dbConnect("SQLite", ":memory:")
> }, mc.cores=2)
> print("Done")
>
> When I execute it (R --vanilla  < test_parallel_db.R), it hangs
> forever, and I have to type several times CTRL+C to interrupt it. I
> then get this message:
>
> Warning messages:
> 1: In selectChildren(ac, 1) : error 'Interrupted system call' in select
> 2: In selectChildren(ac, 1) : error 'Interrupted system call' in select
>
> Then, just remove library(tcltk), or uncomment
> unloadNamespace("tcltk"), and it works fine again.
>
> I guess there's a bug somewhere, but where exactly ?
>
> Best,
>
> Karl Forner
>
> Further info:
>
>
> R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
> Copyright (C) 2012 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> ubuntu 12.04 and 12.10
>
> ubuntu package tk8.5
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Paul E. Johnson
Professor, Political Science      Assoc. Director
1541 Lilac Lane, Room 504      Center for Research Methods
University of Kansas                 University of Kansas
http://pj.freefaculty.org               http://quant.ku.edu



More information about the R-devel mailing list