[Bug 768775] New: Deadlock while waiting for an event in a multi-threaded X application
https://bugzilla.novell.com/show_bug.cgi?id=768775 https://bugzilla.novell.com/show_bug.cgi?id=768775#c0 Summary: Deadlock while waiting for an event in a multi-threaded X application Classification: openSUSE Product: openSUSE 12.1 Version: Final Platform: PC OS/Version: openSUSE 12.1 Status: NEW Severity: Normal Priority: P5 - None Component: X.Org AssignedTo: bnc-team-xorg-bugs@forge.provo.novell.com ReportedBy: myrosia@gmail.com QAContact: xorg-maintainer-bugs@forge.provo.novell.com Found By: --- Blocker: --- Created an attachment (id=496322) --> (http://bugzilla.novell.com/attachment.cgi?id=496322) A sample C program demonstrating the problem User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0 The attached program is a cut-down version of a graphics library used in the HTK toolkit. It consistently creates deadlocks in X calls on OpenSuse 12.1 (on two different laptops, 32- and 64-bit), while it works normally on RHEL 5/6 and FC13 on the same hardware. I asked a question about this on OpenSuse-xorg mailing list, and the outcome of the discussion was that this is a bug in XLib which is fixed in the upstream commit fd85aca7a616c595fc17b2520f84316a11e8906f. The test program does not get stuck on a machine with a newer X build The sequence of events is 1. XInitThreads is called 2. The library creates a thread ("XEventThread") and starts executing it. The thread executes a simple loop that repeatedly calls XNextEvent and passes the returned events elsewhere. 3. XEventThread calls XNextEvent 4. XNextEvent blocks waiting for events; it does not return immediately because there are no windows yet 5. XEventThread releases control to the main app thread 6. the main app thread calls XLockScreen 7 the main app thread starts creating windows 8. The first call to X functions, e.g. XCreateSimpleWindow, hangs This is with XSyncrhonize enabled; if it is disabled, a few X calls will succeed, but eventually something will hang forever. On the OSes that work (FC13, ScientificLinux 6) the difference is point 8 - the calls to X never lock. It works with a variety of window managers. Details are on this thread http://lists.opensuse.org/opensuse-xorg/2012-06/msg00019.html Reproducible: Always Steps to Reproduce: 1. Compile the attached test file with gcc -O2 -ansi -g -DXGRAFIX -I. -DUNIX -D_cplusplus -D_XOPEN_SOURCE=500 -D_REENTRANT -c -o HGraf.o HGraf.c gcc HGraf.o -lpthread -lm -lX11 -L/usr/X11R6/lib mv a.out HGrafTest 2. run ./HGrafTest Actual Results: The program either produces no windows, or a single window. The last line on display says "Calling XCreateSimpleWindow in makeHWin" Expected Results: The program puts up 3 different windows and says "Waiting forever", waiting for "Ctrl-C" to exit.
From Michal Srb msrb@suse.com:
The libX11 code contains following comment just above the pthread_cond_wait it is stuck on: /* If some thread is already waiting for events, * it will get the first one. That thread must * process that event before we can continue. */ /* FIXME: That event might be after this reply, * and might never even come--or there might be * multiple threads trying to get events. */ Fedora 13 uses older libX11 that doesn't contain this bug yet. In upstream, this was fixed by commit fd85aca7a616c595fc17b2520f84316a11e8906f. I can confirm your application doesn't get stuck on my machine with upstream Xorg build. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=768775
https://bugzilla.novell.com/show_bug.cgi?id=768775#c1
Stefan Dirsch
https://bugzilla.novell.com/show_bug.cgi?id=768775
https://bugzilla.novell.com/show_bug.cgi?id=768775#c3
Stefan Dirsch
participants (1)
-
bugzilla_noreply@novell.com