Mesa (master): mesa: Don't use _mesa_generic_nop on Windows.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Jan 7 20:09:07 UTC 2015


Module: Mesa
Branch: master
Commit: 2b7fd5b11df95869249a1bdc6e1b222747aaa075
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b7fd5b11df95869249a1bdc6e1b222747aaa075

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Jan  7 14:27:12 2015 +0000

mesa: Don't use _mesa_generic_nop on Windows.

It doesn't work on Windows because of STDCALL calling convention -- it's
the callee responsibility to pop the arguments, and the number of
arguments vary with the prototype --, so the stack pointer ends up getting
corrupted.

This is just a non-invasive stop-gap fix.  A proper fix would be more
elaborate, and require either:
- a variation of __glapi_noop_table which sets GL_INVALID_OPERATION
  error
- stop using APIENTRY on all internal _mesa_* functions.

Tested with piglit gl-1.0-beginend-coverage (it now fails instead of
crashing).

VMware PR1350505

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/context.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 400c158..4b5b694 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -908,6 +908,9 @@ nop_glFlush(void)
 #endif
 
 
+extern void (*__glapi_noop_table[])(void);
+
+
 /**
  * Allocate and initialize a new dispatch table.  All the dispatch
  * function pointers will point at the _mesa_generic_nop() function
@@ -929,7 +932,13 @@ _mesa_alloc_dispatch_table(void)
       _glapi_proc *entry = (_glapi_proc *) table;
       GLint i;
       for (i = 0; i < numEntries; i++) {
+#if defined(_WIN32)
+         /* FIXME: This will not generate an error, but at least it won't
+          * corrupt the stack like _mesa_generic_nop does. */
+         entry[i] = __glapi_noop_table[i];
+#else
          entry[i] = (_glapi_proc) _mesa_generic_nop;
+#endif
       }
 
 #if defined(_WIN32)




More information about the mesa-commit mailing list