- 浏览: 482528 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
alvin198761:
renzhengzhi 写道我参与过12306余票查询系统的开 ...
别给12306 辩解了 -
renzhengzhi:
我参与过12306余票查询系统的开发,用户请求被前面3层缓存拦 ...
别给12306 辩解了 -
renzhengzhi:
写的很好。
JAVA线程dump的分析 -
liyonghui160com:
说好的附件呢
分布式服务框架 Zookeeper -- 管理分布式环境中的数据 -
ghpaas:
orbeon作为xforms标准的实现,不论其设计器还是运行时 ...
XForms 1.1 中文翻译—第1章 关于XForms标准
How to debug application crash/hang in production environment?
- 博客分类:
- Web性能
A common tough scenario is the application crash/hang in production environment. Production environment is different from development environment that it normally does not have any powerful tools to obtain information regarding application failure. In this blog entry, I will talk about 2 wonderful tools to help collect information in production environment: Windbg and Process Explorer. Application Crash: Crash is the most common scenario of application failure. It is actually caused by an unhanded exception generated in the application. There are 2 types of information that are common critical to resolve application crash: 1. Unhandled exception type (it is called exception code in unmanaged world) and error message 2. The full stack trace for the unhandled exception These 2 types of information are trivial to obtain in development environment, because the application runs under the VS debugger, the debugger will tell us this information while unhandled exception is caught. In production environment, it may not be practical to install Visual Studio IDE for debugging, because: 1. Visual Studio is not free. 2. VS has a large memory footprint. 3. The problem can even disappear after installing the Visual Studio. Windbg and Process Explorer are 2 free download tools with much less impact on end user. Using Windbg to obtain Application Crash information: Windbg is included in the Microsoft “Debugging tools for Windows”. You may download the “Debugging tools for Windows” from the link below: http://www.microsoft.com/whdc/devtools/debugging/default.mspx After installing windbg, the first thing is setting up the symbol path for it. The symbol path is critical during debugging, because windbg will retrieve the Windows system dlls internal symbols from the symbol path to display the meaningful name for functions/variables. Without the correct symbol loaded, the debugger can only display the numeric memory address for the functions/variables. For example, in a windbg without symbol path, if we use “k” command to obtain the current call stack, we will see following output(note the red numeric): 0:000> k *** ERROR: Module load completed but symbols could not be loaded for notepad.exe ChildEBP RetAddr WARNING: Stack unwind information not available. Following frames may be wrong. 0007f6ec 01001fe4 USER32!MessageBoxW 0007f70c 010027e7 notepad+0x1fe4 0007f944 010035b9 notepad+0x27e7 0007f960 7739c3b7 notepad+0x35b9 0007f98c 7739c484 USER32!EnableMenuItem+0x4cd4 0007fa04 7739ca68 USER32!EnableMenuItem+0x4da1 0007fa60 7739ce7a USER32!TranslateMessageEx+0xd5 0007fa88 7c82ec9e USER32!MsgWaitForMultipleObjectsEx+0x126 0007fb08 773966f0 ntdll!KiUserCallbackDispatcher+0x2e 0007fb24 7739668a USER32!DefWindowProcW+0xc7 0007fb6c 010038e2 USER32!DefWindowProcW+0x61 0007fb94 7739c3b7 notepad+0x38e2 0007fbc0 7739c484 USER32!EnableMenuItem+0x4cd4 0007fc38 7739ca68 USER32!EnableMenuItem+0x4da1 0007fc94 7739ce7a USER32!TranslateMessageEx+0xd5 0007fcbc 7c82ec9e USER32!MsgWaitForMultipleObjectsEx+0x126 0007fd3c 773966f0 ntdll!KiUserCallbackDispatcher+0x2e 0007fd58 7739668a USER32!DefWindowProcW+0xc7 0007fda0 010037fc USER32!DefWindowProcW+0x61 0007fdc8 7739c3b7 notepad+0x37fc Yes, the windbg can only recognize the export function names of the dll. Since we do not have the symbol for notepad.exe, the windbg will only display a *magic* number for the function memory address which is not meaningful to us. To set the symbol path, you may set the following path in the windbg menu item File->”Symbol File Path…”: “srv*DownstreamStore*http://msdl.microsoft.com/download/symbols”
Change “DownstreamStore” to any local folder to cache the downloaded symbol files on your machine. For example, I normally use “srv*c:\LocalSymbols* http://msdl.microsoft.com/download/symbols”. Now, you may open the windbg and click File->”Open Executable…” and select your application for launching. Windbg will launch your application and break in the initial loader breakpoint. You can check the red rectangle in the figure to ensure the symbol path is correct:
You may press “F5” or input “g” command to tell windbg to ignore the initial loader breakpoint. Now, you may manipulate your application to reproduce the crash. When the application crashes with exception, windbg will automatically break-in your application. Then you may input “k” command to get the full stack trace of this exception/failure. Note: the “k” command may require some time to load the symbols from Microsoft symbol server for the system dlls the first time. So the windbg will report “busy…” for sometime. You may wait to have a coffee for the symbol loading and output. Use Process Explorer to obtain application hangs information: Process Explorer can be free downloaded in the http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspx Process Explorer is especially suitable for troubleshooting hang problem in application, because it has a very good UI for monitor threads activity. After downloading the Process Explorer, the first thing to do is still setting the symbol server path as we do in windbg:
Note: in the “Dbghelp.dll path” textbox above, I used to Dbghelp.dll in “Debugging Tools for Windows” package, because this Dbghelp.dll has a higher version than the one in “%windir%/System32/”. If you do not have “Debugging Tools for Windows” installed on end user machine, you can live with using the one in “%windir%/System32/” directory. Let’s demonstrate the Process Explorer usage with a sample. In a .Net Winform application, we write the following code in an existing VC application to simulate the hang in application: Sleep(30000); While the application is hang, we can find the application in the Process Explorer and double click it to launch its property dialog. Then, we should switch to the “Threads” tabpage to examine the thread status. This is what I got in the sample: As you can see there is only one thread in the test application. Then, we can select the thread and click “Stack” button in the dialog, we got: Aha, by examining this stack trace, we can see that “VMQueryHelper” function calls Sleep() function, which causes the hang. Use Windbg to obtain application hangs information: Windbg can also be used to troubleshoot the application hang. I assume you have downloaded the windbg and set up the symbol path the same way as said in first section. Now, another .Net application is hanging in customer’s machine. We can use windbg to attach the hang application with the menu item below: In the dialog, we can choose the hang application and click Ok button: In the windbg, the first thing we should do is checking how many threads are there in the hang application with “~*” command, please see the figure below. As you can see in the figure, thread #0 is executing _CorExeMain method, which is .Net Winform application main GUI thread. The thread #5 has a “.” in the front which means the current examine thread. Because the application hang occurs in the main GUI thread, we should switch the current thread to the #0 thread by inputting “~0s”, see figure. Now, the context is switched to the main GUI hang thread. We can input the “K” command to get the full stack trace of the hang thread to see what it is waiting for. All these 3 commands and output are listed in the figure below.
As you can see it is the Button.Click() method in .Net Winform calls the System.Threading.Thread.Sleep(30000) that caused the hang.
发表评论
-
高性能、高流量Java Web站点打造的最佳实践
2013-12-24 11:23 2813从2005年-2013年,Ashwanth Fernando ... -
高性能、高流量Java Web站点打造的最佳实践
2013-12-24 11:01 4从2005年-2013年,Ashwanth ... -
20行实现javascript模板引擎
2013-12-23 10:35 151020行实现javascript模板引擎 我仍然在用Abs ... -
标题怎么办
2012-03-25 23:50 21.首先在这里 下载Selenium RC,解压到C盘。 ... -
Google Page Speed应用上线,移动设备也在支持之列
2011-04-05 21:23 855Google已经将Page Speed应用到线上,并且加强 ... -
浏览器的加载与页面性能优化
2011-02-16 11:23 1317本文将探讨浏览器渲染的loading过程,主要有2 ... -
门户网站负载均衡技术的六大新挑战
2010-12-23 11:25 995文 / 李晓栋 记得上 ... -
使用 JAWS 测试 Web 应用的技巧
2010-10-31 23:34 1633屏幕阅读器简介 屏幕阅读器(S ... -
How We Evaluate the Experiences We Engineer
2010-10-26 14:38 7169 and how we measured (and co ... -
研究显示:众多网上零售商未遵循Web优化基本准则
2010-10-26 10:25 697Web优化专家Joshua Bixby最近在博客中披露,在 ... -
Testing sites with Browser Mode vs. Doc Mode
2010-10-22 10:07 1067With site developers verifying ... -
Common Security Mistakes in Web Applications
2010-10-22 10:02 1694Web application developers toda ... -
A (somewhat) brief history of the performance landscape
2010-10-21 10:44 1714I’d like to enlist your help. ... -
Best Practices for Speeding Up Your Web Site
2010-10-20 10:40 1206Minimize HTTP Requests tag: ... -
Web Performance Optimization Use Cases – Part 1 Benchmarking
2010-10-19 14:40 941Web Performance Optimizatio ... -
Google WebP——让图片更小,让页面访问速度更快
2010-10-12 13:14 1587Google日前对外宣布了一种新的图片压缩格式WebP,可 ... -
剖析IE浏览器子系统的性能权重
2010-09-02 13:23 874最近,InfoQ中文站报道了Web 2.0应用客户端性能问 ... -
Performance: Profiling how different web sites use browser subsystems
2010-09-02 00:41 1206When we first showed IE9 at t ... -
Measuring Browser Performance: Understanding issues in benchmarking and performa
2010-09-02 00:40 946Measuring Browse ... -
Ajax应用开发:实践者指南
2010-08-10 21:13 979目前的Web应用开发基本上都是围绕富互联网应用(Rich ...
相关推荐
《动态调试技术详解——以Android系统中的dynamic-debug-howto为例》 在计算机软件开发领域,调试是必不可少的一个环节,它帮助我们找出代码中的错误并优化性能。动态调试(Dynamic Debug,简称ddebug)是一种强大...
you’ll learn how to use Docker to package your applications with all of their dependencies and then test, ship, scale, and support your containers in production. This edition includes significant ...
A Stock Exchange simulator to show how timers and randon number generators work together. A cool simulation for anyone who might think about playing the stocks and spending money and get a general ...
How To Use Adobe Photoshop CS2 <br>Photoshop CS2使用指南 <br>By Daniel Giordan, Doug Nelson <br>Publisher: Sams Publishing <br>Have you ever looked at your color pictures and wished ...
藏经阁-SparkR under the hood How to debug your SparkR code.pdf
So you want to test your complex application that involves large-scale distributed systems. But how do you feel about testing it effectively just using your test environment? Today, automated testing ...
How to use epoll A complete example in C How to use epoll A complete example in C How to use epoll A complete example in C How to use epoll A complete example in C
i write a document for how to config the Python 3.0 environment. it can help the Python newer
How to debug test scripts and test data How to manage and deal with browser profiles and capabilities< How to manage tests for advanced user interactions and experiences (UX) How to work with and ...
You should ensure that the server's public keys are loaded by the client as described in How to use SFTP (with server validation - known hosts), or you may want to switch off server validation to get ...
Linux HOWTO(中文版) BootPrompt-HOWTO (28KB) 启动提示说明 CDROM-HOWTO (27KB) 如何安装, 设定及使用光驱,同时列出支援的硬体. Chinese-HOWTO (39KB) 如何在 Linux 的系统上使用中文?/TD> Config-...
This tutorial will show you how to access the information you need in your browser by simply highlighting your text in the edit window and clicking your toolbar button How to install UE3 UE3 is the ...
This could be for a playable level or a game environment exploration to show off in a portfolio. Planning process is called pre-production and what you end up with is a "Preproduction Blueprint". It...
RK3399的DRM-HOWTO测试 最近在学习与调试RK3399的DRM显示架构,网上有很多例程,其中介绍比较多的是来于David Herrmann’s Github的drm-howto.开源代码 但这些源码下载后执行make编译出来的执行文件只能在PC机上测试...
Made in [Yalantis] (https://yalantis.com/?utm_source=github) [How We Created uCrop] (https://yalantis.com/blog/how-we-created-ucrop-our-own-image-cropping-library-for-android/) Check this [project on...
Using flow charts and line-by-line analysis of a full-scale P2P file-sharing application, they show you how to solve for typical P2P programming challenges – and create your own sate-of-the-art P2P ...
1.7 How do I get my program to act like a daemon? 1.8 How can I look at process in the system like ps does? 1.9 Given a pid, how can I tell if it's a running program? 1.10 What's the return value ...
you can know how to scrolling text with C#