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: AS3, error, Flash, flex compiler, release, stack, throw, trace, try, underflow
June 1st, 2015 at 14:26
I found that a if() { } else { } with nothing but trace statements in the true and false branches did the same thing.
October 17th, 2021 at 12:12
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.