Looping in poll() in every application using GPollFDs.
Submitted by Robert Nagy
Link to original bug (#661201)
Description
Hi
We have been suffering from a problem on OpenBSD where glib causes several applications to hang if they are using GPollFDs. One of these applications is clutter.
(gdb) bt
#0 0x00000002041a282a in poll () from /usr/lib/libc.so.60.1
#1 0x000000020582028b in poll (fds=0x205cd42b0, nfds=2, timeout=0) at /usr/src/lib/libpthread/uthread/uthread_poll.c:80
#2 0x0000000210e9b9ce in g_main_context_check () from /home/pobj/clutter-1.8.0/clutter-1.8.0/tests/micro-bench/.libs/libglib-2.0.so.2992.0
#3 0x0000000210e9c03a in g_main_loop_run () from /home/pobj/clutter-1.8.0/clutter-1.8.0/tests/micro-bench/.libs/libglib-2.0.so.2992.0
#4 0x00000002109caf34 in clutter_main () at ./clutter-main.c:675
#5 0x0000000000401a79 in main (argc=1, argv=0x7f7ffffcb3d0) at test-text.c:116
By attaching to the process and doing a backtrace after SIGINT shows the above output.
Tracing the process reveals that the process is looping in poll():
31557 test-text CALL poll(0x20dc3c9d0,0x2,0) 31557 test-text RET poll 0 31557 test-text CALL read(0x5,0x20286202c,0x1000) 31557 test-text RET read -1 errno 35 Resource temporarily unavailable 31557 test-text CALL poll(0x20dc3c9d0,0x2,0) 31557 test-text RET poll 0 31557 test-text CALL read(0x5,0x20286202c,0x1000) 31557 test-text RET read -1 errno 35 Resource temporarily unavailable
read() returns EAGAIN all the time and the application's UI is totally frozen.
Running the process with G_MAIN_POLL_DEBUG shows the following:
created context=0x20ffbc400 default context=0x20ffbc400 polling context=0x20ffbc400 n=2 timeout=0 g_main_poll(2) timeout: 0 - elapsed 0.0000710000 seconds [5 :i] polling context=0x20ffbc400 n=2 timeout=0 g_main_poll(2) timeout: 0 - elapsed 0.0000030000 seconds polling context=0x20ffbc400 n=2 timeout=0 g_main_poll(2) timeout: 0 - elapsed 0.0000030000 seconds polling context=0x20ffbc400 n=2 timeout=0 g_main_poll(2) timeout: 0 - elapsed 0.0000040000 seconds
And so on ... until the process gets killed.