38

I realise this is not the ideal place to ask about this in terms of searchability, but I've got a page whose JavaScript code throws "Stack overflow in line 0" errors when I look at it in Internet Explorer.

The problem is quite clearly not in line 0, but somewhere in the list of stuff that I'm writing to the document. Everything works fine in Firefox, so I don't have the delights of Firebug and friends to assist in troubleshooting.

Are there any standard causes for this? I'm guessing this is probably an Internet Explorer 7 bug or something quite obscure, and my Google-fu is bringing me little joy currently. I can find lots of people who have run into this before, but I can't seem to find how they solved it.

danday74
  • 38,089
  • 29
  • 169
  • 214
glenatron
  • 10,309
  • 11
  • 59
  • 101
  • 28
    sick that this has 10k views. – Sneakyness Dec 23 '09 at 17:24
  • It's a really common and generic error message- it can show up for a whole lot of reasons and it totally doesn't explain itself. If it said "infinite loop" or something it would be a lot easier to work out what the cause is. – glenatron Dec 24 '09 at 10:32
  • sometimes i cant understand why suddenly one question gets all the attention...damn :) or :( – Suraj Chandran May 24 '11 at 17:44
  • 2
    I'm pretty sure the attention is because it is a very common and not in the least bit self-explanatory error message... – glenatron Oct 18 '11 at 21:48

13 Answers13

32

I ran into this problem recently and wrote up a post about the particular case in our code that was causing this problem.

http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/

The quick summary is: recursion that passes through the host global object is limited to a stack depth of 13. In other words, if the reference your function call is using (not necessarily the function itself) was defined with some form window.foo = function, then recursing through foo is limited to a depth of 13.

Mike Kormendy
  • 3,127
  • 1
  • 21
  • 21
Ross Boucher
  • 716
  • 2
  • 6
  • 10
20

Aha!

I had an OnError() event in some code that was setting the image source to a default image path if it wasn't found. Of course, if the default image path wasn't found it would trigger the error handler...

For people who have a similar problem but not the same, I guess the cause of this is most likely to be either an unterminated loop, an event handler that triggers itself or something similar that throws the JavaScript engine into a spin.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
glenatron
  • 10,309
  • 11
  • 59
  • 101
  • 1
    this was somewhat similar to my problem. i'm not sure how the "recursion" happened, but i had a missing resource (empty.html) used in some iframe, and the empty.html was missing in one of my deployments. i checked my access log based on this answer, found the 404 and added the missing file. voila! – dmansfield Jul 31 '12 at 19:28
17

You can turn off the "Disable Script Debugging" option inside of Internet Explorer and start debugging with Visual Studio if you happen to have that around.

I've found that it is one of few ways to diagnose some of those IE specific issues.

hud
  • 4,373
  • 10
  • 49
  • 124
Mitchel Sellers
  • 58,921
  • 13
  • 103
  • 170
7

I had this problem, and I solved it. There was an attribute in the <%@ Page tag named MaintainScrollPositionOnPostback and after removing it, the error disapeared. I added it before to prevent scrolling after each postback.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
massoud
  • 71
  • 1
  • 1
3

If you came here because you had the problem inside your selenium tests: IE doesn't like By.id("xyz"). Use By.name, xpath, or whatever instead.

devsnd
  • 6,563
  • 3
  • 39
  • 47
2

Also having smartNavigation="true" causes this"

CDev
  • 21
  • 1
2

I set up a default project and found out the following:

The problem is the combination of smartNavigation and maintainScrollPositionOnPostBack. The error only occurs when both are set to true.

In my case, the error was produced by:

<pages smartNavigation="true" maintainScrollPositionOnPostBack="true" />

Any other combination works fine.

Can anybody confirm this?

Tillito
  • 7,176
  • 6
  • 30
  • 31
  • smartNavigation is deprecated, so you should use maintainScrollPositionOnPostBack only. This solved the problem for me. – Tillito Feb 04 '12 at 19:25
  • My users suddenly started receiving this error after I added these attributes to the pages tag, but only when using IE, so I did not experience the problem myself. Not having any clue to link the two together, I was completely lost for a solution until I found this answer. – kad81 May 11 '12 at 06:45
1

My was "at line 1" instead but...

I got this problem when using jQuery's .clone method. I replaced these by using making jQuery objects from the html string: $($(selector).html()).

Muhd
  • 20,699
  • 20
  • 59
  • 72
  • Could you have been cloning an element that included the code that called `clone`? That would have that effect I reckon. – glenatron Jan 22 '13 at 09:59
1

I have reproduced the same error on IE8. One of the text boxes has some event handlers to replace not valid data.

$('.numbersonly').on("keyup input propertychange", function () {
    //code
});

The error message was shown on entering data to this text box. We removed event "propertychange" from the code above and now it works correctly.

P.S. maybe it will help somebody

Max
  • 804
  • 7
  • 19
  • Like most of the examples here, this is almost certainly a recursive loop- if your `propertychange` event changes a property of the element, it would trigger itself again, causing exactly this type of exception. – glenatron Oct 25 '13 at 10:09
1

  1. Internet Options
  2. Tools
  3. Internet options
  4. Advanced
  5. Navigation section
  6. Click > Disable script debugging

    display a notification about every script error

  7. sign in
  8. You will smile !
0

In my case I had two functions a() and b(). First was calling second and second was calling first one:

var i = 0;
function a() { b(); }
function b() {
  i++; 
  if (i < 30) {
    a();
  }
}

a();

I resolved this using setTimeout:

var i = 0;
function a() { b(); }
function b() {
  i++; 
  if (i < 30) {
    setTimeout( function() {
      a();
    }, 0);
  }
}

a();
lord_t
  • 2,142
  • 2
  • 23
  • 48
0

I don't know what to tell you, but the same problem occured with jQuery table sorting and SEARCH. When there is nothing left in the table, where you are searching a string for example, you get this error too. Even in Google Analytics this error occurs often.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
FasoService
  • 139
  • 2
  • 17
  • The cause of the error is typically an unterminated loop or recursive call that just overloads the Javascript engine, but that can happen in a whole lot of different ways. – glenatron Jan 27 '10 at 10:35
-16

This is problem with Java and Flash Player. Install the latest Java and Flash Player, and the problem will be resolved. If not, then install Mozilla Firefox, it will auto install the updates required.

Anish Gupta
  • 2,150
  • 2
  • 21
  • 37