Stack overflow in line: 0

IE6 started to throw this JScript error in my face, “Stack overflow in line: 0″, in a mildly involved bundle of one-off Javascript I was cobbling together.

It was a series of calculations trickling down from an initial textbox change through cascading onchange events and homemade callbacks, and it worked, that’s not the problem — but once it was done this error message popped up each time. It didn’t happen during the calculations, it happened outside my code. I did not have any infinite recursion anywhere. Firefox showed no problems.

When I disabled the deepest part of the calculations (where the execution stack went deepest), this didn’t occur at the end. I could pinpoint just where I had to stop such that this wouldn’t happen at the end. This was around 10 stack frames, if I recall correctly.

Googling turned up nothing in the way of an explanation or a fix.

I finally worked around it by wrapping one call in setTimeout(function() { call(); }, 0); to put the rest of the execution on a fresh stack.

That worked around the spurious error dialog … but I still don’t know what was going wrong. Can’t stand that!

One Response to “Stack overflow in line: 0”

  1. JS Says:

    Googled the same error message and found your reply.
    I updated to the latest WP with all sorts of problems. Put back my old files and now when I go to ‘widgets’ under the presentation tab, as the page starts to load normally, the widgets jump and that nasty error message appears. I have to close the window.

    The oddes thing is that the ‘categories’ list does not appear anymore.

    Anyway, if you have any suggestions, much appreciated.

    Thanks.