Bug 16562 - mclapply() with tcltk causes subsequent system() to return exit status inconsistently
Summary: mclapply() with tcltk causes subsequent system() to return exit status incons...
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.1.3
Hardware: x86_64/x64/amd64 (64-bit) Linux-Ubuntu
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-10-11 14:10 UTC by Christian Brechbuehler
Modified: 2015-10-11 14:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Brechbuehler 2015-10-11 14:10:19 UTC
Normally, system() returns the exit status of the child.  E.g.,

    > (system("bogus"))
    sh: 1: bogus: not found
    [1] 127

But after a simple mclapply() call it intermittently returns 0, which is wrong:

    > x <- mclapply(1:5, `-`); replicate(16,{(system("bogus", ignore.stderr=TRUE))})
     [1]   0 127   0 127   0   0   0   0   0 127   0   0   0   0   0   0

This only happens if library(tcltk) was loaded.
Here's a self-contained shell script:

    #! /usr/bin/env bash

    R --vanilla --silent << \
    R_SCRIPT
       library(tcltk)
       library(parallel)
       replicate(16, {(system("bogus", ignore.stderr=TRUE))})
       ll <- mclapply(1:5, \`-\`)
       replicate(16, {(system("bogus", ignore.stderr=TRUE))})
    R_SCRIPT

Example output:

    >    library(tcltk)
    >    library(parallel)
    >    replicate(16, {(system("bogus", ignore.stderr=TRUE))})
     [1] 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127
    >    ll <- mclapply(1:5, `-`)
    >    replicate(16, {(system("bogus", ignore.stderr=TRUE))})
     [1] 127   0 127   0   0   0 127   0   0 127   0   0   0   0 127 127
    > 

Obviously, the exact outcome is not reproducible.  The problem is that the issue manifests in system(), which may be very far away, and seem unrelated to any use of package:parallel.

This may be related to https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15040

    > R.version$version.string
    [1] "R version 3.1.0 Patched (2014-04-25 r65494)"

BTW, I valgrind raises some complaints about memory access in tcltk.