I have some ActionScript3 code that for some reason only crashes in a stack overflow when compiled for ‘Release’ mode. The method it crashes in doesn’t call any other function and does therefore not recurse in any way.
The weird thing is that when compiled in ‘Debug’ mode it works perfectly.
The ‘Release’ mode also starts working if I enable ‘Verbose stack traces’ in the compiler options. What is this trickery? Is there a bug in the flash compiler when it tries to optimize too much?
Edit:
Here is the stack trace:
Stacktrace:
VerifyError: Error #1023: Stack overflow occurred.
at Extensions::CRunObjectSelection/filterNonQualifierObjects()
at Extensions::CRunObjectSelection/filterObjects()
at Extensions::CRunEasing/con_IsObjectMoving()
at Extensions::CRunEasing/condition()
at Objects::CExtension/condition()
at Conditions::CCndExtension/eva2()
at Conditions::CCndExtension/eva1()
at Events::CEventProgram/computeEventList()
at RunLoop::CRun/f_GameLoop()
at RunLoop::CRun/doRunLoop()
at Application::CRunApp/loopFrame()
at Application::CRunApp/playApplication()
at Application::CRunApp/stepApplication()
And here is some of the code referenced in that report:
public function selectAll(Oi:int):void
{
var pObjectInfo:CObjInfo = OiList[Oi];
pObjectInfo.oilNumOfSelected = pObjectInfo.oilNObjects;
pObjectInfo.oilListSelected = pObjectInfo.oilObject;
pObjectInfo.oilEventCount = eventProgram.rh2EventCount;
var i:int = pObjectInfo.oilObject;
while(i >= 0)
{
var pObject:CObject = ObjectList[i];
pObject.hoNextSelected = pObject.hoNumNext;
i = pObject.hoNumNext;
}
}
public function filterNonQualifierObjects(rdPtr:Object, Oi:int, negate:Boolean, filter:Function):Boolean
{
var pObjectInfo:CObjInfo = OiList[Oi];
var hasSelected:Boolean;
if (pObjectInfo.oilEventCount != eventProgram.rh2EventCount){
selectAll(Oi); //The SOL is invalid, must reset.
}
//If SOL is empty
if(pObjectInfo.oilNumOfSelected <= 0){
return false;
}
var firstSelected:int = -1;
var count:int = 0;
var current:int = pObjectInfo.oilListSelected;
var previous:CObject = null;
while(current >= 0)
{
var pObject:CObject = ObjectList[current];
var filterResult:Boolean = filter(rdPtr, pObject);
var useObject:Boolean = Boolean(int(filterResult) ^ int(negate));
hasSelected = Boolean(int(hasSelected) | int(useObject));
if(useObject)
{
if(firstSelected == -1){
firstSelected = current;
}
if(previous != null){
previous.hoNextSelected = current;
}
previous = pObject;
count++;
}
current = pObject.hoNextSelected;
}
if(previous != null){
previous.hoNextSelected = -1;
}
pObjectInfo.oilListSelected = firstSelected;
pObjectInfo.oilNumOfSelected = count;
return hasSelected;
}
Your problem could be caused by this bug: http://bugs.adobe.com/jira/browse/ASC-2993
See also this question: Why does calling this function with more than 2 parameters in Actionscript 3 cause stack overflow?