From 2b7fd5b11df95869249a1bdc6e1b222747aaa075 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 7 Jan 2015 14:27:12 +0000 Subject: [PATCH] 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 --- 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 400c158a755..4b5b694a7fb 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) -- 2.30.2