[Rd] system/system2 and open file descriptors

2017-04-18 Thread Winston Chang
It seems that the system() and system2() functions don't close file
descriptors between the fork() and exec() (on Unix platforms, of course).
This means that the child processes inherit open files and socket
connections.

Running this (from a terminal) will result in the child process writing to
a file that was opened by R:

R
f <- file('foo.txt', 'w')
system('echo "abc" >&3')



You can also see the open files if you run the following:
  f <- file('foo.txt', 'w')
  system2('sleep', '100', wait=F)

And then in another terminal:
  lsof -c R -c sleep
it will show that both the R and sleep processes have the file open:
  ...
  R   324 root3w   REG   0,480   4259 /foo.txt
  ...
  sleep   327 root3w   REG   0,480   4259 /foo.txt


This behavior can cause problems if R spawns a child process that outlives
the R process, but keeps open some resources.

Would it be possible to add an option to close file descriptors for child
processes? It would be nice if that were the default, but I suspect that
making that change would break a lot of existing code.

To take an example from the Python world, subprocess.Popen() has an option,
close_fds, which closes all file descriptors except 0, 1, and 2.
  https://docs.python.org/2/library/subprocess.html#popen-constructor


-Winston

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Crash after (wrongly) applying product operator on object from LIMMA package

2017-04-18 Thread Hilmar Berger

Hi,

this is a problem that occurs in the presence of two libraries (limma, 
xlsx) and leads to a crash of R. The problematic code is the wrong 
application of sweep or the product ("*") function on an LIMMA MAList 
object. To my knowledge, limma does not define a "*" method for MAList 
objects.


If only LIMMA is loaded but not package xlsx, the code does not crash 
but rather produces an error ("Error: C stack usage  7970512 is too 
close to the limit"). Loading only package rJava instead of xlsx does 
also not produce the crash but the error message instead. Note that xlsx 
functions are not explicitly used.


It could be reproduced on two different Linux machines running R-3.2.5, 
R-3.3.0 and R-3.3.2.


Code to reproduce the problem:
-
library(limma)
library(xlsx)

# a MAList
ma = new("MAList", list(A=matrix(rnorm(300), 30,10), 
M=matrix(rnorm(300), 30,10)))


# This should actually be sweep(ma$M, ...) for functional code, but I 
omitted the $M...

#sweep(ma, 2, c(1:10), "*")
# sweep will crash when doing the final operation of applying the 
function over the input matrix, which in this case is function "*"


f = match.fun("*")
# This is not exactly the same as in sweep but it also tries to multiply 
the MAList object with a matrix of same size and leads to the crash

f(ma, ma$M)
# ma * ma$M has the same effect
-

My output:

R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-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.

> library(limma)
> library(xlsx)
Loading required package: rJava
Loading required package: xlsxjars
>
> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8  LC_NUMERIC=C LC_TIME=en_US.UTF-8
 [4] LC_COLLATE=en_US.UTF-8LC_MONETARY=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8  LC_NAME=en_US.UTF-8 
LC_ADDRESS=en_US.UTF-8
[10] LC_TELEPHONE=en_US.UTF-8  LC_MEASUREMENT=en_US.UTF-8 
LC_IDENTIFICATION=en_US.UTF-8


attached base packages:
[1] stats graphics  grDevices utils datasets  methods base

other attached packages:
[1] xlsx_0.5.7 xlsxjars_0.6.1 rJava_0.9-8limma_3.30.7

loaded via a namespace (and not attached):
[1] tools_3.3.0
>
> ma = new("MAList", list(A=matrix(rnorm(300), 30,10), 
M=matrix(rnorm(300), 30,10)))

> #sweep(ma, 2, c(1:10), "*")
>
> f = match.fun("*")
> f
function (e1, e2)  .Primitive("*")

> f(ma, ma$M)

> crash to command line with segfault.

Best regards,
Hilmar

--
Dr. Hilmar Berger, MD
Max Planck Institute for Infection Biology
Charitéplatz 1
D-10117 Berlin
GERMANY

Phone:  + 49 30 28460 430
Fax:+ 49 30 28460 401
 
E-Mail: ber...@mpiib-berlin.mpg.de

Web   : www.mpiib-berlin.mpg.de

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] R 3.4 has broken C++11 support

2017-04-18 Thread Angerer, Philipp via R-devel
Whoops, sorry. The links are supposed to be:

[This commit]: 
https://github.com/wch/r-source/commit/45899dba734cbd80a77432af9a3a7829a9ad48da
[the documentation]: 
https://github.com/wch/r-source/blob/45899dba734cbd80a77432af9a3a7829a9ad48da/config.site#L264

- Ursprüngliche Mail -
Von: "Angerer, Philipp" 
An: "r-devel" 
Gesendet: Dienstag, 18. April 2017 15:11:52
Betreff: R 3.4 has broken C++11 support



Hi, 

[This commit] (I’m using the mirror to have a working link) broke C++11 
compilation. 

Before (and still now, according to the comments in the configure script), it’s 
sufficient to just have “SystemRequirements: C++11” in the DESCRIPTION file. 


But now “R CMD install” fails with “C++11 standard requested but CXX11 is not 
defined”, which is, according to [the documentation], a lie. 

I can’t even circumvent this, as setting “CXX11=$(CXX)” in the src/Makevars 
file fails with “CXX definition recursive”, and hardcoding “CXX11=g++” is a bad 
idea. 

Did I do sth. wrong or is the C++11 support in R just broken atm.? 


Best, Philipp 

PS: After addressing all points in the submission of my popular package 
“IRkernel”, I didn’t get any feedback, and the file just vanished from the 
incoming directory in CRAN. I asked about it multiple times but got no answer. 
What can I do now? 

 

Helmholtz Zentrum Muenchen
Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)
Ingolstaedter Landstr. 1
85764 Neuherberg
www.helmholtz-muenchen.de
Aufsichtsratsvorsitzende: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrer: Prof. Dr. Guenther Wess, Heinrich Bassler, Dr. Alfons Enhsen
Registergericht: Amtsgericht Muenchen HRB 6466
USt-IdNr: DE 129521671

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] R 3.4 has broken C++11 support

2017-04-18 Thread Martyn Plummer
A user with the email address flying-sh...@web.de has submitted a bug
report on this topic. 

https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17260

Assuming that you are the same person, I will address the issue here
first.

If you get the message “C++11 standard requested but CXX11 is not
defined” then this means that there is no available C++11 compiler on
your computer. The presence or absence of a working C++11 compiler is
determined at configure time when R is built.

The tests used by R's configure script to determine C++11 support are
more stringent in R 3.4.0 than in previous versions. However, if you
are using gcc you should be protected against this change. For versions
of gcc prior to 4.8 (which have only partial C++11 support) the same
tests as in R 3.3.x are used. This maintains the current behaviour on
long-term service Linux distributions that are stuck with old gcc
versions.

It would be help if you could share more information about your
platform - i.e. the output of sessionInfo() - and specify the compiler
version you are using.

Martyn

On Tue, 2017-04-18 at 15:11 +0200, Angerer, Philipp via R-devel wrote:
> 
> Hi, 
> 
> This commit (I’m using the mirror to have a working link) broke C++11
> compilation. 
> 
> Before (and still now, according to the comments in the configure
> script), it’s sufficient to just have “SystemRequirements: C++11” in
> the DESCRIPTION file. 
> 
> 
> But now “R CMD install” fails with “C++11 standard requested but
> CXX11 is not defined”, which is, according to the documentation , a
> lie. 
> 
> I can’t even circumvent this, as setting “CXX11=$(CXX)” in the
> src/Makevars file fails with “CXX definition recursive”, and
> hardcoding “CXX11=g++” is a bad idea. 
> 
> Did I do sth. wrong or is the C++11 support in R just broken atm.? 
> 
> 
> Best, Philipp 
> 
> PS: After addressing all points in the submission of my popular
> package “IRkernel”, I didn’t get any feedback, and the file just
> vanished from the incoming directory in CRAN. I asked about it
> multiple times but got no answer. What can I do now? 
> 
>  
> 
> 
> Helmholtz Zentrum Muenchen
> 
> Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)
> 
> Ingolstaedter Landstr. 1
> 
> 85764 Neuherberg
> 
> www.helmholtz-muenchen.de
> 
> Aufsichtsratsvorsitzende: MinDir'in Baerbel Brumme-Bothe
> 
> Geschaeftsfuehrer: Prof. Dr. Guenther Wess, Heinrich Bassler, Dr.
> Alfons Enhsen
> 
> Registergericht: Amtsgericht Muenchen HRB 6466
> 
> USt-IdNr: DE 129521671
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] R 3.4 has broken C++11 support

2017-04-18 Thread Angerer, Philipp via R-devel


Hi, 

This commit (I’m using the mirror to have a working link) broke C++11 
compilation. 

Before (and still now, according to the comments in the configure script), it’s 
sufficient to just have “SystemRequirements: C++11” in the DESCRIPTION file. 


But now “R CMD install” fails with “C++11 standard requested but CXX11 is not 
defined”, which is, according to the documentation , a lie. 

I can’t even circumvent this, as setting “CXX11=$(CXX)” in the src/Makevars 
file fails with “CXX definition recursive”, and hardcoding “CXX11=g++” is a bad 
idea. 

Did I do sth. wrong or is the C++11 support in R just broken atm.? 


Best, Philipp 

PS: After addressing all points in the submission of my popular package 
“IRkernel”, I didn’t get any feedback, and the file just vanished from the 
incoming directory in CRAN. I asked about it multiple times but got no answer. 
What can I do now? 

 


Helmholtz Zentrum Muenchen

Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)

Ingolstaedter Landstr. 1

85764 Neuherberg

www.helmholtz-muenchen.de

Aufsichtsratsvorsitzende: MinDir'in Baerbel Brumme-Bothe

Geschaeftsfuehrer: Prof. Dr. Guenther Wess, Heinrich Bassler, Dr. Alfons Enhsen

Registergericht: Amtsgericht Muenchen HRB 6466

USt-IdNr: DE 129521671


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] Q: Windows/readline: missing history search

2017-04-18 Thread Prof Brian Ripley
Your error is in your subject line: getline rather than readline is used 
on Windows.  (readline was not written for Windows and depends on a 
'curses' library not available for Windows terminals let alone RGui.  A 
considerable amount of time was spent trying to use it, unsuccessfully.)



On 13/04/2017 07:23, Ulrich Windl wrote:

Hello!

Ever since I used R on Windows (RGui) I am missing the ability to search the 
command history (Cntrl+R (reverse-search-history) in BASH, for example). Is 
there a particular reason for having this function disabled? Another feature 
would be word-wise delete (kill-word, backward-kill-word).

Probably being able to use the Alt-key as Meta key for readline (instead of 
activating menu entries) would be helpful. At least of the console window has 
the input focus.


That's the Windows way.  And users of e.g. Emacs on macOS know how this 
can cause awkward conflicts.



Another nice feature would be PuTTY-like copying of selected text: It's 
sufficient to mark text in the console to have it put into the clipboard. In 
Rgui I need an explicit copy.


That's the Windows way: PuTTY is using an older Unix/X11 standard (not 
so much used on Unix nowadays).



Finally I'd like if Rgui would remember the state of the MDI main window 
(maximized or not, maybe position and size also): Currently it always starts 
maximized.


AFAIR that is part of the configuration you can save.


Regards,
Ulrich




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Antw: Re: "table(droplevels(aq)$Month)" in manual page of droplevels

2017-04-18 Thread Ulrich Windl
>>> Martin Maechler  schrieb am 13.04.2017 um 16:16 
>>> in
Nachricht <22767.34875.318482.421...@stat.math.ethz.ch>:
[...]
> Ulrich, please note that in the end this was all  because you're
> still learning to understand R (e.g., data frames !) better.

Hi!

I understood that I did not understand the example due to my lack of R 
knowledge. That is the point you made.
However I read a book on R, the introduction on R, and several tutorials on R, 
and I still never saw the use pattern presented in the example.
Thus I think my proposal to present more comprehensible examples is a valid 
one. Alternatively the introduction to R could be extended to a level that 
allows the user to understand the example presented.
Honestly there are many example I don't understand (plus descriptions that I 
hope to understand from the examples).
While I understand that R developers prefer to be left alone, not hearing about 
such issues, I think even R developers could benefit from hearing of beginner's 
problems.
Anyway R developers are free to forward messages to R-help if they think more 
appropriate for R-help.

> 
> As such this was completely inappropriate for R-devel and should
> have gotten to the R help list  R-help.

Regards,
Ulrich


> 
> With regards,
> Martin Maechler, ETH Zurich
[...]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel