From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Roj7B-0006qg-0D for qemu-devel@nongnu.org; Sat, 21 Jan 2012 17:08:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Roj79-00011v-Ml for qemu-devel@nongnu.org; Sat, 21 Jan 2012 17:08:48 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:49071) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Roj79-00011p-DV for qemu-devel@nongnu.org; Sat, 21 Jan 2012 17:08:47 -0500 Message-ID: <4F1B376C.3000908@weilnetz.de> Date: Sat, 21 Jan 2012 23:08:44 +0100 From: Stefan Weil MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Init win32 CRITICAL_SECTION before starting thread; crash when attaching disks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bogdan Harjoc Cc: qemu-devel@nongnu.org Am 29.12.2011 18:29, schrieb Bogdan Harjoc: > Git commit 8d3bc51 crashes on win32 on startup because > qemu_tcg_init_vcpu calls: > > qemu_thread_create(th, qemu_tcg_cpu_thread_fn, ... > ... > qemu_thread_get_handle(th) > > which locks th->data->cs, a CRITICAL_SECTION which is initialized only > in the thread_fn, so it finds garbage. > > Attached patch initializes it before calling _beginthreadex. > GDB/windbg probably start newly created threads sooner, because this > doesn't happen under a debugger. > > With the patch below it boots until it crashes somewhere while > attaching disks (-hda raw_img). > > "bt" in gdb only returns "#0 0x00000000 in ??" and generate-core-file > didn't work. > > Cheers, > > diff -du qemu-8d3bc51\qemu-thread-win32.c > qemu-8d3bc51-new\qemu-thread-win32.c > --- qemu-8d3bc51\qemu-thread-win32.c Tue Dec 27 17:28:58 2011 > +++ qemu-8d3bc51-new\qemu-thread-win32.c Thu Dec 29 18:59:50 2011 > @@ -215,8 +215,6 @@ > if (data->mode == QEMU_THREAD_DETACHED) { > g_free(data); > data = NULL; > - } else { > - InitializeCriticalSection(&data->cs); > } > TlsSetValue(qemu_thread_tls_index, data); > qemu_thread_exit(start_routine(thread_arg)); > @@ -287,6 +285,10 @@ > data->arg = arg; > data->mode = mode; > data->exited = false; > + > + if (data->mode != QEMU_THREAD_DETACHED) { > + InitializeCriticalSection(&data->cs); > + } > > hThread = (HANDLE) _beginthreadex(NULL, 0, win32_start_routine, > data, 0, &thread->tid); > Hi, could you please resend your patch with a Signed-by line? And you should use "git format-patch" to create the patch. See http://wiki.qemu.org/Contribute/SubmitAPatch for more information. Thanks, Stefan Weil