Skip to content

Commit 10598c9

Browse files
dhewgaxeldavy
authored andcommitted
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: f3fa7e3 ("st/nine: Use WINE thread for threadpool") Cc: [email protected] Signed-off-by: Andre Heider <[email protected]> Reviewed-by: Axel Davy <[email protected]>
1 parent d2b2364 commit 10598c9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/gallium/state_trackers/nine/threadpool.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "os/os_thread.h"
3838
#include "threadpool.h"
3939

40+
/* POSIX thread function */
4041
static void *
4142
threadpool_worker(void *data)
4243
{
@@ -76,6 +77,15 @@ threadpool_worker(void *data)
7677
return NULL;
7778
}
7879

80+
/* Windows thread function */
81+
static DWORD NINE_WINAPI
82+
wthreadpool_worker(void *data)
83+
{
84+
threadpool_worker(data);
85+
86+
return 0;
87+
}
88+
7989
struct threadpool *
8090
_mesa_threadpool_create(struct NineSwapChain9 *swapchain)
8191
{
@@ -87,7 +97,9 @@ _mesa_threadpool_create(struct NineSwapChain9 *swapchain)
8797
pthread_mutex_init(&pool->m, NULL);
8898
pthread_cond_init(&pool->new_work, NULL);
8999

90-
pool->wthread = NineSwapChain9_CreateThread(swapchain, threadpool_worker, pool);
100+
/* This uses WINE's CreateThread, so the thread function needs to use
101+
* the Windows ABI */
102+
pool->wthread = NineSwapChain9_CreateThread(swapchain, wthreadpool_worker, pool);
91103
if (!pool->wthread) {
92104
/* using pthread as fallback */
93105
pthread_create(&pool->pthread, NULL, threadpool_worker, pool);

0 commit comments

Comments
 (0)