views:

1285

answers:

4

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.

A: 

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).

apphacker
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
Alessandro Vernet
+1  A: 

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
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?
Alessandro Vernet
@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
@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.
Alessandro Vernet
I have seen FF do this, but never IE. The answer from George Reilly sounds promising.
leppie
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
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
Alessandro Vernet
+5  A: 

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
@George V. Reilly, This is a great tip. I'll definitely have to try this one out.
Alessandro Vernet
@George V. Reilly, BTW, are you the buy on the picture of that Microsoft site you recommended? ;)
Alessandro Vernet
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
@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
Alessandro Vernet
A: 

I too have this problem with ajax enable applications. And as of yet haven't been able to resolve problem. The only work around is to not use ajax...