Opened 16 years ago

Closed 16 years ago

#2737 closed bug (fixed)

ActivityMonitor: Deadlock on Window Close

Reported by: bonefish Owned by: axeld
Priority: normal Milestone: R1
Component: Applications/ActivityMonitor Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

hrev27518

ActivityMonitor sometimes deadlocks when closing with Command-W:

kdebug> threads 161
thread         id  state     wait for   object  cpu pri  stack      team  name
0x999d5800    161  waiting   sem          1952    -  10  0x91fd2000  161  ActivityMonitor
0x999d8000    162  waiting   sem          1887    -  10  0x92022000  161  team 161 debug task
0x99a32000    166  waiting   sem          1970    -  20  0x920a9000  161  _BMediaRoster_
0x99a33000    168  waiting   sem          1952    -  10  0x920b1000  161  source refresh
0x99a33800    169  waiting   sem          1989    -  15  0x920b5000  161  w>ActivityMonitor
kdebug> sc 161
stack trace for thread 161 "ActivityMonitor"
    kernel stack: 0x91fd2000 to 0x91fd6000
      user stack: 0x7efef000 to 0x7ffef000
frame            caller     <image>:function + offset
 0 91fd5e54 (+  48) 80046d35   <kernel>:context_switch__FP6threadT0 + 0x0039
 1 91fd5e84 (+  64) 80047041   <kernel>:scheduler_reschedule + 0x02d5
 2 91fd5ec4 (+  64) 80049bfc   <kernel>:switch_sem_etc + 0x0368
 3 91fd5f04 (+  64) 8004a7c2   <kernel>:_user_acquire_sem_etc + 0x0096
 4 91fd5f44 (+ 100) 800cfe41   <kernel>:pre_syscall_debug_done + 0x0002 (nearest)
user iframe at 0x91fd5fa8 (end = 0x91fd6000)
 eax 0xc            ebx 0x81351c        ecx 0x7ffee980   edx 0xffff0104
 esi 0xffffffff     edi 0x7fffffff      ebp 0x7ffee9bc   esp 0x91fd5fdc
 eip 0xffff0104  eflags 0x203      user esp 0x7ffee980
 vector: 0x63, error code: 0x0
 5 91fd5fa8 (+   0) ffff0104
 6 7ffee9bc (+  64) 002cfb1a   <libbe.so>:_LockComplete__7BLooperP7BLooperlllx + 0x003e
 7 7ffee9fc (+  80) 002cfa75   <libbe.so>:_Lock__7BLooperP7BLooperlx + 0x0191
 8 7ffeea4c (+  48) 002ced80   <libbe.so>:Lock__7BLooper + 0x002c
 9 7ffeea7c (+  48) 002c6e3f   <libbe.so>:_WindowQuitLoop__12BApplicationbT1 + 0x003b
10 7ffeeaac (+  48) 002c6f37   <libbe.so>:_QuitAllWindows__12BApplicationb + 0x0043
11 7ffeeadc (+  48) 002c42f9   <libbe.so>:QuitRequested__12BApplication + 0x0025
12 7ffeeb0c (+ 128) 002d029c   <libbe.so>:_QuitRequested__7BLooperP8BMessage + 0x0030
13 7ffeeb8c (+  48) 002ce86e   <libbe.so>:DispatchMessage__7BLooperP8BMessageP8BHandler + 0x0046
14 7ffeebbc (+ 496) 002c5a3d   <libbe.so>:DispatchMessage__12BApplicationP8BMessageP8BHandler + 0x0401
15 7ffeedac (+  64) 002d01f1   <libbe.so>:task_looper__7BLooper + 0x0211
16 7ffeedec (+  64) 002c41ad   <libbe.so>:Run__12BApplication + 0x0075
17 7ffeee2c (+ 336) 0020decb   <_APP_>:main + 0x002f
18 7ffeef7c (+  48) 0020da8b   <_APP_>:_start + 0x005b
19 7ffeefac (+  48) 001008ea   17843:runtime_loader_seg0ro@0x00100000 + 0x8ea
20 7ffeefdc (+   0) 7ffeefec   17842:ActivityMonitor_main_stack@0x7efef000 + 0xffffec
kdebug> sc 169
stack trace for thread 169 "w>ActivityMonitor"
    kernel stack: 0x920b5000 to 0x920b9000
      user stack: 0x700c3000 to 0x70103000
frame            caller     <image>:function + offset
 0 920b8d94 (+  48) 80046d35   <kernel>:context_switch__FP6threadT0 + 0x0039
 1 920b8dc4 (+  64) 80047041   <kernel>:scheduler_reschedule + 0x02d5
 2 920b8e04 (+  64) 80049bfc   <kernel>:switch_sem_etc + 0x0368
 3 920b8e44 (+  64) 80049866   <kernel>:acquire_sem_etc + 0x0026
 4 920b8e84 (+ 128) 80055b1e   <kernel>:wait_for_thread_etc + 0x01ba
 5 920b8f04 (+  64) 800571a3   <kernel>:_user_wait_for_thread + 0x0027
 6 920b8f44 (+ 100) 800cfe41   <kernel>:pre_syscall_debug_done + 0x0002 (nearest)
user iframe at 0x920b8fa8 (end = 0x920b9000)
 eax 0x35           ebx 0x81351c        ecx 0x70102a30   edx 0xffff0104
 esi 0x18025ea0     edi 0x18025ea0      ebp 0x70102a5c   esp 0x920b8fdc
 eip 0xffff0104  eflags 0x207      user esp 0x70102a30
 vector: 0x63, error code: 0x0
 7 920b8fa8 (+   0) ffff0104
 8 70102a5c (+  64) 0021059d   <_APP_>:DetachedFromWindow__12ActivityView + 0x0065
 9 70102a9c (+  48) 00371a2c   <libbe.so>:_Detach__5BView + 0x0030
10 70102acc (+  48) 00371a45   <libbe.so>:_Detach__5BView + 0x0049
11 70102afc (+  48) 00371a45   <libbe.so>:_Detach__5BView + 0x0049
12 70102b2c (+  80) 0036ec16   <libbe.so>:_RemoveSelf__5BView + 0x0042
13 70102b7c (+  48) 0036ebc9   <libbe.so>:RemoveSelf__5BView + 0x0055
14 70102bac (+  80) 003734ee   <libbe.so>:_._7BWindow + 0x00d6
15 70102bfc (+  48) 0021485c   <_APP_>:_._14ActivityWindow + 0x002c
16 70102c2c (+  48) 002cecea   <libbe.so>:Quit__7BLooper + 0x00de
17 70102c5c (+  48) 00373c26   <libbe.so>:Quit__7BWindow + 0x00c6
18 70102c8c (+ 128) 002d0373   <libbe.so>:_QuitRequested__7BLooperP8BMessage + 0x0107
19 70102d0c (+  48) 002ce86e   <libbe.so>:DispatchMessage__7BLooperP8BMessageP8BHandler + 0x0046
20 70102d3c (+ 480) 003764b9   <libbe.so>:DispatchMessage__7BWindowP8BMessageP8BHandler + 0x174d
21 70102f1c (+  96) 00379c84   <libbe.so>:task_looper__7BWindow + 0x0270
22 70102f7c (+  48) 002cfddf   <libbe.so>:_task0___7BLooperPv + 0x003f
23 70102fac (+  48) 00787718   <libroot.so>:_get_next_team_info + 0x005c (nearest)
24 70102fdc (+   0) 70102fec   17909:w>ActivityMonitor_169_stack@0x700c3000 + 0x3ffec
kdebug> sem 1989
SEM: 0x986c6404
id:      1989 (0x7c5)
name:    'thread_168_retcode_sem'
owner:   1
count:   -1
queue:   169
last acquired by: 0, count: 0
last released by: 0, count: 0
kdebug> sc 168
stack trace for thread 168 "source refresh"
    kernel stack: 0x920b1000 to 0x920b5000
      user stack: 0x70082000 to 0x700c2000
frame            caller     <image>:function + offset
 0 920b4e54 (+  48) 80046d35   <kernel>:context_switch__FP6threadT0 + 0x0039
 1 920b4e84 (+  64) 80047041   <kernel>:scheduler_reschedule + 0x02d5
 2 920b4ec4 (+  64) 80049bfc   <kernel>:switch_sem_etc + 0x0368
 3 920b4f04 (+  64) 8004a7c2   <kernel>:_user_acquire_sem_etc + 0x0096
 4 920b4f44 (+ 100) 800cfe41   <kernel>:pre_syscall_debug_done + 0x0002 (nearest)
user iframe at 0x920b4fa8 (end = 0x920b5000)
 eax 0xc            ebx 0x81351c        ecx 0x700c1be0   edx 0xffff0104
 esi 0xffffffff     edi 0x7fffffff      ebp 0x700c1c1c   esp 0x920b4fdc
 eip 0xffff0104  eflags 0x203      user esp 0x700c1be0
 vector: 0x63, error code: 0x0
 5 920b4fa8 (+   0) ffff0104
 6 700c1c1c (+  64) 002cfb1a   <libbe.so>:_LockComplete__7BLooperP7BLooperlllx + 0x003e
 7 700c1c5c (+  80) 002cfa75   <libbe.so>:_Lock__7BLooperP7BLooperlx + 0x0191
 8 700c1cac (+  48) 002ced80   <libbe.so>:Lock__7BLooper + 0x002c
 9 700c1cdc (+  48) 002ca3fc   <libbe.so>:LockLooper__8BHandler + 0x0028
10 700c1d0c (+ 624) 00212e55   <_APP_>:_Refresh__12ActivityView + 0x01c1
11 700c1f7c (+  48) 00212f13   <_APP_>:_RefreshThread__12ActivityViewPv + 0x001f
12 700c1fac (+  48) 00787718   <libroot.so>:_get_next_team_info + 0x005c (nearest)
13 700c1fdc (+   0) 700c1fec   17907:source refresh_168_stack@0x70082000 + 0x3ffec

The main thread tries to lock the window while holding the app looper lock. The window thread holds the window lock while waiting for the "source refresh" thread, which in turn tries to lock the application.

Change History (1)

comment:1 by axeld, 16 years ago

Resolution: fixed
Status: newclosed

I guess you got confused by the benaphore style locking a bit, but it's fixed in hrev27599 ;-P

The only lock in the game was the window lock; the application thread wasn't really needed at all, closing the window directly could reproduce this problem as well.

Note: See TracTickets for help on using tickets.