AppHangB1

我目前正在处理的程序偶尔会因 AppHangB1 问题事件而挂起。我已经将它追溯到一系列特定的操作,但它似乎是一种 heisenbug,因为每当我单步执行代码时,它都不会表现出来。而且一旦程序挂起,我就无法暂停程序来查看它在 Visual Studio 中的挂起位置。这个应用程序中发生了很多事情(非托管互操作、多线程等),所以在我的特定应用程序中可能有很多错误。

我不是在寻找任何人来解决我的问题,我只是想知道什么类型的事情会导致这种类型的挂起?我在谷歌上找到了几个点击,但没有任何帮助。任何有助于查明问题的 .NET 应用程序调试技巧也会有所帮助。

最佳答案

当 UI 线程数秒内未响应消息并且用户尝试终止它时,将触发 AppHangB1 事件。几乎任何事情都可能导致挂起:代码中的繁忙循环、在 UI 线程上执行网络或磁盘 I/O、UI 线程被阻塞在执行长时间运行任务的后台线程持有的锁上,等等。

Visual Studio 无法在挂起点中断,这有点让人担心。您附加的是仅托管调试还是混合模式调试?您可以尝试使用 Windbg ( http://www.microsoft.com/whdc/devtools/debugging/default.mspx ) 以非侵入方式附加到进程并尝试获取挂起线程的堆栈跟踪(您想查看使用 !clrstack 获取托管堆栈跟踪)。 Windbg 的学习曲线非常陡峭,因此您可能只想收集可以在 Visual Studio 中调试的转储。

关于.net - 什么会导致 WPF 应用程序崩溃并出现 AppHangB1 问题事件名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/706649/

The program I'm currently working on occasionally hangs with an AppHangB1 problem event. I have traced it to a specific series of actions, but it seems to be a type of heisenbug, as whenever I step through the code, it doesn't manifest itself. And once the program hangs, I can't pause the program to see where it is hung in Visual Studio. There are many things going on in this application (unmanaged interop, multi-threading, etc.), so it could be any number of things that are wrong in my particular application.

I am not looking for anyone to solve my problem for me, I'm just wondering what types of things could cause this type of hang? I found a couple hits on Google, but nothing that helped. Any debugging tricks for .NET applications that could help pinpoint the problem would also help.

The AppHangB1 event is triggered when the UI thread doesn't respond to messages for several seconds and the user tries to terminate it. Hangs can be caused by just about anything: busy loops in your code, doing network or disk I/O on the UI thread, the UI thread being blocked on a lock held by a background thread doing a long running task, etc.

It's a bit concerning that Visual Studio can't break at the point of the hang. Are you attaching for managed-only debugging or for mixed-mode debugging? You could try using Windbg (http://www.microsoft.com/whdc/devtools/debugging/default.mspx) to non-invasively attach to the process and try to get a stack trace of the hung thread (you want to look at using !clrstack to get the managed stack trace). The learning curve for Windbg is pretty steep, so you might just want to collect a dump that you can debug in Visual Studio.

My debugging skills don't extend much beyond the VS2008 tools. I have used WinDbg in the past, but am not very familiar with it. I am unable to get a trace (in VS or WinDbg) on the occasion that the app does hang. Both debugging apps hang when my app hangs. Any suggestions on how to get a trace?

bsruth

Apr 1, 2009 at 23:09

Try remote debugging. If your app is doing some very strange and horking the desktop, doing a remote debug might help since it's UI couldn't be hung by your app.

Michael

Apr 2, 2009 at 5:10

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值