3

I have a web application, which in the course of a normal interaction, hangs IE. By "IE being hung", I mean that IE doesn't respond anymore and using 100% of the CPU. The only to get out of this state is to kill the IE process. About the app:

  • It loads only one page in the browser, communicates with a server with Ajax queries, and updates the DOM.
  • I can reproduce this with both IE6 and IE7, but not Firefox or Safari.

I am wondering if anyone has seen this already, and if there are a few known cases that can get IE into this hung / using 100% of the CPU state.

Kara
  • 6,115
  • 16
  • 50
  • 57
avernet
  • 30,895
  • 44
  • 126
  • 163
  • Hi, Is this page available on the Internet to have a look? thanks – Nahom Tijnam Feb 22 '09 at 05:51
  • Unfortunately, this is an app which was create for a client and which isn't public. – avernet Feb 22 '09 at 06:16
  • Maybe if you could post some of the HTML/JavaScript of the page? Also, can you give us information the memory usage of the page? Is it high? Does it climb? – BobbyShaftoe Feb 22 '09 at 06:33
  • The page is quite big. There is about 1 MB of HTML, 600 KB of JavaScript (minimized, combined in one file). When loading the page, IE7 mem usage increases by 20 MB. When using the page, it increases by another 40 MB. In increases another 50 MB before it hangs. – avernet Feb 22 '09 at 06:45
  • @BobbyShaftoe Sorry, because this is an application created for a client, I can't share much here. I'd have to create a reproducible test case which doesn't include any of the code, which seems close to impossible :). – avernet Feb 22 '09 at 06:47
  • Alessandro, IE is very bad (slow) at locating elements in the DOM using XPATH, and quite bad at manipulating the DOM (adding sub-nodes.) What kinds of ops is your AJAX performing on the DOM (both read & write?) – vladr Feb 22 '09 at 08:29
  • @BobbyShaftoe Yes, it is indeed :). – avernet Feb 22 '09 at 21:02
  • @Vlad Romascanu, it is performing all kind of operations, including massive updates of the page (yes read and write). – avernet Feb 22 '09 at 21:04
  • Alessandro, did you ever solve this problem? We are running into something very very similar. Thanks. – Eric Pohl May 06 '10 at 19:04

3 Answers3

6

Use WinDbg, http://www.microsoft.com/whdc/devtools/debugging/

Attach it to the IE process that has the problem.

The .symfix+ command will set your symbol path to point to the Microsoft symbol server and cache the debug symbols locally.

The !runaway command will enumerate all the stacks in the process and tell you which one is going berserk.

If you're lucky, you may see something recognizable, such as a regex replacement at the top of the stack. Or perhaps the layout engine has gone into an infinite loop. Both of these have happened to me in the past.

If the callstack doesn't make sense, use 'g' to make the process go, wait a few seconds, hit Ctrl+Break, then try !runaway again.

Once you've got the symbols locally, you can also use SysInternals' Process Explorer to look at a process's stacks. Configure the Symbols option in Process Explorer to point to your local symbol cache, something like c:\Program Files\Debugging Tools for Windows\sym.

George V. Reilly
  • 15,885
  • 7
  • 43
  • 38
  • @George V. Reilly, This is a great tip. I'll definitely have to try this one out. – avernet Feb 22 '09 at 21:07
  • @George V. Reilly, BTW, are you the buy on the picture of that Microsoft site you recommended? ;) – avernet Feb 22 '09 at 21:08
  • Heh. Nope. But I am one of the pasty white guys with beards and glasses on the cover of "Beginning ATL COM Programming". – George V. Reilly Feb 23 '09 at 01:52
  • @George, :). So we are in good company; I am the guy on the right on this Professional XML book: http://www.wrox.com/WileyCDA/WroxTitle/productCd-0471777773.html – avernet Feb 26 '09 at 03:08
1

Try attaching the script debugger (via Visual Studio, in my case), and see what is causing it.

Most likely it's a javascript running an infinite loop, or just looping too fast for what needs to be done per ajax request.

leppie
  • 115,091
  • 17
  • 196
  • 297
  • But if this is what is happening, shouldn't IE suggest to stop running the script after a certain amount of time? At least I am used to see this message in IE when I write an infinite loop. Are there cases where IE can't detect a script running for a long time? – avernet Feb 22 '09 at 06:06
  • @Alessandro-Vernet, that error only occurs in situations. You're right, it can be helpful, but there are a large class of situations that can occur where you won't get that message. – BobbyShaftoe Feb 22 '09 at 06:30
  • @BobbyShaftoe Interesting, I didn't know that infinite loops could get IE to hang. Thanks for that information. I'll try to follow the advice from another user who suggested I test this with IE8 and use the IE8 tools to debug this. – avernet Feb 22 '09 at 06:33
  • I have seen FF do this, but never IE. The answer from George Reilly sounds promising. – leppie Feb 22 '09 at 08:58
  • It depends where it's stuck. It could be in the JavaScript engine. It could be in the HTML layout engine or some other native code, in which case the script debugger will not help. The WinDbg trick that I gave will help pinpoint what's happening. – George V. Reilly Feb 23 '09 at 01:54
  • George, it is not happening in the JavaScript engine. I used your method to get stack traces, and have posted them here: http://stackoverflow.com/questions/576349/ie-hanging-with-100-cpu-got-stack-trace – avernet Feb 26 '09 at 03:06
0

Have you tried tracing the problem? If the problem also happens in IE8 you could use console.log commands and their awesome new debugger/dev tool that's built in. Otherwise use the old dev toolbar for IE or alerts. Try to reduce the problem and then file a bug (and paste the code here please).

Bjorn
  • 69,215
  • 39
  • 136
  • 164
  • The code has been sprinkled with console.log() but that hasn't helped. I also have stack traces, which you can see here: http://stackoverflow.com/questions/576349/ie-hanging-with-100-cpu-got-stack-trace – avernet Feb 26 '09 at 03:05