我有一些ActionScript3代码,由于某种原因,只有在编译为“Release”模式时才会在堆栈溢出时崩溃。它崩溃的方法不会调用任何其他函数,因此不会以任何方式递归。 奇怪的是,当在“调试”模式下编译时,它可以完美地工作。 如果我在编译器选项中启用“详细堆栈跟踪”,则“释放”模式也会开始工作。这个诡计是什么?当Flash编译器尝试优化太多时,是否存在错误?
编辑:
这是堆栈跟踪:
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()
以下是该报告中引用的一些代码:
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;
}
答案 0 :(得分:1)
您是否在代码中的任何位置使用跟踪?跟踪功能有两个可能的问题。首先,跟踪会在运行时延迟并影响异步进程。第二,可能在跟踪函数中调用了一些方法。此方法可以更改变量的值。
因此,您可能会删除一些跟踪并检查代码是否会在发布模式下崩溃。
答案 1 :(得分:1)