qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: spice-devel <spice-devel@freedesktop.org>,
	Marian Krcmarik <mkrcmari@redhat.com>,
	Alon Levy <alevy@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] monitor: Protect outbuf from concurrent access
Date: Fri, 2 Sep 2011 11:24:39 -0300	[thread overview]
Message-ID: <20110902112439.7cb55562@doriath> (raw)
In-Reply-To: <4E60DC77.5020300@redhat.com>

On Fri, 02 Sep 2011 15:39:03 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:

>    Hi,
> 
> >> After some investigation, I found out that the problem is that different
> >> SPICE threads are calling monitor functions (such as
> >> monitor_protocol_event()) in parallel which causes concurrent access
> >> to the monitor's internal buffer outbuf[].
> 
> [ adding spice-list to Cc, see qemu-devel for the rest of the thread ]
> 
> spice isn't supposed to do that.
> 
> /me just added a assert in channel_event() and saw it trigger in display 
> channel disconnects.
> 
> #0  0x0000003ceba32a45 in raise () from /lib64/libc.so.6
> #1  0x0000003ceba34225 in abort () from /lib64/libc.so.6
> #2  0x0000003ceba2b9d5 in __assert_fail () from /lib64/libc.so.6
> #3  0x0000000000503759 in channel_event (event=3, info=0x35e9340)
>      at /home/kraxel/projects/qemu/ui/spice-core.c:223
> #4  0x00007f9a77a9921b in reds_channel_event (s=0x35e92c0) at reds.c:400
> #5  reds_stream_free (s=0x35e92c0) at reds.c:4981
> #6  0x00007f9a77aac8b0 in red_disconnect_channel 
> (channel=0x7f9a24069a80) at red_worker.c:8489
> #7  0x00007f9a77ab53a8 in handle_dev_input (listener=0x7f9a3211ab20, 
> events=<value optimized out>)
>      at red_worker.c:10062
> #8  0x00007f9a77ab436d in red_worker_main (arg=<value optimized out>) at 
> red_worker.c:10304
> #9  0x0000003cec2077e1 in start_thread () from /lib64/libpthread.so.0
> #10 0x0000003cebae68ed in clone () from /lib64/libc.so.6
> 
> IMHO spice server should handle the display channel tear-down in the 
> dispatcher instead of the worker thread.  Alon?
> 
> >> Anyways, this commit fixes the problem at hand.
> 
> Not really.  channel_event() itself isn't thread-safe too, it does 
> unlocked list operations which can also blow up when called from 
> different threads.

I thought my patch was at least a candidate for stable, but after this
thread I'm convinced the problem should be fixed in spice instead.

> 
> A patch like the attached (warning: untested) should do as quick&dirty 
> fix for stable.  But IMO we really should fix spice instead.
> 
> cheers,
>    Gerd
> 

  parent reply	other threads:[~2011-09-02 14:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 19:35 [Qemu-devel] [PATCH] monitor: Protect outbuf from concurrent access Luiz Capitulino
2011-09-01 19:47 ` Daniel P. Berrange
2011-09-01 21:03 ` Jan Kiszka
2011-09-02  1:34 ` Anthony Liguori
2011-09-02  9:41   ` Daniel P. Berrange
2011-09-02 11:26     ` Jan Kiszka
2011-09-02 13:39   ` Gerd Hoffmann
2011-09-02 14:03     ` Anthony Liguori
2011-09-02 14:24     ` Luiz Capitulino [this message]
2011-09-02 14:28     ` Anthony Liguori
2011-09-02 15:18       ` Gerd Hoffmann
2011-09-02 15:20         ` Anthony Liguori
2011-09-02 15:31         ` Paolo Bonzini
2011-09-02 15:37           ` Anthony Liguori
2011-09-05  7:48           ` Gerd Hoffmann

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=20110902112439.7cb55562@doriath \
    --to=lcapitulino@redhat.com \
    --cc=alevy@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mkrcmari@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=spice-devel@freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).