skip to Main Content

I’m trying to install rgl on a R 4.2.0 installation that I have installed from source, on a Ubuntu 18.04 system. The package seems to be building correctly, however I get a Segmentation fault when R tries to test whether it can load the package. This happens whether I install from CRAN or directly from the rgl repo:

[...]
** 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
Segmentation fault (core dumped)
ERROR: loading failed

any idea of what is going on or what I could check?

EDIT 1

I tried following the suggestion of @user2554330, installed the package skipping the post-install check and then loaded it in an R session under a debugger (I used valgrind). Here’s the trace, it’s not very helpful to me but hopefully to you:

==36041== Conditional jump or move depends on uninitialised value(s)
==36041==    at 0x56914B7: __wmemchr_avx2 (memchr-avx2.S:275)
==36041==    by 0x55EC518: internal_fnwmatch (fnmatch_loop.c:168)
==36041==    by 0x55EF987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==36041==    by 0x16F2EB35: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x55E1FA3: __scandir_tail (scandir-tail.c:54)
==36041==    by 0x16F2EE6D: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x16E52A98: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x14940103: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==36041==    by 0x14932F37: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==36041==    by 0x1492E5C3: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==36041==    by 0x1492EFA4: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==36041==    by 0x12C9B5EC: rgl::X11GUIFactory::createWindowImpl(rgl::Window*) (x11gui.cpp:662)
==36041==
==36041== Conditional jump or move depends on uninitialised value(s)
==36041==    at 0x5691497: __wmemchr_avx2 (memchr-avx2.S:264)
==36041==    by 0x55EC518: internal_fnwmatch (fnmatch_loop.c:168)
==36041==    by 0x55EF987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==36041==    by 0x16F2EB35: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x55E1FA3: __scandir_tail (scandir-tail.c:54)
==36041==    by 0x16F2EE6D: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x16F2ADD1: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x1693F41C: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x169391EA: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x16E52AA0: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==36041==    by 0x14940103: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==36041==    by 0x14932F37: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==36041==
==36041== Invalid read of size 8
==36041==    at 0x12C8EC50: rgl::Window::on_close() (gui.cpp:306)
==36041==    by 0x12C79B83: rgl::DeviceManager::createTestWindow() (devicemanager.cpp:171)
==36041==    by 0x12C8EE67: rgl_init (init.cpp:97)
==36041==    by 0x4F38F03: ??? (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F7B2AA: ??? (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F8565F: Rf_eval (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F8746E: ??? (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F88236: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F7C093: ??? (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F8565F: Rf_eval (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F8746E: ??? (in /usr/lib/R/lib/libR.so)
==36041==    by 0x4F88236: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==36041==  Address 0x20 is not stack'd, malloc'd or (recently) free'd

EDIT 2

After this, I tried turning on rgl debug before loading it:

> options(rgl.debug=TRUE)
> library(rgl)
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

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

Traceback:
 1: rgl.init(initValue, onlyNULL)
 2: fun(libname, pkgname)
 3: doTryCatch(return(expr), name, parentenv, handler)
 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 5: tryCatchList(expr, classes, parentenv, handlers)
 6: tryCatch(fun(libname, pkgname), error = identity)
 7: runHook(".onLoad", env, package.lib, package)
 8: loadNamespace(package, lib.loc)
 9: doTryCatch(return(expr), name, parentenv, handler)
10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
11: tryCatchList(expr, classes, parentenv, handlers)
12: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return && !quietly)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
13: library(rgl)

seems like it might be connected to the swrast driver.

2

Answers


  1. I’m not sure if it will help, but you could try this, namely:

    1. Run sudo nano ~/.profile
    2. Add the line:
    export MESA_LOADER_DRIVER_OVERRIDE=i965
    
    1. Close R and start a new R session, then try the package installation again.
    Login or Signup to reply.
  2. It looks to me as though rgl initialization failed, but the error wasn’t handled properly, leading to your segfault. The important messages are

    libGL error: No matching fbConfigs or visuals found
    libGL error: failed to load driver: swrast
    

    which caused the initialization failure. Then the invalid read of size 8 happened when the cleanup code tried to clean something up that had never been created.

    rgl should fix the cleanup code so you don’t get a segfault. To avoid that issue, you have two choices:

    1. Figure out what went wrong with swrast, and fix it. This question might be relevant: libGL error: failed to load driver: swrast – Running Ubuntu Docker container on Mac OS X host .

    2. Skip trying to use OpenGL within rgl, by setting the R option options(rgl.useNULL = TRUE) before loading rgl. It won’t display anything within the R session, but the rglwidget() function will create displays that can be viewed in a browser or in RStudio’s viewer.

    What rgl should do is automatically fall back to #2 when the initialization fails; after the bug is fixed that should happen.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search