VerifyError: Error #1024: Stack underflow occurred.

I just completed hunting down a Stack underflow error. It was a little tedious since the error is not thrown when I compiled for debug player, only release.
The source of it? A trace statement in a try block. For some reason the compiler doesn’t like that at all.

The solution seemed to be to remove all traces from try-catch blocks, which worked, but I wasn’t satisfied.

After binary searching trough the svn commits, I found what triggered the above error, an empty for-each loop.
Removing that loop made all traces work again normally inside try-catch blocks, which is what I prefer.

for each (var fruit:String in fruits) {
   // Empty loop, a BIG NO NO!
}

So to prevent your swf from corrupting, do not have empty for-each loops in your project! Remove them completely or fill them with some code.

Tags: , , , , , , , , ,

2 Responses to “VerifyError: Error #1024: Stack underflow occurred.”

  1. Jim Says:

    I found that a if() { } else { } with nothing but trace statements in the true and false branches did the same thing.

  2. JM Says:

    Thanks for sharing this. You’ve just helped me a solve a problem I’ve been having all morning with my release builds.

    What a strange issue indeed.