Skip to content

more rgl problems

18 messages · Ken Beath, Peter West, Duncan Murdoch +1 more

#
This is repeatable when the lines are all pasted in at once.
The example works if I allow some time delay between lines.

This is might be a relative of the one from a few months ago.
But this message is about invalid permissions.
=====

R version 4.0.4 RC (2021-02-12 r79998) -- "Lost Library Book"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.
error: xp_attach_gl_context returned: 2

 *** caught segfault ***
address 0x18, cause 'invalid permissions'

Traceback:
 1: rgl.open(useNULL)
 2: open3d()

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 


====
MacBookAir with the M1 chip using the regular intel version of R from CRAN.
Big Sur 11.2.1.
The plot(1:10), col=7) ## went by default to the quartz() device.


I repeated this about 5 times in ESS, and then once in Terminal.

Let me know if you need more information.
#
And speaking of M1 Silicon:

My XQuartz version is 2.7.11.

Started R 4.0.4.
Stopped R 4.0.4
Started RStudio
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/rgl_0.105.13.tgz'
Content type 'application/x-gzip' length 6446159 bytes (6.1 MB)
==================================================
downloaded 6.1 MB


The downloaded binary packages are in
	/var/folders/jf/mkyz74311796dl4mxx_7tcx80000gn/T//RtmpflD1wL/downloaded_packages
RStudio hangs indefinitely.

My RStudio is at 1.4.1103.

Peter

?
pbw at ehealth.id.au
?For what does it profit a man if he gains the whole world and loses or forfeits himself??

  
  
#
RStudio have a page for reporting bugs at https://github.com/rstudio/rstudio/issues/ <https://github.com/rstudio/rstudio/issues/> You may be the first M! bug.

They haven?t progressed my fairly serious bug report about Windows (if you plot a graph and the screen hasn?t updated when you start parallel processing then R crashes) from 6 weeks ago, so I wouldn?t be anticipating much progress soon.

Ken

  
  
#
Ken,

I only used RStudio because it is easier to remove packages. I should have made that clear.

The same thing happens with R.app; that is, library(rgl) hangs indefinitely.

Peter
?
pbw at ehealth.id.au
?For what does it profit a man if he gains the whole world and loses or forfeits himself??

  
  
#
On 17/02/2021 10:13 p.m., Peter West wrote:
That looks a lot like the issue Rich had last week (which I think is 
unrelated to the one posted today).  Have you tried the solution I 
posted for that?  Here's a copy:
I suspect it would be sufficient to just delete the 
/Library/LaunchAgents/org.xquartz.startx.plist and 
/Library/LaunchDaemons/org.xquartz.startx.plist files and reboot, but I 
haven't tried that.

Duncan Murdoch
#
Yes, I went through that process. I have no org.xquartz.* files in /Library Launch* now.

  
  
#
I can reproduce this on a Catalina machine, working in R from the terminal.

This definitely looks similar to the problem that 
rgl::setGraphicsDelay() was designed to solve, but even adding a 10 
second delay doesn't help.  I get a slightly different message than you:

 > open3d()
error: xp_attach_gl_context returned: 2

  *** caught segfault ***
address 0x18, cause 'memory not mapped'

but that might just be a different way of reporting the same underlying 
issue.

It's clearly some kind of interaction between the Quartz device and rgl. 
  I'll see if I can track it down.

Duncan Murdoch
On 17/02/2021 7:36 p.m., Richard M. Heiberger wrote:
#
On 18/02/2021 6:14 a.m., Peter West wrote:
If you run x11(), does it cause the same issue?

What about not starting R at all, and just running some X11 app like 
xclock from the terminal?

Duncan Murdoch
#
Looks like an authorization problem.

xclockk did not appear, so I had a look at system.log.

Here?s a sample.

---------------------------------------------------------------
Feb 18 20:40:09 Rosie org.macosforge.xquartz.startx[10388]: waiting for X server to begin accepting connections
Feb 18 20:40:09 Rosie org.macosforge.xquartz.startx[10388]: /opt/X11/bin/xinit: giving up
Feb 18 20:40:09 Rosie org.macosforge.xquartz.startx[10388]: /opt/X11/bin/xinit: unable to connect to X server: Operation timed out
Feb 18 20:40:09 Rosie org.macosforge.xquartz.startx[10388]: /opt/X11/bin/xinit: /opt/X11/bin/xinit: server error
Feb 18 20:40:09 Rosie org.macosforge.xquartz.startx[10388]: /opt/X11/bin/xinit:
Feb 18 21:51:40 Rosie org.macosforge.xquartz.startx[75167]: xauth:  file /Users/pbw/.serverauth.75168 does not exist
Feb 18 21:51:40 Rosie org.macosforge.xquartz.X11.stub[75265]: Xquartz: Unable to locate waiting server: org.macosforge.xquartz.X11
Feb 18 21:51:40 Rosie Xquartz[75272]: no path for address 0x7ffdffcec000
Feb 18 21:51:40 Rosie org.macosforge.xquartz.X11.stub[75272]: Xquartz: Starting X server: /Applications/Utilities/XQuartz.app/Contents/MacOS/X11 --listenonly
Feb 18 21:51:40 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/fonts.scale: fopen(w): Operation not permitted
Feb 18 21:51:40 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/fonts.dir: fopen(w): Operation not permitted
Feb 18 21:51:40 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/Supplemental/fonts.scale: fopen(w): Operation not permitted
Feb 18 21:51:40 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/Supplemental/fonts.dir: fopen(w): Operation not permitted
Feb 18 21:51:42 Rosie org.macosforge.xquartz.startx[75167]:

Feb 18 21:51:44 Rosie org.macosforge.xquartz.startx[75167]: waiting for X server to begin accepting connections
Feb 18 21:52:04 --- last message repeated 9 times ---
Feb 18 21:52:04 Rosie org.macosforge.xquartz.X11.stub[75265]: Xquartz: bootstrap_look_up(): Unknown service name
Feb 18 21:52:05 Rosie org.macosforge.xquartz.startx[75167]: waiting for X server to begin accepting connections
Feb 18 21:52:05 Rosie org.macosforge.xquartz.startx[75167]: waiting for X server to begin accepting connections giving up
Feb 18 21:52:05 Rosie org.macosforge.xquartz.startx[75167]: /opt/X11/bin/xinit: unable to connect to X server: Connection refused
Feb 18 21:52:05 Rosie org.macosforge.xquartz.startx[75167]: /opt/X11/bin/xinit: unable to connect to X server/opt/X11/bin/xinit: server error
Feb 18 21:52:05 Rosie org.macosforge.xquartz.startx[75167]: /opt/X11/bin/xinit: unable to connect to X server
Feb 18 21:52:06 Rosie org.macosforge.xquartz.privileged_startx[54309]: /opt/X11/bin/font_cache: line 92: /System/Library/Fonts/fonts.list: Operation not permitted
Feb 18 21:52:06 Rosie org.macosforge.xquartz.privileged_startx[54309]: /opt/X11/bin/font_cache: line 92: /System/Library/Fonts/Supplemental/fonts.list: Operation not permitted
Feb 18 21:52:06 Rosie org.macosforge.xquartz.startx[75566]: expr: syntax error
Feb 18 21:52:06 --- last message repeated 2 times ---
@
Feb 18 21:52:30 --- last message repeated 7 times ---
Feb 18 21:52:30 Rosie org.macosforge.xquartz.X11.stub[75664]: Xquartz: bootstrap_look_up(): Unknown service name
Feb 18 21:52:31 Rosie org.macosforge.xquartz.startx[75566]: waiting for X server to begin accepting connections
Feb 18 21:52:31 Rosie org.macosforge.xquartz.startx[75566]: waiting for X server to begin accepting connections giving up
Feb 18 21:52:31 Rosie org.macosforge.xquartz.startx[75566]: /opt/X11/bin/xinit: unable to connect to X server: Connection refused
Feb 18 21:52:31 Rosie org.macosforge.xquartz.startx[75566]: waiting for X server to begin accepting connections /opt/X11/bin/xinit: server error
Feb 18 21:52:31 Rosie org.macosforge.xquartz.startx[75566]: waiting for X server to begin accepting connections
Feb 18 21:52:32 Rosie org.macosforge.xquartz.startx[75977]: expr: syntax error
Feb 18 21:52:32 --- last message repeated 2 times ---
Feb 18 21:52:32 Rosie org.macosforge.xquartz.privileged_startx[54309]: /opt/X11/bin/font_cache: line 92: /System/Library/Fonts/fonts.list: Operation not permitted
Feb 18 21:52:32 Rosie org.macosforge.xquartz.privileged_startx[54309]: /opt/X11/bin/font_cache: line 92: /System/Library/Fonts/Supplemental/fonts.list: Operation not permitted
Feb 18 21:52:32 Rosie org.macosforge.xquartz.startx[75977]: xauth:  file /Users/pbw/.serverauth.75978 does not exist
Feb 18 21:52:32 Rosie org.macosforge.xquartz.X11.stub[76064]: Xquartz: Unable to locate waiting server: org.macosforge.xquartz.X11
Feb 18 21:52:32 Rosie Xquartz[76068]: no path for address 0x7ffdffcdd000
Feb 18 21:52:32 Rosie org.macosforge.xquartz.X11.stub[76068]: Xquartz: Starting X server: /Applications/Utilities/XQuartz.app/Contents/MacOS/X11 --listenonly
Feb 18 21:52:32 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/fonts.scale: fopen(w): Operation not permitted
Feb 18 21:52:32 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/fonts.dir: fopen(w): Operation not permitted
Feb 18 21:52:32 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/Supplemental/fonts.scale: fopen(w): Operation not permitted
Feb 18 21:52:32 Rosie org.macosforge.xquartz.privileged_startx[54309]: /System/Library/Fonts/Supplemental/fonts.dir: fopen(w): Operation not permitted
Feb 18 21:52:34 Rosie org.macosforge.xquartz.startx[75977]:

Feb 18 21:52:36 Rosie org.macosforge.xquartz.startx[75977]: waiting for X server to begin accepting connections---------------------------------------------------------------

  
  
#
This is happening as a result of the Launch* startx and privileged_startx execution. The Operation not permitted stuff just scrolls on by.
#
I?ve enabled /opt/X11/libexec/launchd_startx for full disk access in Security & Privacy, but it hasn?t fixed the problem.
#
On 18/02/2021 7:15 a.m., Peter West wrote:
In any case, it's a generic XQuartz problem, not related to R or rgl.

Duncan
#
On 18/02/2021 7:15 a.m., Peter West wrote:
One approach that was fruitful for me:

After uninstalling and reinstalling XQuartz 2.7.11, I looked around for 
related files with older install dates, especially dates around Feb 2, 
when I had installed 2.8.0beta.  The /Library/Launch* files showed up 
that way.

Duncan Murdoch
#
I've made some progress on this, but I don't know how to fix it properly.

What's happening is that rgl is trying to open the new window that 
open3d() asks for.  It gets most of the way through that operation, then 
calls glXMakeCurrent, which associates the OpenGL context with that 
window.  That call fails, but without generating any of the documented 
errors:  it just fails, triggering an X11 error handler with error code 
0 (which typically means no error).

In the released versions of rgl, that failure leads to a segfault, 
because I wasn't doing enough error checking.  I've fixed the segfault, 
but I'm still getting the error (in fact I'm getting it a lot more than 
I used to; not sure if it's my debugging code causing that), and after I 
get the error reported on screen, the new rgl window opens but doesn't 
work to display anything.

I think it's probably something wrong in the rgl initialization code; 
running this:

   plot(1:10, col=7)
   library(rgl)
   open3d()

is fine, whereas this:

   library(rgl)
   plot(1:10, col=7)
   open3d()

is always failing for me.  Or possibly this is an Xquartz bug, maybe a 
leftover from when I installed the beta.

I'd guess what's happening is that calling quartz() invalidates part of 
the initialization done by rgl.init(), but I don't know what part yet. 
I do want to call rgl.init() when loading rgl, because it might fail, 
and then I can drop back to the off-screen drawing.  It's too late to do 
that later.

A workaround that works for me is for the .onload() function in rgl to 
execute

  dev.new()
  dev.off()

before calling rgl.init(). It is less irritating than you might guess, 
because the window doesn't have time to appear before being destroyed, 
but I still don't like it.   I'll try it out a bit, and then push it to 
Github for others to test.

Duncan Murdoch
On 18/02/2021 6:28 a.m., Duncan Murdoch wrote:
#
This is from my MacBook Air mid-2012 running Catalina 10.15.7
with Xquartz 2.7.11
I never placed the beta on this machine.
I also see from a fresh R session

   plot(1:10, col=7)
   library(rgl)
   open3d()

is fine, whereas this:

   library(rgl)
   plot(1:10, col=7)
   open3d()
segfaults

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.
plot(1:10, col=7)
   open3d()
   library(rgl)
error: xp_attach_gl_context returned: 2

 *** caught segfault ***
address 0x18, cause 'memory not mapped'

Traceback:
 1: rgl.open(useNULL)
 2: open3d()

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 2
Warning message:
In rgl.open(useNULL) : RGL: ERROR: can't bind glx context to window

Process R finished at Thu Feb 18 17:57:37 2021
1 day later
#
If you are set up to install from source, could you try this?

   devtools::install_github("dmurdoch/rgl at quartzbug", type="source")

If you only have some of the requirements (e.g. no devel versions of 
packages) you might find you only get a partial build with no X11 
display; that won't really test the workaround.  In that case I'll try 
to build a binary for your R version.

Duncan Murdoch
On 18/02/2021 6:07 p.m., Richard M. Heiberger wrote:
#
I am running it now on 4.0.4RC.

The cran page
https://cran.r-project.org
offers download of 4.0.3 for mac, even though 4.0.4 is available on windows.
#
it ran to completion (with warnings).  then i dropped the three lines in and it worked.

lt for newer macOS version (11.0) than being linked (10.13)
ld: warning: dylib (/usr/local/lib/libpng16.dylib) was built for newer macOS version (11.0) than being linked (10.13)
mkdir -p ../inst/useNULL
mv useNULL/rgl.so ../inst/useNULL/
installing to /Users/rmh/Library/R/4.0/library/00LOCK-rgl/00new/rgl/libs
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rgl)
glX
  1