This is the mail archive of the
cygwin-xfree
mailing list for the Cygwin XFree86 project.
Re: Semaphore handle leaks in WindowMaker with latest Xorg distribution
Yaakov (Cygwin/X) wrote:
Jon TURNEY wrote:
So I guess suspicion first falls that this leak is somewhere in one of
the updated X DLLs...
The question is then, how can we track this down?
This actually turned out to be easier to track down than I thought. Using
process explorer on 'wmaker --for-real --no-polling --static' shows that the
only thing of interest it's doing is calling XSync().
A simple test-case (attached) which just calls XSync() shows exactly the same
behaviour, leaking 3 semaphores per call.
The call stack looks like
pthread_cond_init
xcondition_init at Xthreads.h
insert_pending_request at xcb_io.c:343
_XReply at xcb_io.c:368
XSync at Sync.c:48
main at test_xsync.c:19
After some staring at the code, I think the attached patch is perhaps the
correct place to add a matching xcondition_clear.
Entered into bugzilla
http://sourceware.org/bugzilla/show_bug.cgi?id=9795
#include <X11/X.h>
#include <X11/Xlib.h>
#include <time.h>
#include <assert.h>
//
// gcc -g test_xsync.c -lX11 -o test_xsync
//
int main()
{
// Open the display
Display *dpy = XOpenDisplay(NULL);
assert(dpy);
// loop for ever
while (1)
{
sleep(0);
XSync(dpy, 0);
}
}
diff --git a/src/xcb_io.c b/src/xcb_io.c
index 913e04e..f58316a 100644
--- a/src/xcb_io.c
+++ b/src/xcb_io.c
@@ -167,6 +167,7 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi
dpy->xcb->pending_requests = req->next;
if(!dpy->xcb->pending_requests)
dpy->xcb->pending_requests_tail = &dpy->xcb->pending_requests;
+ xcondition_clear(&(req->condition));
free(req);
reply = error;
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ: http://x.cygwin.com/docs/faq/