Hi,

I recently came across this issue in viewperf (from SPEC):

Viewperf defines a local glGenBuffers function pointer, initializes to NULL, and then decides since it isn't using VBOs to never initialize to a real function. Thus with PBOs on by default in VGL now, VGL does readback, calls glGenBuffers() and gets a SEGV because the pointer is NULL.

The most simple patch is add a "&& glGenBuffers" before pbdrawable uses glGenBuffers) but means the rest of the code can't rely on the fconfig.readback status.

The still simple but slightly cleaner (if you'll excuse the type abuse) fix is to disable PBO readback if glGenBuffers is NULL (check in fakerconfig.cpp). Patch attached. (I wasn't sure if you cared about requiring libGL for everything that links with fakerconfig.cpp or not, hence the dlsym rather than including gl.h)

An alternate fix, that has the benefit of allowing PBOs with viewperf, would be to check if the symbol was NULL and dlsym(RTLD_NEXT, glGenBuffers), plus all the other symbols viewperf NULLs.

Patch applies to trunk with:

patch -p1 < 0001-Disable-PBO-use-if-glGenBuffers-is-NULL.patch

Cheers,

-Nathan

P.S. Of course this error points out that the same issue could happen with *any* symbol that VGL calls directly but the app redefined. I think the "dlsym all GL functions VGL uses" step is only something to consider if we see it in practice, but something I'm keeping in the back of my mind is that google suggests that GLEW in particular seems to have this paradigm of all extension functions are pointers, and app needs to initialize after a context is created. Any call that invokes VGL usage (e.g. glxSwapBuffers) before that GLEW initialization is done in the app will easily end up the the same SEGV situation.
Index: server/fakerconfig.cpp
===================================================================
--- server/fakerconfig.cpp	(revision 3514)
+++ server/fakerconfig.cpp	(working copy)
@@ -26,6 +26,7 @@
 #include <sys/ipc.h>
 #include <sys/types.h>
 #endif
+#include <dlfcn.h>
 #include "vglutil.h"
 #include <X11/Xatom.h>
 #ifdef USEXV
@@ -407,6 +408,20 @@
 		if(readback>=0 && (!fconfig_envset || fconfig_env.readback!=readback))
 			fconfig.readback=fconfig_env.readback=readback;
 	}
+	if (RRREAD_PBO==fconfig.readback)
+        {
+		int *gen=(int *)dlsym(RTLD_DEFAULT, "glGenBuffers");
+		if (!gen || !*gen)
+		{
+			static int printed=0;
+			fconfig.readback=fcenv.readback=RRREAD_SYNC;
+			if (!printed)
+			{
+				rrout.println("[VGL] Forcing synchronous readback due to NULL glGenBuffers\n");
+				printed=1;
+			}
+		}
+	}
 	fetchenv_dbl("VGL_REFRESHRATE", refreshrate, 0.0, 1000000.0);
 	fetchenv_int("VGL_SAMPLES", samples, 0, 64);
 	fetchenv_bool("VGL_SPOIL", spoil);
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
VirtualGL-Devel mailing list
VirtualGL-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtualgl-devel

Reply via email to