Delayed private heap allocation to after child the process started on windows

This commit is contained in:
Snaipe 2015-09-21 00:03:08 +02:00
parent 5f9f617ee7
commit acce462995

View file

@ -169,8 +169,6 @@ static void CALLBACK handle_child_terminated(PVOID lpParameter,
int resume_child(void) {
#ifdef VANILLA_WIN32
init_inheritable_heap();
TCHAR mapping_name[128];
_sntprintf(mapping_name, 128, g_mapping_name, GetCurrentProcessId());
@ -179,8 +177,10 @@ int resume_child(void) {
FALSE,
mapping_name);
if (sharedMem == NULL)
if (sharedMem == NULL) {
init_inheritable_heap();
return 0;
}
struct full_context *ctx = (struct full_context *) MapViewOfFile(sharedMem,
FILE_MAP_ALL_ACCESS,
@ -196,6 +196,20 @@ int resume_child(void) {
local_ctx = *ctx;
UnmapViewOfFile(ctx);
HANDLE self = GetCurrentThread();
DuplicateHandle(GetCurrentProcess(),
self,
GetCurrentProcess(),
&self,
0,
FALSE,
DUPLICATE_SAME_ACCESS);
SetEvent(local_ctx.sync);
SuspendThread(self);
init_inheritable_heap();
struct test_single_param *param = NULL;
if (local_ctx.param.size != 0) {
ctx = (struct full_context*) MapViewOfFile(sharedMem,
@ -325,8 +339,6 @@ s_proc_handle *fork_process() {
if (g_worker_context.suite->data)
ctx->suite_data = *g_worker_context.suite->data;
inherit_heap(info.hProcess);
if (ResumeThread(info.hThread) == (DWORD) -1)
goto failure;
@ -336,6 +348,11 @@ s_proc_handle *fork_process() {
if (wres == WAIT_OBJECT_0)
goto failure;
inherit_heap(info.hProcess);
if (ResumeThread(info.hThread) == (DWORD) -1)
goto failure;
CloseHandle(info.hThread);
UnmapViewOfFile(ctx);