2013-02-20 51 views
2

我試圖分析我的應用程序中發生掛起後從我的一個最終用戶收到的內存轉儲。這似乎與我的應用程序的音頻播放部分有關。我相信涉及到兩個線程,即即將開始播放聲音的主線程和一個更新線程,該線程遍歷鏈表中的聲音以不斷更新其狀態。但是,我不明白吊墜的來源可能是什麼。內存轉儲分析(應用程序掛起)

我的WinDbg知識是有限的,但我設法弄清楚,掛起似乎發生在音頻庫的SetLoop方法內(特別是在靜態聲音代碼中)。我使用DirectSound,並且在這種情況下應用程序在Windows 7 32位上運行(我正在開發自己的XP,我從來沒有像這樣的問題)。靜態聲音類在檢查聲音是否正在播放之前鎖定關鍵部分,如果不是,則會將循環標誌設置爲true或false。在這種情況下,主線程調用SetLoop將其設置爲false,因爲它想要以非循環狀態播放聲音。我可以看到,在掛起時,主線程停留在ntdll.dll中的EtwEventEnabled調用中,這顯然是由靜態聲音類的SetLoop方法產生的。我想知道它是否卡在EnterCriticalSection調用中,或者是在調用DirectSound的GetStatus方法獲取輔助緩衝區時進一步下降?這裏是我對內存轉儲分析的知識不足的地方,如果有人花時間查看轉儲,我將非常感激。

下面是轉儲的鏈接,與應用程序的特定符號:任何幫助提前 https://dl.dropbox.com/u/5121962/hangdump.zip

非常感謝。

+0

Dropbox文件是25MB。 – 2013-02-20 17:20:16

+0

這是因爲它包含一個小型轉儲加符號。用合理的連接下載應該不會超過幾分鐘。 – 2013-02-20 17:29:16

+0

這就是我發佈內存轉儲的原因,因爲我不知道可能失敗的代碼的哪個部分。如果我知道這一點,我可以繼續,但在這一點上,我無法弄清楚如何繼續。 – 2013-02-20 17:37:44

回答

1

兩個線程(一個是WinMain)正在等待同關鍵部分03cb6ffc沒有所有者。 看看StaticSound::UpdateStaticSound::SetLoop。也許當前正在終止的線程仍然擁有一個關鍵部分。嘗試使用帶鎖定停止細節的Application Verifier - 驗證關鍵部分的正確用法。

0:000> !analyze -hang -v 
[...] 
BUGCHECK_STR: HANG 
[...] 

DERIVED_WAIT_CHAIN: 

Dl Eid Cid  WaitType 
-- --- ------- -------------------------- 
    0 768.d1c Critical Section  (Self) 

WAIT_CHAIN_COMMAND: ~0s;k;; 

BLOCKING_THREAD: 00000d1c 

DEFAULT_BUCKET_ID: APPLICATION_HANG_SELF_Unowned_CriticalSection 

PRIMARY_PROBLEM_CLASS: APPLICATION_HANG_SELF_Unowned_CriticalSection 

LAST_CONTROL_TRANSFER: from 77d56a24 to 77d57094 
[...] 
0:000> !locks 
CritSec +13af7d0 at 013af7d0 
WaiterWoken  No 
LockCount   0 
RecursionCount  1 
OwningThread  10a8 
EntryCount   0 
ContentionCount 2b7 
*** Locked 

CritSec +3cb6ffc at 03cb6ffc 
WaiterWoken  No 
LockCount   2 
RecursionCount  0 
OwningThread  0 
EntryCount   0 
ContentionCount d 
*** Locked 

0:000> ~* 
. 0 Id: 768.d1c Suspend: 0 Teb: 7ffde000 Unfrozen 
     Start: pontefract_timer!WinMainCRTStartup (01299030) 
     Priority: 0 Priority class: 32 Affinity: f 
    [...] 
    4 Id: 768.10a8 Suspend: 0 Teb: 7ffdb000 Unfrozen 
     Start: pontefract_timer!_threadstartex (012ae09f) 
     Priority: 2 Priority class: 32 Affinity: f 
    [...] 
0:004> kb 
ChildEBP RetAddr Args to Child    
021af9b4 77d56a24 77d42278 000002f0 00000000 ntdll!KiFastSystemCallRet 
021af9b8 77d42278 000002f0 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc 
021afa1c 77d4215c 00000000 00000000 00000000 ntdll!RtlpWaitOnCriticalSection+0x13e 
021afa44 012882c2 03cb6ffc 013af7cc 00326ee8 ntdll!RtlEnterCriticalSection+0x150 
021afa60 0128a1ed 021afa8c 021afa80 013af810 pontefract_timer!StaticSound::Update+0x12 
021afa84 012ae079 013af700 73a14e26 00000000 pontefract_timer!UpdaterTick+0x7d 
021afabc 012ae103 00000000 021afad4 7750ed6c pontefract_timer!_callthreadstartex+0x1b 
021afac8 7750ed6c 013af810 021afb14 77d7377b pontefract_timer!_threadstartex+0x64 
021afad4 77d7377b 013af810 6b63b5bd 00000000 kernel32!BaseThreadInitThunk+0xe 
021afb14 77d7374e 012ae09f 013af810 00000000 ntdll!__RtlUserThreadStart+0x70 
021afb2c 00000000 012ae09f 013af810 00000000 ntdll!_RtlUserThreadStart+0x1b 
0:000> kb 
ChildEBP RetAddr Args to Child    
0020c39c 77d56a24 77d42278 000002f0 00000000 ntdll!KiFastSystemCallRet 
0020c3a0 77d42278 000002f0 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc 
0020c404 77d4215c 00000000 00000000 774f8e38 ntdll!RtlpWaitOnCriticalSection+0x13e 
0020c42c 012881af 03cb6ffc 00000000 03cb6ff8 ntdll!RtlEnterCriticalSection+0x150 
0020c440 0128682c 00000000 00000000 00000000 pontefract_timer!StaticSound::SetLoop+0xf 
0020c460 012616ac 00000000 00000000 01765bac pontefract_timer!DeviceManager::SetLoop+0x6c 
0020c474 0121a2ce 01a46ddc 00000000 0178ea9c pontefract_timer!BgtSound::play+0x6c 
0020c61c 01219d02 0178ea9c 01765bf4 01a46ddc pontefract_timer!CallSystemFunctionNative+0x42e 
0020c64c 0121d450 00000000 00000000 0178ea9c pontefract_timer!CallSystemFunction+0xd2 
0020c6d4 0121c276 01a46dfc 77b6ea11 00000000 pontefract_timer!asCContext::ExecuteNext+0x930 
0020c708 0127a293 719b431a 0020f780 00000000 pontefract_timer!asCContext::Execute+0x1d6 
0020f780 0127a1d5 719b4c6a 77b1f2a9 0010000c pontefract_timer!execute+0x83 
0020f8f0 0127acff 77b1f2a9 77b18d02 0020f958 pontefract_timer!RunApplication+0x805 
0020f908 0127b085 0020f908 0127b339 00000000 pontefract_timer!run_script+0x9f 
0020f910 0127b339 00000000 00000000 7ffdf000 pontefract_timer!main_game+0x35 
0020f958 01298fdd 01210000 00000000 00361f32 pontefract_timer!WinMain+0x2a9 
0020f9e8 7750ed6c 7ffdf000 0020fa34 77d7377b pontefract_timer!__tmainCRTStartup+0x11a 
0020f9f4 77d7377b 7ffdf000 6959b49d 00000000 kernel32!BaseThreadInitThunk+0xe 
0020fa34 77d7374e 01299030 7ffdf000 00000000 ntdll!__RtlUserThreadStart+0x70 
0020fa4c 00000000 01299030 7ffdf000 00000000 ntdll!_RtlUserThreadStart+0x1b 
4

你可以嘗試分析與微軟的Debug Diagnostics Tool轉儲 - 它似乎證實你懷疑,但沒有你的代碼或您的EXE版本PDB的知識,我無法從調用堆棧獲得更多的信息。

Summary of problem

線程0的調用棧和4爲:總結如下 -

從報告中有涉及到兩個線程(你可以使用該工具運行全面分析自己)如下:

Thread 0

..和...

Thread 4

這些可能會給你一些更多的信息,讓你再次移動....

希望幫助,

羅傑