如何调试运行时堆栈下溢错误? [英] How to debug a runtime stack underflow error?

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

问题描述

我真的很努力地解决我正在获得的堆栈下溢。在运行时得到的回溯是:

 VerifyError:Error#1024:Stack underflow occurred。 

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

这很难调试,因为当我以调试模式运行时,根本就不会发生。只有当编译为发行版才会发生。



有没有人有任何有关如何调试堆栈下溢的提示?对Flash有什么意义吗?



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



mxmlc used = from flex_sdk_4 .5.0.20967



示例播放器(我已经尝试了几个)= 10.2.153.1






更新:我的具体问题解决了...但是我正在离开问题,因为我想知道如何一般地调试这样的问题,而不是仅仅得到我的具体解决方案。



在我的代码中,我有以下应用程序定义:

 < 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 事件而不是初始化(感谢J_A_X!),问题完全消失了。似乎发生的事情是Event.COMPLETE事件处理程序(堆栈跟踪中的onComplete)正在使用全局SP对象。关于release(vs debug)的编译一定是影响SP变量初始化的启动时间。稍后将处理程序移动到 onCompletion 事件解决所有问题。



如上所述,我仍然想知道什么样的技巧/工具可用于调试这样的初始化问题。






更新2: / p>

applicationComplete 似乎比 createComplete 更好的事件放置应用程序初始化代码。有关某些解释,请参见此博客条目,以及和此视频(大约4:25)由Adobe Tech Evangelist提供简单的开始应用数据初始化的例子。

解决方案

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



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



如果你发布破碎的swf,我可以给你更多的信息。


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.

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();">

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

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");
}

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.


UPDATE 2:

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 basically means the compiler messed up.

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.

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆