Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
67e45d66
Commit
67e45d66
authored
Feb 23, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Don't free the thread stack and TEB while exiting, do it from the next thread.
parent
7d1952b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
23 deletions
+22
-23
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+1
-2
thread.c
dlls/ntdll/thread.c
+21
-21
No files found.
dlls/ntdll/ntdll_misc.h
View file @
67e45d66
...
...
@@ -195,8 +195,7 @@ struct ntdll_thread_data
int
wait_fd
[
2
];
/* 1e8 fd for sleeping server requests */
void
*
vm86_ptr
;
/* 1f0 data for vm86 mode */
void
*
pthread_data
;
/* 1f4 private data for pthread emulation */
void
*
pad
[
1
];
/* 1f8 change this if you add fields! */
pthread_t
pthread_id
;
/* 1f8 pthread thread id */
};
static
inline
struct
ntdll_thread_data
*
ntdll_get_thread_data
(
void
)
...
...
dlls/ntdll/thread.c
View file @
67e45d66
...
...
@@ -353,9 +353,9 @@ HANDLE thread_init(void)
*/
void
abort_thread
(
int
status
)
{
pthread_sigmask
(
SIG_BLOCK
,
&
server_block_set
,
NULL
);
if
(
interlocked_xchg_add
(
&
nb_threads
,
-
1
)
<=
1
)
_exit
(
status
);
pthread_sigmask
(
SIG_BLOCK
,
&
server_block_set
,
NULL
);
close
(
ntdll_get_thread_data
()
->
wait_fd
[
0
]
);
close
(
ntdll_get_thread_data
()
->
wait_fd
[
1
]
);
close
(
ntdll_get_thread_data
()
->
reply_fd
);
...
...
@@ -369,11 +369,8 @@ void abort_thread( int status )
*/
static
void
DECLSPEC_NORETURN
exit_thread
(
int
status
)
{
int
fds
[
4
];
void
*
teb_addr
;
SIZE_T
teb_size
;
if
(
interlocked_xchg_add
(
&
nb_threads
,
-
1
)
<=
1
)
exit
(
status
);
static
void
*
prev_teb
;
TEB
*
teb
;
RtlAcquirePebLock
();
RemoveEntryList
(
&
NtCurrentTeb
()
->
TlsLinks
);
...
...
@@ -381,23 +378,26 @@ static void DECLSPEC_NORETURN exit_thread( int status )
RtlFreeHeap
(
GetProcessHeap
(),
0
,
NtCurrentTeb
()
->
FlsSlots
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
NtCurrentTeb
()
->
TlsExpansionSlots
);
fds
[
0
]
=
ntdll_get_thread_data
()
->
wait_fd
[
0
];
fds
[
1
]
=
ntdll_get_thread_data
()
->
wait_fd
[
1
];
fds
[
2
]
=
ntdll_get_thread_data
()
->
reply_fd
;
fds
[
3
]
=
ntdll_get_thread_data
()
->
request_fd
;
pthread_sigmask
(
SIG_BLOCK
,
&
server_block_set
,
NULL
);
if
(
interlocked_xchg_add
(
&
nb_threads
,
-
1
)
<=
1
)
exit
(
status
);
virtual_free_system_view
(
&
NtCurrentTeb
()
->
DeallocationStack
);
teb_addr
=
NtCurrentTeb
();
teb_size
=
virtual_free_system_view
(
&
teb_addr
);
close
(
fds
[
0
]
);
close
(
fds
[
1
]
);
close
(
fds
[
2
]
);
close
(
fds
[
3
]
);
if
((
teb
=
interlocked_xchg_ptr
(
&
prev_teb
,
NtCurrentTeb
()
)))
{
struct
ntdll_thread_data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
SIZE_T
size
;
pthread_join
(
thread_data
->
pthread_id
,
NULL
);
wine_ldt_free_fs
(
thread_data
->
fs
);
size
=
0
;
NtFreeVirtualMemory
(
GetCurrentProcess
(),
&
teb
->
DeallocationStack
,
&
size
,
MEM_RELEASE
);
size
=
0
;
NtFreeVirtualMemory
(
GetCurrentProcess
(),
(
void
**
)
&
teb
,
&
size
,
MEM_RELEASE
);
}
wine_ldt_free_fs
(
wine_get_fs
()
);
if
(
teb_size
)
munmap
(
teb_addr
,
teb_size
);
close
(
ntdll_get_thread_data
()
->
wait_fd
[
0
]
);
close
(
ntdll_get_thread_data
()
->
wait_fd
[
1
]
);
close
(
ntdll_get_thread_data
()
->
reply_fd
);
close
(
ntdll_get_thread_data
()
->
request_fd
);
pthread_exit
(
UIntToPtr
(
status
)
);
}
...
...
@@ -479,6 +479,7 @@ static void start_thread( struct wine_pthread_thread_info *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
);
...
...
@@ -632,7 +633,6 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
pthread_attr_init
(
&
attr
);
pthread_attr_setstacksize
(
&
attr
,
stack_reserve
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment