mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Added patch to use a separate stack when starting new threads.
This commit is contained in:
parent
579d7f8032
commit
95ff86b496
@ -0,0 +1,81 @@
|
||||
From ef57b2c7cadda78730cb57e117507c7a8a0ff6cb Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Wed, 13 Apr 2016 03:11:03 +0200
|
||||
Subject: ntdll: Use a separate stack when starting new threads.
|
||||
|
||||
---
|
||||
dlls/ntdll/thread.c | 33 +++++++++++++++++++++++----------
|
||||
1 file changed, 23 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
|
||||
index 07dc285..db27447 100644
|
||||
--- a/dlls/ntdll/thread.c
|
||||
+++ b/dlls/ntdll/thread.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
+#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
@@ -452,15 +453,8 @@ void exit_thread( int status )
|
||||
static void start_thread( struct startup_info *info )
|
||||
{
|
||||
TEB *teb = info->teb;
|
||||
- struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)teb->SpareBytes1;
|
||||
PRTL_THREAD_START_ROUTINE func = info->entry_point;
|
||||
void *arg = info->entry_arg;
|
||||
- struct debug_info debug_info;
|
||||
-
|
||||
- debug_info.str_pos = debug_info.strings;
|
||||
- debug_info.out_pos = debug_info.output;
|
||||
- thread_data->debug_info = &debug_info;
|
||||
- thread_data->pthread_id = pthread_self();
|
||||
|
||||
signal_init_thread( teb );
|
||||
server_init_thread( func );
|
||||
@@ -476,6 +470,26 @@ static void start_thread( struct startup_info *info )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
+ * call_start_thread
|
||||
+ *
|
||||
+ * Setup debug_info struct and call start_thread on target stack.
|
||||
+ */
|
||||
+static void call_start_thread( struct startup_info *info )
|
||||
+{
|
||||
+ TEB *teb = info->teb;
|
||||
+ struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)teb->SpareBytes1;
|
||||
+ struct debug_info debug_info;
|
||||
+
|
||||
+ debug_info.str_pos = debug_info.strings;
|
||||
+ debug_info.out_pos = debug_info.output;
|
||||
+ thread_data->debug_info = &debug_info;
|
||||
+ thread_data->pthread_id = pthread_self();
|
||||
+
|
||||
+ wine_switch_to_stack( (void (*)(void *))start_thread, info, teb->Tib.StackBase );
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/***********************************************************************
|
||||
* RtlCreateUserThread (NTDLL.@)
|
||||
*/
|
||||
NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *descr,
|
||||
@@ -581,11 +595,10 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
|
||||
if ((status = virtual_alloc_thread_stack( teb, stack_reserve, stack_commit ))) goto error;
|
||||
|
||||
pthread_attr_init( &attr );
|
||||
- pthread_attr_setstack( &attr, teb->DeallocationStack,
|
||||
- (char *)teb->Tib.StackBase - (char *)teb->DeallocationStack );
|
||||
+ pthread_attr_setstacksize( &attr, PTHREAD_STACK_MIN );
|
||||
pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); /* force creating a kernel thread */
|
||||
interlocked_xchg_add( &nb_threads, 1 );
|
||||
- if (pthread_create( &pthread_id, &attr, (void * (*)(void *))start_thread, info ))
|
||||
+ if (pthread_create( &pthread_id, &attr, (void * (*)(void *))call_start_thread, info ))
|
||||
{
|
||||
interlocked_xchg_add( &nb_threads, -1 );
|
||||
pthread_attr_destroy( &attr );
|
||||
--
|
||||
2.7.1
|
||||
|
2
patches/ntdll-Thread_Stack/definition
Normal file
2
patches/ntdll-Thread_Stack/definition
Normal file
@ -0,0 +1,2 @@
|
||||
Fixes: Use a separate stack when starting new threads
|
||||
Depends: ntdll-ThreadTime
|
@ -232,6 +232,7 @@ patch_enable_all ()
|
||||
enable_ntdll_SystemRecommendedSharedDataAlignment="$1"
|
||||
enable_ntdll_SystemRoot_Symlink="$1"
|
||||
enable_ntdll_ThreadTime="$1"
|
||||
enable_ntdll_Thread_Stack="$1"
|
||||
enable_ntdll_Threading="$1"
|
||||
enable_ntdll_User_Shared_Data="$1"
|
||||
enable_ntdll_WRITECOPY="$1"
|
||||
@ -869,6 +870,9 @@ patch_enable ()
|
||||
ntdll-ThreadTime)
|
||||
enable_ntdll_ThreadTime="$2"
|
||||
;;
|
||||
ntdll-Thread_Stack)
|
||||
enable_ntdll_Thread_Stack="$2"
|
||||
;;
|
||||
ntdll-Threading)
|
||||
enable_ntdll_Threading="$2"
|
||||
;;
|
||||
@ -2139,6 +2143,13 @@ if test "$enable_ntdll_WRITECOPY" -eq 1; then
|
||||
enable_ws2_32_WriteWatches=1
|
||||
fi
|
||||
|
||||
if test "$enable_ntdll_Thread_Stack" -eq 1; then
|
||||
if test "$enable_ntdll_ThreadTime" -gt 1; then
|
||||
abort "Patchset ntdll-ThreadTime disabled, but ntdll-Thread_Stack depends on that."
|
||||
fi
|
||||
enable_ntdll_ThreadTime=1
|
||||
fi
|
||||
|
||||
if test "$enable_ntdll_SystemRoot_Symlink" -eq 1; then
|
||||
if test "$enable_ntdll_Exception" -gt 1; then
|
||||
abort "Patchset ntdll-Exception disabled, but ntdll-SystemRoot_Symlink depends on that."
|
||||
@ -5115,6 +5126,21 @@ if test "$enable_ntdll_ThreadTime" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset ntdll-Thread_Stack
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * ntdll-ThreadTime
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/ntdll/thread.c
|
||||
# |
|
||||
if test "$enable_ntdll_Thread_Stack" -eq 1; then
|
||||
patch_apply ntdll-Thread_Stack/0001-ntdll-Use-a-separate-stack-when-starting-new-threads.patch
|
||||
(
|
||||
echo '+ { "Sebastian Lackner", "ntdll: Use a separate stack when starting new threads.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset ntdll-Threading
|
||||
# |
|
||||
# | Modified files:
|
||||
|
Loading…
x
Reference in New Issue
Block a user