[libvirt] [PATCH] cygwin: fix abort of virsh on my system

This strange patch fixes aborts of virsh on my system. It seems that the string returned by xmlSaveUri is owned by the xml library?? Signed-off-by: Stefan Berger <stefanb@us.ibm.com> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 317125f..a916b86 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -542,6 +542,9 @@ doRemoteOpen (virConnectPtr conn, } name = (char *) xmlSaveUri (&tmpuri); +#ifdef __CYGWIN__ + name = strdup(name); +#endif #ifdef HAVE_XMLURI_QUERY_RAW VIR_FREE(tmpuri.query_raw);

On 05/06/2010 02:11 PM, Stefan Berger wrote:
This strange patch fixes aborts of virsh on my system. It seems that the string returned by xmlSaveUri is owned by the xml library??
Hm, I don't think so, at least not according to the documentation: Function: xmlSaveUri xmlChar * xmlSaveUri (xmlURIPtr uri) Save the URI as an escaped string uri: pointer to an xmlURI Returns: a new string (to be deallocated by caller) The code in libxml2 also seems to confirm this, although it's not entirely straightforward: xmlChar * xmlSaveUri(xmlURIPtr uri) { xmlChar *ret = NULL; xmlChar *temp; const char *p; int len; int max; if (uri == NULL) return(NULL); max = 80; ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar)); ... ret[len] = 0; return(ret); } So something else might be going on. What version of libxml2 are you currently building against? -- Chris Lalancette

On 05/06/2010 02:11 PM, Stefan Berger wrote:
This strange patch fixes aborts of virsh on my system. It seems that
Chris Lalancette <clalance@redhat.com> wrote on 05/06/2010 02:28:18 PM: the
string returned by xmlSaveUri is owned by the xml library??
[...]
So something else might be going on. What version of libxml2 are you currently building against?
Cygwin picks up what I have installed in /cydrive/c/GTK/ and there I have version 2.6.32. xmlversion.h:#define LIBXML_DOTTED_VERSION "2.6.32" The abort occurs upon the VIR_FREE(name). Regards, Stefan
-- Chris Lalancette

On Thu, May 06, 2010 at 02:55:31PM -0400, Stefan Berger wrote:
Chris Lalancette <clalance@redhat.com> wrote on 05/06/2010 02:28:18 PM:
This strange patch fixes aborts of virsh on my system. It seems that
On 05/06/2010 02:11 PM, Stefan Berger wrote: the
string returned by xmlSaveUri is owned by the xml library??
[...]
it should not, libxml2 will use malloc (assuming xmlMalloc is not changed to point to something else).
So something else might be going on. What version of libxml2 are you currently building against?
Cygwin picks up what I have installed in /cydrive/c/GTK/ and there I have version 2.6.32.
xmlversion.h:#define LIBXML_DOTTED_VERSION "2.6.32"
The abort occurs upon the VIR_FREE(name).
The *big* problem is that if the library was compiled with a different toolchain, or sometimes even slightly different options you may end up with the malloc used by libxml2 and initialized by a reference at comoilation time, to be different and incompatible with the malloc/free used by libvirt. This blows up very frequently when people compile with the microsoft tool chain, and less frequently on cygwin but this can happen. As 0.6.2 is rather ancient to say the least, maybe rebuilding libxml2 with your current cygwin and making sure libvirt uses that one could fix the problem. I would say that 90% of the Windows specific problems reported for libxml2 are due to incompatibilities between runtime especially at the memory allocation problem, it's a serious pain ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Chris Lalancette
-
Daniel Veillard
-
Stefan Berger