From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMb7j-0006ZK-Bb for qemu-devel@nongnu.org; Thu, 19 Sep 2013 06:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMb7a-0003V1-Tb for qemu-devel@nongnu.org; Thu, 19 Sep 2013 06:06:11 -0400 Received: from mail-ea0-x229.google.com ([2a00:1450:4013:c01::229]:64984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMb7a-0003Uw-Mc for qemu-devel@nongnu.org; Thu, 19 Sep 2013 06:06:02 -0400 Received: by mail-ea0-f169.google.com with SMTP id k11so4066407eaj.14 for ; Thu, 19 Sep 2013 03:06:01 -0700 (PDT) Date: Thu, 19 Sep 2013 12:05:58 +0200 From: Stefan Hajnoczi Message-ID: <20130919100558.GD22814@stefanha-thinkpad.redhat.com> References: <20130918125035.GF13359@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] R: qemu-nbd segmentation fault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mario DE CHENNO Cc: qemu-devel@nongnu.org On Wed, Sep 18, 2013 at 03:35:12PM +0200, Mario DE CHENNO wrote: > This time crashed just issuing a mount command: > > Starting program: /vmstore/vmtools/qemu-nbd-from1.6.0 /vmstore/playground/archivioweb.img > [Thread debugging using libthread_db enabled] > [New Thread 0x7ffff55e3700 (LWP 7626)] > [New Thread 0x7ffff47dd700 (LWP 7645)] > [New Thread 0x7ffff3fdc700 (LWP 7646)] > [New Thread 0x7ffff37db700 (LWP 7647)] > > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x7ffff37db700 (LWP 7647)] > 0x00007ffff7717249 in ?? () from /usr/lib64/libglib-2.0.so.0 > (gdb) bt > #0 0x00007ffff7717249 in ?? () from /usr/lib64/libglib-2.0.so.0 > #1 0x00007ffff771759c in ?? () from /usr/lib64/libglib-2.0.so.0 > #2 0x00007ffff7718958 in g_slice_free1 () from /usr/lib64/libglib-2.0.so.0 > #3 0x0000555555591c2d in aio_worker (arg=0x555555c2f6c0) at block/raw-posix.c:776 > #4 0x00005555555da094 in worker_thread (opaque=0x555555c31a40) at thread-pool.c:109 > #5 0x00007ffff6c2ed6b in start_thread () from /lib64/libpthread.so.0 > #6 0x00007ffff6966abd in clone () from /lib64/libc.so.6 Please try this patch and let us know if it worked. Older glib versions required the application to call g_thread_init(). Failure to do so results in the single-threaded code path being used. In a multi-threaded application that means race conditions and I've seen crashes similar to the backtrace you've posted. diff --git a/qemu-nbd.c b/qemu-nbd.c index c26c98e..8ae3868 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -357,6 +357,15 @@ int main(int argc, char **argv) const char *fmt = NULL; Error *local_err = NULL; + if (!g_thread_supported()) { +#if !GLIB_CHECK_VERSION(2, 31, 0) + g_thread_init(NULL); +#else + fprintf(stderr, "glib threading failed to initialize.\n"); + exit(1); +#endif + } + /* The client thread uses SIGTERM to interrupt the server. A signal * handler ensures that "qemu-nbd -v -c" exits with a nice status code. */