actionscript-3 - 如何调试运行时堆栈下溢错误?

标签 actionscript-3 flash debugging apache-flex stackunderflow

我真的很难解决我遇到的堆栈下溢问题。我在运行时得到的回溯是:

VerifyError: Error #1024: Stack underflow occurred.

at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

This is particularly difficult to debug because when I run in debug mode it does not happen at all. It only happens when compiled as a release.

Does anyone have any tips on how to debug a Stack Underflow? Are have a clean explanation of what that means for Flash?

In case it helps, this error is occurring when I click a button whose handler makes an RPC call, which uses a URLLoader, an AsyncToken, and then invokes the set of AsyncResponder instances associated with the AsyncToken. With some server-side logging as well as some logging hacked into the swf, I know that the UrlLoader is successfully doing and GET'ing a crossdomain.xml file, is correctly processing it (ie: if I wreck it, I get a security error), and is also successfully completing the "load" request (the server sends the data). The underflow seems to be happening in the Event.COMPLETE listening/handling process (as is, of course, implied by the traceback as well).

mxmlc used = from flex_sdk_4.5.0.20967

Example player (I've tried a few) = 10.2.153.1


UPDATE: My specific problem is solved... but I'm leaving the question as-is since I would like to know how to generally debug such a problem, rather than just getting my specific solution.

In my code I had the following Application definition:

<s:Application height="100%" width="100%"
                              xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               initialize="InitData();">

请注意,该代码已/已附加到 initialize事件。

InitData() 和相关定义是:
import classes.RpcServerProxy;
public var SP:RpcServerProxy;

public function InitData():void {
    SP = new RpcServerProxy("http://192.168.1.102:1234");
}

当我将 InitData() 调用切换到 onCompletion 上时事件而不是 initialize (感谢 J_A_X!),问题完全消失了。似乎发生的事情是 Event.COMPLETE 事件处理程序(堆栈跟踪中的 onComplete)正在使用全局 SP 对象。发布(vs 调试)编译一定会影响 SP 变量初始化的启动时间。稍后将处理程序移至 onCompletion事件解决了所有问题。

如上所述,我仍然想知道有哪些技巧/工具可用于调试此类初始化问题。

更新 2:
applicationComplete似乎是比 creationComplete 更好的事件放置应用程序初始化代码。见 this blog entry一些解释,和this video (大约 4 点 25 分)由 Adob​​e 技术布道师提供的简单“应用程序启动”数据初始化示例。

最佳答案

堆栈下溢基本上意味着编译器搞砸了。

您可以使用 SWFWire Inspector查看事件处理程序的字节码,如果您想确切地知道它是如何搞砸的。您也可以使用 SWFWire Debugger查看调用了哪些方法,但在这种情况下,您已经知道它在哪里发生。

如果您发布损坏的 swf,我可以为您提供更多信息。

关于actionscript-3 - 如何调试运行时堆栈下溢错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6270837/

相关文章:

php - 使用 datagrid 、 flash 、 php 、 mysql 、 as3 显示数据库中的数据

iphone - 制作 iPhone 应用程序时是否可以嵌入或加载 SWF(Apple 是否允许)

flash - BitmapData.draw clipRect 未按预期工作

flash - file.asc 和 file.far

c++ - 我可以在 Visual Studio 2017 调试器中查看未处理的异常吗?

debugging - Docker 内部的调试限制有哪些?

ios - 在 Xcode 和 iOS 中调试应用程序启动

c# - 使静态资源在 Azure Web 角色中可用

flash - AS3上传速度测试

java - Windows 上的 red5 0.9 - 构建时的 Java 问题