From 9b9ca093c763c36ff4121ee9ca233a82f6d33c59 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 12 Apr 2016 18:12:04 -0400 Subject: [PATCH] windows: created threads' stack sizes should be reserved, not committed. --- src/thread/windows/SDL_systhread.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 249e361ba44cb..735178019882e 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -121,6 +121,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ pThreadStartParms pThreadParms = (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); + const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0; if (!pThreadParms) { return SDL_OutOfMemory(); } @@ -135,12 +136,12 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) thread->handle = (SYS_ThreadHandle) ((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize, RunThreadViaBeginThreadEx, - pThreadParms, 0, &threadid)); + pThreadParms, flags, &threadid)); } else { DWORD threadid = 0; thread->handle = CreateThread(NULL, thread->stacksize, RunThreadViaCreateThread, - pThreadParms, 0, &threadid); + pThreadParms, flags, &threadid); } if (thread->handle == NULL) { return SDL_SetError("Not enough resources to create thread");