From: Paolo Bonzini <pbonzini@redhat.com>
To: Bogdan Harjoc <harjoc@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Init win32 CRITICAL_SECTION before starting thread; crash when attaching disks
Date: Fri, 30 Dec 2011 16:57:26 +0100 [thread overview]
Message-ID: <4EFDDF66.3090909@redhat.com> (raw)
In-Reply-To: <CAF4+tmopXFry77uZitO5=KjPkgcjJE_gwpY8V051Vk=TWsx2QA@mail.gmail.com>
On 12/29/2011 06:29 PM, Bogdan Harjoc wrote:
> 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);
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2011-12-30 15:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-29 17:29 [Qemu-devel] [PATCH] Init win32 CRITICAL_SECTION before starting thread; crash when attaching disks Bogdan Harjoc
2011-12-30 15:57 ` Paolo Bonzini [this message]
2012-01-21 22:08 ` Stefan Weil
2012-01-21 22:11 ` Stefan Weil
2012-01-27 21:34 ` Stefan Weil
2012-01-30 22:23 ` Sebastian Herbszt
2012-01-31 6:18 ` [Qemu-devel] [PATCH] w32: Initialise critical section before starting thread (fix #922131) Stefan Weil
2012-02-01 7:54 ` Roy Tam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EFDDF66.3090909@redhat.com \
--to=pbonzini@redhat.com \
--cc=harjoc@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.