WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] A bug in Xenbus driver

To: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] A bug in Xenbus driver
From: "Jun Zhu (Intern)" <Jun.Zhu@xxxxxxxxxx>
Date: Fri, 27 Aug 2010 12:03:03 +0100
Accept-language: en-US
Acceptlanguage: en-US
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 27 Aug 2010 04:04:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4C7697B3.8090502@xxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB47@xxxxxxxxxxxxxxxxxxxxxxxxx>, <4C756CCE.3060200@xxxxxxxx> <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB49@xxxxxxxxxxxxxxxxxxxxxxxxx>, <4C7697B3.8090502@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: ActFPKCrUTABXcpHQcKhviFNtivHYwAmsqrl
Thread-topic: [Xen-devel] A bug in Xenbus driver
Hi

Besides xenbus driver bug, the other problem is that there will be a deadlock 
if the read_thread exits! 

Now I have recognized where the deadlock comes if the child thread (read_thread 
in xs.c) exists. After the child thread dies, the main thread (read_reply in 
xs.c) will go on. So in the following invocation of read_reply (no reading 
thread exists now),  read_reply will use read_message(h) == -1 to read the 
reply. If the reply is XS_WATCH_EVENT type, the read_message function returns 
zero but leaves the reply_list empty, so read_reply goes to 
condvar_wait(&h->reply_condvar, &h->reply_mutex, h) since the reply_list is 
empty. The problem incurs here.  Since condvar_wait is a different definition 
when using PTHREAD to read reply message, it will just wait on this signal, do 
nothing.

This is one possibility of deadlocks. You can replay this bug by commenting 
read_message function in the read_thread, just letting the read_thread die 
directly. In this case, the reading thread does nothing.
I am not sure I have a good solution to fix this problem now.  Maybe we can let 
the read_message function returns a different value when the reply is 
XS_WATCH_EVENT, and the read_reply function checks. If it is  XS_WATCH_EVENT 
type, call the read_message again.

Jun Zhu
Citrix Systems UK
________________________________________
From: Jeremy Fitzhardinge [jeremy@xxxxxxxx]
Sent: Thursday, August 26, 2010 12:34 PM
To: Jun Zhu (Intern)
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] A bug in Xenbus driver

 On 08/26/2010 01:25 AM, Jun Zhu (Intern) wrote:
> Sorry for my description. "Does not report correctly" is not the problem of 
> xenbus read.
> I mean that in the xenstore/xs.c code, when using another thread (#ifdef 
> USE_PTHREAD) to receive responses from xenbus, if this thread exits 
> incorrectly, the listener should be noticed, or the listener will wait for 
> response for ever.

How does that relate to your proposed fix?

    J

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>