Opened 17 years ago

Closed 17 years ago

#2388 closed bug (fixed)

deadlock between kernel heap and kernel vm

Reported by: korli Owned by: mmlr
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The heap grower thread is trying to acquire the kernel aspace lock. The net_server thread is trying to use memalign() which waits for the heap grower, while holding the kernel aspace lock.

Here is the dump of the debug session:

kdebug> bt 8
stack trace for thread 8 "heap grower"
    kernel stack: 0x80147000 to 0x8014b000
frame            caller     <image>:function + offset
8014ad88 (+  32) 80037d1e   <kernel>:context_switch__FP6threadT0 + 0x0026
8014ada8 (+  64) 80037f88   <kernel>:scheduler_reschedule + 0x0248
8014ade8 (+  64) 80039270   <kernel>:switch_sem_etc + 0x0368
8014ae28 (+  64) 80038eda   <kernel>:acquire_sem_etc + 0x0026
8014ae68 (+  64) 8009154e   <kernel>:SetTo__23AddressSpaceWriteLockerl + 0x0036
8014aea8 (+ 144) 80092d81   <kernel>:vm_create_anonymous_area + 0x00c1
8014af38 (+  96) 80098a7f   <kernel>:create_area + 0x0047
8014af98 (+  64) 8002f964   <kernel>:heap_grow_thread__FPv + 0x0060
8014afd8 (+  32) 80042993   <kernel>:_create_kernel_thread_kentry__Fv + 0x001b
8014aff8 (+2146127880) 80042928   <kernel>:thread_kthread_exit__Fv + 0x0000
kdebug>
kdebug> bt 76
stack trace for thread 76 "net_server"
    kernel stack: 0x80250000 to 0x80254000
      user stack: 0x7efe7000 to 0x7ffe7000
frame            caller     <image>:function + offset
802537d4 (+  32) 80037d1e   <kernel>:context_switch__FP6threadT0 + 0x0026
802537f4 (+  64) 80037f88   <kernel>:scheduler_reschedule + 0x0248
80253834 (+  64) 80039270   <kernel>:switch_sem_etc + 0x0368
80253874 (+  48) 80038f02   <kernel>:switch_sem + 0x001e
802538a4 (+  48) 8002fc56   <kernel>:memalign + 0x00d6
802538d4 (+  32) 8002fcac   <kernel>:malloc + 0x0014
802538f4 (+  48) 80091f4f   <kernel>:create_area_struct__FP16vm_address_spacePCcUlUl + 0x002f
80253924 (+  64) 8009288d   <kernel>:map_backing_store__FP16vm_address_spaceP8vm_cachePPvxUlUliiiPP7vm_areaPCcbT11_ + 0x0021
80253964 (+ 176) 80092edf   <kernel>:vm_create_anonymous_area + 0x021f
80253a14 (+  96) 80098a7f   <kernel>:create_area + 0x0047
80253a74 (+  80) 80678365   <usb>:__23PhysicalMemoryAllocatorPCcUlUlUl + 0x0161
80253ac4 (+  80) 80674496   <usb>:__5Stack + 0x00b2
80253b14 (+  48) 80673640   <usb>:bus_std_ops__Fle + 0x00a8
80253b44 (+  64) 8003405b   <kernel>:get_module + 0x013f
80253b84 (+  48) 802c48da   </boot/beos/system/add-ons/kernel/drivers/dev/net/pegasus>:init_driver + 0x002a
80253bb4 (+  48) 8005a229   <kernel>:load_driver__FP13legacy_driver + 0x0139
80253be4 (+ 128) 8005a6e1   <kernel>:add_driver__FPCcl + 0x022d
80253c64 (+  32) 8005c2b0   <kernel>:legacy_driver_add + 0x0014
80253c84 (+  48) 8005b994   <kernel>:try_drivers__FRt16DoublyLinkedList2Z12driver_entryZt31DoublyLinkedListStandardGetLink1Z12driver_entry + 0x00a4
80253cb4 (+ 192) 8005bde3   <kernel>:probe_for_drivers__FPCc + 0x03ff
80253d74 (+ 144) 8005c75e   <kernel>:legacy_driver_probe + 0x0172
80253e04 (+  96) 800565fd   <kernel>:scan_for_drivers__FP11devfs_vnode + 0x0085
80253e64 (+  64) 80058135   <kernel>:devfs_open_dir__FP9fs_volumeP8fs_vnodePPv + 0x0081
80253ea4 (+  48) 8007c3d2   <kernel>:open_dir_vnode__FP5vnodeb + 0x0022
80253ed4 (+  48) 8007ccbd   <kernel>:dir_open__FiPcb + 0x0051
80253f04 (+  64) 80081a6b   <kernel>:_user_open_dir + 0x0093
80253f44 (+ 100) 800a47e2   <kernel>:pre_syscall_debug_done + 0x0002 (nearest)
iframe at 0x80253fa8 (end = 0x80254000)
 eax 0x5a           ebx 0x444a28        ecx 0x7ffe6720   edx 0xffff0104
 esi 0x214107       edi 0x7ffe6948      ebp 0x7ffe674c   esp 0x80253fdc
 eip 0xffff0104  eflags 0x203
 vector: 0x63, error code: 0x0
80253fa8 (+   0) ffff0104
7ffe674c (+  48) 00382c19   <libbe.so>:__10BDirectoryPCc + 0x0055
7ffe677c (+ 544) 0020b988   <_APP_>:_ConfigureDevices__9NetServeriPCcP8BMessage + 0x0028
7ffe699c (+ 272) 0020c02d   <_APP_>:_BringUpInterfaces__9NetServer + 0x0211
7ffe6aac (+  80) 00209a7a   <_APP_>:ReadyToRun__9NetServer + 0x005e
7ffe6afc (+ 496) 002bd309   <libbe.so>:DispatchMessage__12BApplicationP8BMessageP8BHandler + 0x02f9
7ffe6cec (+  64) 002c791d   <libbe.so>:task_looper__7BLooper + 0x0211
7ffe6d2c (+  64) 002bbb81   <libbe.so>:Run__12BApplication + 0x0075
7ffe6d6c (+ 528) 0020c2df   <_APP_>:main + 0x0083
7ffe6f7c (+  48) 00209267   <_APP_>:_start + 0x005b
7ffe6fac (+  48) 0010084a   3991:runtime_loader_seg0ro@0x00100000 + 0x84a
7ffe6fdc (+   0) 7ffe6fec   3990:net_server_main_stack@0x7efe7000 + 0xffffec
kdebug>
kdebug> sem 5
SEM: 0x9209b104
id:      5 (0x5)
name:    'heap_grown_notify'
owner:   0
count:   -1
queue:   76
last acquired by: 0, count: 0
last released by: 0, count: 0
kdebug>
kdebug> sem 1
SEM: 0x9209b034
id:      1 (0x1)
name:    'kernel_aspacelock'
owner:   0
count:   -1025
queue:   8 77
last acquired by: 76, count: 1024
last released by: 77, count: 1
kdebug>
kdebug>
kdebug> threads
thread         id  state     wait for  object  cpu pri  stack      team  name
0x800e64e0      1  running          -            0   0  0x80201000    1  idle thread 1
0x90b4d000      2  waiting   cvar  0x800e64c8    -  15  0x800ff000    1  undertaker
0x90b4d800      3  zzz                           -   5  0x80133000    1  kernel daemon
0x90b4e000      4  zzz                           -   1  0x80137000    1  page scrubber
0x90b4e800      5  waiting   sem           18    -  11  0x8013b000    1  page writer
0x919ed800     68  waiting   sem          671    -  10  0x80150000   68  _roster_thread_
0x90b4f000      6  waiting   sem           22    -  10  0x8013f000    1  page daemon
0x90b4f800      7  waiting   sem           26    -   5  0x80143000    1  low memory handler
0x919fb000     70  zzz                           -  10  0x801fa000   68  message deliverer
0x90b50000      8  waiting   sem            1    - 110  0x80147000    1  heap grower
0x919fb800     71  waiting   sem          678    -  10  0x8023c000   68  timer_thread
0x90b61000      9  waiting   mutex 0x90b2a38c    -   5  0x8014c000    1  block notifier/writer
0x90b6f000     72  waiting   sem          682    -  10  0x80240000   68  authentication manager
0x90b6f800     73  waiting   sem          695    -  10  0x80244000   68  main_mime
0x90b66000     11  waiting   sem           41    -  10  0x80154000    1  acpi_task
0x91a07000     74  waiting   sem          706    -  15  0x80248000   68  messaging command processor
0x90b61800     75  waiting   sem          784    -  10  0x801f6000   75  debug_server
0x91a0d800     76  waiting   sem            5    -  10  0x80250000   76  net_server
0x91a14000     77  waiting   sem            1    -  10  0x80254000   77  app_server
0x91a1f000     78  zzz                           -  10  0x80258000   78  waitfor
0x90b6b000     48  zzz                           -  10  0x8015a000    1  media checker
0x91a32000     80  waiting   sem          817    -  10  0x80260000   75  kernel listener
0x91a29800     82  waiting   sem          834    -  10  0x8025c000   76  PathMonitor looper
0x91a32800     83  waiting   sem          841    -  10  0x80264000   76  PathMonitor looper
0x91a41800     84  waiting   sem          870    -  10  0x8027e000    1  net timer
0x91a69800     85  waiting   sem          915    -  15  0x802ba000    1  loop consumer
0x90b6b800     54  waiting   sem          225    -  10  0x80162000    1  locked_pool_enlarger
0x90b66800     55  waiting   sem          233    -  20  0x80166000    1  scsi_bus_service
0x90ba8000     56  waiting   sem          267    -  20  0x8016f000    1  scsi_bus_service
0x90ba8800     58  waiting   sem          476    -   5  0x801ec000    1  syslog sender
0x919ec000     59  waiting   cvar  0x90c6ded8    -  10  0x801f0000   59  sh
kdebug>

Change History (2)

comment:1 by mmlr, 17 years ago

Owner: changed from axeld to mmlr
Status: newassigned

Working on it, resolving a few other shortcomings too.

comment:2 by mmlr, 17 years ago

Resolution: fixed
Status: assignedclosed

Should be fixed in hrev26009 along with some other issues.

Note: See TracTickets for help on using tickets.