Skip to content

x11(....) kills R without DISPLAY (PR#10379)

6 messages · Christian Brechbühler, Hin-Tak Leung, Peter Dalgaard

#
Full_Name: Christian Brechbuehler
Version: 2.4.1, 2.5.1, 
OS: Ubuntu GNU/Linux
Submission from: (NULL) (24.61.47.236)


Context:
'X11' starts a graphics device driver on the display given by argument
'display'.

Problem:
If the environment variable DISPLAY is not set, the R process dies with exit
status 1.

Example (start R without DISPLAY from bash):
  % DISPLAY= R
  > x11("localhost:11.0")                        # this is my valid DISPLAY
  Error: Couldn't find per display information
  %

History:
This was reported before (e.g.,
https://stat.ethz.ch/pipermail/ess-help/2006-April/003464.html), but search
turns up no R Bug Report.

Reportedly this problem was introduced between R 2.2.1 and R 2.3.0.  The
following versions are affected:
  R 2.4.1 (Patched), 2007-03-25, svn.rev 40917, x86_64-unknown-linux-gnu
  R 2.5.1 (Patched), 2007-09-16, svn.rev 43071, x86_64-unknown-linux-gnu 
  R 2.6.0 (Patched), 2007-10-16, svn.rev 43176, x86_64-unknown-linux-gnu 
  R 2.6.0 (Patched), 2007-10-25, svn.rev 43271, x86_64-unknown-linux-gnu 
  R 2.7.0 (Under development (unstable)), 2007-10-25, svn.rev 43273,
x86_64-unknown-linux-gnu


Further Observations:

(A) If DISPLAY is set but not a valid X11 server, R dies equally.

(B) If DISPLAY is set to an X11 server on which I don't have access, the x11
call fails as follows:
| Error in x11("localhost:11.0") : 
|    X11 fatal IO error: please save work and shut down R
|
| Enter a frame number, or 0 to exit   
| 
| 1: x11("localhost:11.0")
|
| Selection:
I.e., the R session survives.  But it is not possible to start an X11 graphics
device driver.

(C) If DISPLAY is set to an X11 server on which I have access, the x11 call
succeeds, and it opens a window on the server named in the 'display' argument. 
Nothing happens on DISPLAY, which is appropriate.

My conjecture: R seems to first connect to the server given by the DISPLAY
environment variable, performing no visible operations, before heeding the
'display' argument.

(D) It is possible to swich between X11 servers (a.k.a. displays) on the fly by
using graphics.off() followed by x11(my.new.display).

When Googling, I found the error string "Couldn't find per display information"
sometimes associated with the Xt library.

I'd be happy to answer any questions that may help clarify the issue.
#
brechbuehler at gmail.com wrote:
I see this on Fedora 7 too. I suspect that the earlier report was 
thought to be Mac specific.
(E) It appears that you have to use a valid display in the x11() call

 > x11(":1")
Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 
else gamma,  :
  unable to start device X11
In addition: Warning message:
In x11(":1") : unable to open connection to X11 display ':1'
 > x11(":0")
Error: Couldn't find per display information

  
    
#
Peter Dalgaard wrote:
<snipped>
<snipped>
<snipped>

I was experimenting with xvfb last week and didn't see the catatrophic 
problem like that, so I tried again. Is it possible that this has 
already been fixed in R 2.6.0 ? (I am on fedora 7, x86_64 as well).

------------------------------------------
$ export -n DISPLAY

$ R
R version 2.6.0 (2007-10-03)
...
 > x11()
Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 
else gamma,  :
   unable to start device X11
In addition: Warning message:
In x11() : unable to open connection to X11 display ''
 > q()
Save workspace image? [y/n/c]: n
$ export DISPLAY=
$ R
R version 2.6.0 (2007-10-03)
...
 > x11()
Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 
else gamma,  :
   unable to start device X11
In addition: Warning message:
In x11() : unable to open connection to X11 display ''
 > q()
Save workspace image? [y/n/c]: n
#
Hin-Tak Leung wrote:
You need x11() with a valid display to trigger the bug:

[pd at titmouse2 BUILD]$ ssh -Y 192.168.1.10
pd at 192.168.1.10's password:
Last login: Sat Oct 27 02:40:16 2007 from 192.168.1.11
[pd at janus ~]$ echo $DISPLAY
localhost:10.0
[pd at janus ~]$ DISPLAY= R -q
 > x11("localhost:10.0")
Error: Couldn't find per display information
[pd at janus ~]$ uname -a
Linux janus 2.6.22.9-91.fc7 #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64 
x86_64 x86_64 GNU/Linux
[pd at janus ~]$ cat /etc/issue
Fedora release 7 (Moonshine)
Kernel \r on an \m
2 days later
#
Peter Dalgaard wrote:
<snipped>
Agh, sorry. Yes, x11() (with or without $DISPLAY set) doesn't
die catatrophically, x11("validinfo") does.

HTL
#
Hin-Tak Leung wrote:
The culprit would seem to be this bit of devX11.c

1302                    xtdpy = XtOpenDisplay(app_con, NULL, "r_x11", 
"R_x11",
1303                                          NULL, 0, &zero, NULL);
1304                    toplevel = XtAppCreateShell(NULL, "R_x11",

The 2nd arg to XtOpenDisplay is listed as display_string, so passing a 
NULL here seems like trouble when the default ways of finding the 
display do not work.

Looks like a fix is to insert p instead of NULL. (Tested rudimentarily.)