Re: [AD] keyboard hang, linux, 4.1.8

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2003-01-15, Eric <ebotcazou@xxxxxxxxxx> wrote:
> > symptoms: when pressing a key, the program will randomly hang (sometimes
> > yes, sometimes no. about 1 in 3 hang). cpu usage remains consistent,
> > 4.2% for the grabber and > 80% for my othello program. Some further
> > testing shows that it mostly happens when you press a key and move the
> > mouse at the same time.
> 
> Try to #undef ALLEGRO_MULTITHREADED in include/allegro/platform/alucfg.h .

Confirmed, the bug disappears if the timer mutexes are disabled.

Below is the gdb session of exgui after it hangs.  Thread 3 is the
bg_man thread, which has locked the X display in order to process X
events, and now is waiting to lock the timer mutex.  Thread 4 is the
timer thread, which has previously locked the timer mutex and now is
looking to lock the X display to redraw the mouse cursor.

One possible fix is attached.  It merges the bg_man and ptimer threads,
which might be a bit drastic but is probably a good thing anyway
(because it gets us closer to interrupt behaviour, as less things can
happen while timer callbacks are running).  It needs more testing.



(gdb) thread 3
[Switching to thread 3 (Thread 1026 (LWP 7681))]#0  0x40174aea in __sigsuspend (set=0xbf7ff7e4)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:54
54      ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or directory.
        in ../sysdeps/unix/sysv/linux/sigsuspend.c
(gdb) bt
#0  0x40174aea in __sigsuspend (set=0xbf7ff7e4) at ../sysdeps/unix/sysv/linux/sigsuspend.c:54
#1  0x400507cb in __pthread_wait_for_restart_signal (self=0xbf7ffc00) at pthread.c:942
#2  0x40052836 in __pthread_alt_lock (lock=0x8102c30, self=0x0) at restart.h:36
#3  0x4004ef52 in __pthread_mutex_lock (mutex=0x8102c20) at mutex.c:120
#4  0x080b1798 in _unix_lock_mutex (handle=0x8102c18) at ./src/unix/uthreads.c:276
#5  0x080847a4 in remove_timer_int (proc=0x807e264, param=0x0, param_used=0) at ./src/timer.c:432
#6  0x0808484e in remove_int (proc=0x807e264 <repeat_timer>) at ./src/timer.c:454
#7  0x0807e44e in _handle_key_release (scancode=4) at ./src/keyboard.c:420
#8  0x080b3ef8 in _handle_pckey (code=160) at ./src/misc/pckeys.c:413
#9  0x080b1a38 in _xwin_keydrv_handler (pressed=0, code=32) at ./src/x/xkeybd.c:116
#10 0x0809f8e0 in _xwin_private_process_event (event=0x80ec1c0) at ./src/x/xwin.c:2004
#11 0x0809ff8e in _xwin_private_handle_input () at ./src/x/xwin.c:2212
#12 0x080a0005 in _xwin_handle_input () at ./src/x/xwin.c:2224
#13 0x0809956f in _xwin_bg_handler (threaded=1) at ./src/x/xsystem.c:154
#14 0x080b1312 in bg_man_pthreads_threadfunc (arg=0x0) at ./src/unix/uthreads.c:79
#15 0x4004e065 in pthread_start_thread (arg=0xbf7ffc00) at manager.c:274
#16 0x4004e0ad in pthread_start_thread_event () at manager.c:298

(gdb) thread 4
[Switching to thread 4 (Thread 2051 (LWP 7682))]#0  0x40174aea in __sigsuspend (set=0xbf5ff784)
    at ../sysdeps/unix/sysv/linux/sigsuspend.c:54
54      in ../sysdeps/unix/sysv/linux/sigsuspend.c
(gdb) bt
#0  0x40174aea in __sigsuspend (set=0xbf5ff784) at ../sysdeps/unix/sysv/linux/sigsuspend.c:54
#1  0x400507cb in __pthread_wait_for_restart_signal (self=0xbf5ffc00) at pthread.c:942
#2  0x4004d162 in pthread_cond_wait (cond=0x8101b00, mutex=0x8101b10) at restart.h:36
#3  0x400b5f49 in _XUnregisterFilter () from /usr/X11R6/lib/libX11.so.6
#4  0x400b60e7 in _XUnregisterFilter () from /usr/X11R6/lib/libX11.so.6
#5  0x400b615b in _XUnregisterFilter () from /usr/X11R6/lib/libX11.so.6
#6  0x400b662a in XLockDisplay () from /usr/X11R6/lib/libX11.so.6
#7  0x080a05c1 in _xwin_update_screen (x=0, y=0, w=18, h=23) at ./src/x/xwin.c:2381
#8  0x080b21bd in _xwin_update_video_bitmap (dst=0x8111d40, x=0, y=0, w=18, h=23) at ./src/x/xvtable.c:101
#9  0x080b272b in _xwin_blit_anywhere (src=0x8110b90, dst=0x8111d40, sx=232, sy=209, dx=0, dy=0, w=18, h=23)
    at ./src/x/xvtable.c:269
#10 0x080a872b in blit (src=0x8110b90, dest=0x8111d40, s_x=232, s_y=209, d_x=0, d_y=0, w=18, h=23)
    at ./src/blit.c:819
#11 0x080812e2 in draw_mouse_doublebuffer (newx=6, newy=5) at ./src/mouse.c:147
#12 0x080815c1 in draw_mouse (remove=-1, add=-1) at ./src/mouse.c:211
#13 0x0808197e in mouse_move () at ./src/mouse.c:336
#14 0x08084002 in _handle_timer_tick (interval=145) at ./src/timer.c:102
#15 0x080b10e2 in ptimer_thread_func (unused=0x0) at ./src/unix/uptimer.c:137
#16 0x4004e065 in pthread_start_thread (arg=0xbf5ffc00) at manager.c:274
#17 0x4004e0ad in pthread_start_thread_event () at manager.c:298


-- 
王浩禎

Attachment: merge-bgman-ptimer.diff.gz
Description: application/gunzip



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/