]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
esx: Disable libcurl's use of signals to fix a segfault
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 29 Sep 2012 20:16:30 +0000 (22:16 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 7 Oct 2012 09:18:06 +0000 (11:18 +0200)
libcurl uses a SIGALRM in combination with sigsetjmp/siglongjmp to be
able to abort a DNS lookup when it takes too long. The problem with this
in a multi-threaded application is that the signal handler for SIGALRM
and the call to siglongjmp can be executed on a thread that is different
from the one that initially did the SIGALRM setup and the call to
sigsetjmp. In the reported case this triggered a segfault.

Disable libcurl's use of signals to avoid this situation. This has the
disadvantage of losing the ability to abort synchronous DNS lookups which
might result in libcurl getting stuck in a DNS lookup in the worst case.
When libcurl was build with an asynchronous DNS backend such as c-ares
then there is no problem because the timeout mechanism works without
signals here anyway.

Reported by Benjamin Wang.

src/esx/esx_vi.c

index 275b858190742bbcaf3a5287a6f8d1609168ec01..125eaee438486cfc77d3d55fcfd71f3fc4b3a727 100644 (file)
@@ -330,6 +330,7 @@ esxVI_CURL_Connect(esxVI_CURL *curl, esxUtil_ParsedUri *parsedUri)
     }
 
     curl_easy_setopt(curl->handle, CURLOPT_USERAGENT, "libvirt-esx");
+    curl_easy_setopt(curl->handle, CURLOPT_NOSIGNAL, 1);
     curl_easy_setopt(curl->handle, CURLOPT_HEADER, 0);
     curl_easy_setopt(curl->handle, CURLOPT_FOLLOWLOCATION, 0);
     curl_easy_setopt(curl->handle, CURLOPT_SSL_VERIFYPEER,