libXt: nextevent.c _waitForSomething, bug?

A.Avila aavilagallego+xrg at
Wed Aug 6 03:58:10 PDT 2008

Recently I'm working in a pseudo real-time application. This involves
various threads with RT priority and most of the signals masked. The
problem is that: sometimes, when trying to shutdown the computer, the
application hang up. Debugging the problem with oprofile, I've managed
to get to an infinite loop in the libXt library, right in the function

In this function there is an infinite loop that manages events, inside
of it there is only one break that when executing goes directly to a
goto that jumps directly into the infinite loop again (this is what is
happening in our thread). Due to a priority issue (and a RT
planification and probably a SIGTERM masked), the thread that is
taking care of this loop is "kidnapping" the CPU (99%) and doesn't let
any other process to continue executing (and subsequently, turning
down or rebooting). This could be easily fixed decreasing the
priority, changing the planification of the thread, killing the app
directly with a SIGKILL, managing the SIGTERM and probably a bunch
more of options...

I have checked that putting an usleep(0) (telling the planner to do a
replanification) right before the break, the application does not hang
any more, and it solves the problem.

My doubt is that I'm not really sure that this is the best solution.
Is there any problem with putting this usleep? is this a bug? does
anybody know what is really happening? Why does the break end up in a
goto that jumps again to the infinite loop? should this be changed
with a continue or should the loop end?

I'll appreciate any comments.

Best regards,

Antonio Ávila
View this message in context:
Sent from the Free Desktop - xorg mailing list archive at

More information about the xorg mailing list