Bug 15796 - system(..., intern=FALSE) will report success even if the syscall failed
Summary: system(..., intern=FALSE) will report success even if the syscall failed
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.1.0
Hardware: All All
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-05-07 20:35 UTC by Simon Urbanek
Modified: 2015-12-14 13:49 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Urbanek 2014-05-07 20:35:02 UTC
system() will report success (status code of 0) even if the underlying system() syscall failed.

This happens on platforms that have sys/wait.h due to the following in sysutils.c:

#ifdef HAVE_SYS_WAIT_H
    if (WIFEXITED(res)) res = WEXITSTATUS(res);
    else res = 0;
#else

In cases where res is an error WIFEXITED() is false so the failure is silently converted into success. I don't know what the author intended here - I suspect that simply removing the else branch should be good enough since that's what we do when sys/wait.h is not available.

(FWIW the original symptom is that install.packages() will claim success without actually doing anything - typically seen in low-memory VMs where system() fails).
Comment 2 Simon Urbanek 2014-05-21 13:33:36 UTC
I have committed the proposed fix to R-devel. Please check if it is effective. Thanks.
Comment 3 Scott Kostyshak 2014-05-21 13:44:13 UTC
(In reply to Simon Urbanek from comment #2)
> I have committed the proposed fix to R-devel. Please check if it is
> effective. Thanks.

Hi Simon, I'm not experiencing this bug, but I passed on this news to the stackoverflow thread.
Comment 4 Yuki Takei 2014-05-21 16:06:21 UTC
(In reply to Simon Urbanek from comment #2)
> I have committed the proposed fix to R-devel. Please check if it is
> effective. Thanks.

I post http://stackoverflow.com/questions/23750740/couldnt-install-r-packages-on-ubuntu-14-04

and I have tried latest R-devel.
But does not seem to effect.




install.packages('shiny')
-----------------------------------------
# R

R Under development (unstable) (2014-05-20 r65701) -- "Unsuffered Consequences"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-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.

> install.packages('shiny')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘Rcpp’, ‘bitops’, ‘httpuv’, ‘caTools’, ‘RJSONIO’, ‘xtable’, ‘digest’

trying URL 'http://cran.ism.ac.jp/src/contrib/Rcpp_0.11.1.tar.gz'
Content type 'application/x-gzip' length 2003515 bytes (1.9 Mb)
opened URL
==================================================
downloaded 1.9 Mb

trying URL 'http://cran.ism.ac.jp/src/contrib/bitops_1.0-6.tar.gz'
Content type 'application/x-gzip' length 8734 bytes
opened URL
==================================================
downloaded 8734 bytes

trying URL 'http://cran.ism.ac.jp/src/contrib/httpuv_1.3.0.tar.gz'
Content type 'application/x-gzip' length 423739 bytes (413 Kb)
opened URL
==================================================
downloaded 413 Kb

trying URL 'http://cran.ism.ac.jp/src/contrib/caTools_1.17.tar.gz'
Content type 'application/x-gzip' length 63326 bytes (61 Kb)
opened URL
==================================================
downloaded 61 Kb

trying URL 'http://cran.ism.ac.jp/src/contrib/RJSONIO_1.2-0.2.tar.gz'
Content type 'application/x-gzip' length 1180440 bytes (1.1 Mb)
opened URL
==================================================
downloaded 1.1 Mb

trying URL 'http://cran.ism.ac.jp/src/contrib/xtable_1.7-3.tar.gz'
Content type 'application/x-gzip' length 357303 bytes (348 Kb)
opened URL
==================================================
downloaded 348 Kb

trying URL 'http://cran.ism.ac.jp/src/contrib/digest_0.6.4.tar.gz'
Content type 'application/x-gzip' length 79309 bytes (77 Kb)
opened URL
==================================================
downloaded 77 Kb

trying URL 'http://cran.ism.ac.jp/src/contrib/shiny_0.9.1.tar.gz'
Content type 'application/x-gzip' length 958658 bytes (936 Kb)
opened URL
==================================================
downloaded 936 Kb


The downloaded source packages are in
        ‘/tmp/RtmpNoUdFg/downloaded_packages’
>
-----------------------------------------

‘/usr/local/lib/R/site-library’ is empty.





debugging
-----------------------------------------
> debug(install.packages)
> install.packages("shiny")

(snip because of very long outputs)

Browse[2]>
debug: if (status > 0L) warning(gettextf("installation of package %s had non-zero exit status",
    sQuote(update[i, 1L])), domain = NA) else if (verbose) {
    cmd <- paste(c(cmd0, args), collapse = " ")
    message(sprintf("%d): succeeded '%s'", i, cmd), domain = NA)
}
Browse[2]>
debug: if (verbose) {
    cmd <- paste(c(cmd0, args), collapse = " ")
    message(sprintf("%d): succeeded '%s'", i, cmd), domain = NA)
}
Browse[2]>
debug: outfile <- if (keep_outputs) {
    paste0(update[i, 1L], ".out")
} else output
Browse[2]>
debug: output
Browse[2]>
debug: args <- c(args0, get_install_opts(update[i, 3L]), "-l", shQuote(update[i,
    2L]), getConfigureArgs(update[i, 3L]), getConfigureVars(update[i,
    3L]), update[i, 3L])
Browse[2]>
debug: status <- system2(cmd0, args, env = env, stdout = outfile, stderr = outfile)
Browse[2]>
debug: if (!quiet && keep_outputs) writeLines(readLines(outfile))
Browse[2]>
debug: if (status > 0L) warning(gettextf("installation of package %s had non-zero exit status",
    sQuote(update[i, 1L])), domain = NA) else if (verbose) {
    cmd <- paste(c(cmd0, args), collapse = " ")
    message(sprintf("%d): succeeded '%s'", i, cmd), domain = NA)
}
Browse[2]>
debug: if (verbose) {
    cmd <- paste(c(cmd0, args), collapse = " ")
    message(sprintf("%d): succeeded '%s'", i, cmd), domain = NA)
}
Browse[2]>
debug: if (keep_outputs && (outdir != getwd())) file.copy(paste0(update[,
    1L], ".out"), outdir)
Browse[2]>
debug: if (!quiet && nonlocalrepos && !is.null(tmpd) && is.null(destdir)) cat("\n",
    gettextf("The downloaded source packages are in\n\t%s", sQuote(normalizePath(tmpd,
        mustWork = FALSE))), "\n", sep = "")
Browse[2]>
debug: cat("\n", gettextf("The downloaded source packages are in\n\t%s",
    sQuote(normalizePath(tmpd, mustWork = FALSE))), "\n", sep = "")
Browse[2]>

The downloaded source packages are in
        ‘/tmp/RtmppyDjsa/downloaded_packages’
debug: libs_used <- unique(update[, 2L])
Browse[2]>
debug: if (.Platform$OS.type == "unix" && .Library %in% libs_used) {
    message("Updating HTML index of packages in '.Library'")
    make.packages.html(.Library)
}
Browse[2]>
debug: invisible()
Browse[2]>
exiting from: install.packages("shiny")
>
>
>
-----------------------------------------
Comment 5 Peter Dalgaard 2014-05-21 16:28:22 UTC
(In reply to Yuki Takei from comment #4)
> (In reply to Simon Urbanek from comment #2)
> > I have committed the proposed fix to R-devel. Please check if it is
> > effective. Thanks.
> 
> I post
> http://stackoverflow.com/questions/23750740/couldnt-install-r-packages-on-
> ubuntu-14-04
> 
> and I have tried latest R-devel.
> But does not seem to effect.
> 
> 
> 
> 
> install.packages('shiny')
> -----------------------------------------
> # R
> 
> R Under development (unstable) (2014-05-20 r65701) -- "Unsuffered
                                             !!!!!!
> Consequences"

Simon's fix went into r65709/65710 !
Comment 6 Yuki Takei 2014-05-22 12:58:15 UTC
Simon and  Peter :


I've tried r65711.

Output is the following.

-----------------------------
# R

R Under development (unstable) (2014-05-21 r65711) -- "Unsuffered Consequences"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-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.


> install.packages('shiny')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘Rcpp’, ‘bitops’, ‘httpuv’, ‘caTools’, ‘RJSONIO’, ‘xtable’, ‘digest’

...
(snip because it is the same as last time)
...

The downloaded source packages are in
        ‘/tmp/Rtmp92Nom4/downloaded_packages’
There were 16 warnings (use warnings() to see them)

>
> warnings()
Warning messages:
1: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
2: In install.packages("shiny") :
  installation of package ‘Rcpp’ had non-zero exit status
3: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
4: In install.packages("shiny") :
  installation of package ‘bitops’ had non-zero exit status
5: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
6: In install.packages("shiny") :
  installation of package ‘RJSONIO’ had non-zero exit status
7: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
8: In install.packages("shiny") :
  installation of package ‘xtable’ had non-zero exit status
9: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
10: In install.packages("shiny") :
  installation of package ‘digest’ had non-zero exit status
11: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
12: In install.packages("shiny") :
  installation of package ‘httpuv’ had non-zero exit status
13: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
14: In install.packages("shiny") :
  installation of package ‘caTools’ had non-zero exit status
15: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) :
  system call failed: Cannot allocate memory
16: In install.packages("shiny") :
  installation of package ‘shiny’ had non-zero exit status
-----------------------------


I feel it became kinder.
The output from warnings() will be a clue to our problem.

Thank you.