本文介绍了如何调试运行时堆栈下溢错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm really struggling to resolve a stack underflow that I'm getting. The traceback I get at runtime is:

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.

有人对如何调试堆栈下溢有任何提示吗?是否清楚地解释了这对 Flash 意味着什么?

如果有帮助,当我单击其处理程序进行 RPC 调用的按钮时,会发生此错误,该调用使用 URLLoader、AsyncToken,然后调用与 AsyncToken 关联的一组 AsyncResponder 实例.通过一些服务器端日志记录以及一些入侵 swf 的日志记录,我知道 UrlLoader 正在成功执行并且正在正确处理一个 crossdomain.xml 文件(即:如果我破坏了它,我会得到一个安全错误),并且也成功完成了加载"请求(服务器发送数据).下溢似乎发生在 Event.COMPLETE 侦听/处理过程中(当然,回溯也暗示了这一点).

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 使用 = 来自 flex_sdk_4.5.0.20967

mxmlc used = from flex_sdk_4.5.0.20967

示例播放器(我试过几个)= 10.2.153.1

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 事件.

Note that the code is/was attached to the initialize event.

InitData() 和相关定义是:

InitData() and relevant defintions are/were:

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 对象.关于发布(与调试)编译的某些东西一定已经影响了 SP 变量初始化的启动时间.稍后将处理程序移至 onCompletion 事件解决了所有问题.

When I switched the InitData() call to be on the onCompletion event instead of initialize (thanks J_A_X!), the problem goes away entirely. What seems to have been happening was that the Event.COMPLETE event handler (onComplete in the stack trace) was using the global SP object. Something about the release (vs debug) compilation must have been affecting the startup timing of the SP variable initialization. Moving the handler later to the onCompletion event resolved all issues.

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

As said above, I would still like to know what tricks/tools are available for debugging initialization issues like this.

更新 2:

applicationComplete 似乎是一个比 creationComplete 更好的事件来放置应用程序初始化代码.请参阅此博客条目以获得一些解释,以及和此视频(大约 4:25)由 Adob​​e 技术布道士提供的简单应用程序启动"数据初始化示例.

applicationComplete seems to be an even better event than creationComplete to put application initialization code. See this blog entry for some explanation, and and this video (around 4:25) by an Adobe Tech Evangelist for an example of simple "start of application" data initialization.

推荐答案

Stack underflow 基本上就是编译器搞砸了.

Stack underflow basically means the compiler messed up.

您可以使用SWFWire Inspector查看事件处理程序的字节码,如果您想知道到底是怎么搞砸的.您还可以使用 SWFWire Debugger 来查看调用了哪些方法,但在这种情况下,您已经知道它在哪里正在发生.

You can use SWFWire Inspector to look at the bytecode of the event handler, if you want to know exactly how it messed up. You can also use SWFWire Debugger to see which methods were called, but in this case, you already knew where it was happening.

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

If you post the broken swf, I can give you more info.

这篇关于如何调试运行时堆栈下溢错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 16:06