Mesa (staging/18.3): st/nine: fix stack corruption due to ABI mismatch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 14 18:56:14 UTC 2018


Module: Mesa
Branch: staging/18.3
Commit: 5f137e94b992a62e98dfa604cd43f57c5385e53b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f137e94b992a62e98dfa604cd43f57c5385e53b

Author: Andre Heider <a.heider at gmail.com>
Date:   Tue Nov  6 09:27:12 2018 +0100

st/nine: fix stack corruption due to ABI mismatch

This fixes various crashes and hangs when using nine's 'thread_submit'
feature.

On 64bit, the thread function's data argument would just be NULL.
On 32bit, the data argument would be garbage depending on the compiler
flags (in my case -march>=core2).

Fixes: f3fa7e3068512d ("st/nine: Use WINE thread for threadpool")
Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Andre Heider <a.heider at gmail.com>
Reviewed-by: Axel Davy <davyaxel0 at gmail.com>
(cherry picked from commit 10598c9667a9c5ea04ac8279549b1df8c026ef51)

---

 src/gallium/state_trackers/nine/threadpool.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/threadpool.c b/src/gallium/state_trackers/nine/threadpool.c
index cc62fd2579..19721aab2d 100644
--- a/src/gallium/state_trackers/nine/threadpool.c
+++ b/src/gallium/state_trackers/nine/threadpool.c
@@ -37,6 +37,7 @@
 #include "os/os_thread.h"
 #include "threadpool.h"
 
+/* POSIX thread function */
 static void *
 threadpool_worker(void *data)
 {
@@ -76,6 +77,15 @@ threadpool_worker(void *data)
     return NULL;
 }
 
+/* Windows thread function */
+static DWORD NINE_WINAPI
+wthreadpool_worker(void *data)
+{
+    threadpool_worker(data);
+
+    return 0;
+}
+
 struct threadpool *
 _mesa_threadpool_create(struct NineSwapChain9 *swapchain)
 {
@@ -87,7 +97,9 @@ _mesa_threadpool_create(struct NineSwapChain9 *swapchain)
     pthread_mutex_init(&pool->m, NULL);
     pthread_cond_init(&pool->new_work, NULL);
 
-    pool->wthread = NineSwapChain9_CreateThread(swapchain, threadpool_worker, pool);
+    /* This uses WINE's CreateThread, so the thread function needs to use
+     * the Windows ABI */
+    pool->wthread = NineSwapChain9_CreateThread(swapchain, wthreadpool_worker, pool);
     if (!pool->wthread) {
         /* using pthread as fallback */
         pthread_create(&pool->pthread, NULL, threadpool_worker, pool);




More information about the mesa-commit mailing list