我真的很难解决我遇到的堆栈下溢问题。我在运行时得到的回溯是:
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 = 来自 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
事件而不是 initialize
时(感谢 J_A_X!),问题就出现了完全离开。似乎发生的情况是 Event.COMPLETE 事件处理程序(堆栈跟踪中的 onComplete)正在使用全局 SP 对象。有关发布(与调试)编译的某些内容一定会影响 SP 变量初始化的启动时序。稍后将处理程序移至 onCompletion
事件解决了所有问题。
如上所述,我仍然想知道有哪些技巧/工具可用于调试此类初始化问题。
更新2:
applicationComplete
似乎是比 creationComplete
更好的事件来放置应用程序初始化代码。请参阅此博客文章了解一些说明,以及和此视频(4:25 左右)由 Adobe 技术传播者提供的简单“应用程序启动”数据初始化示例。
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.
发布评论
评论(9)
我通过添加编译器参数摆脱了这个错误:
-omit-trace-statements=false
I got rid of this error by adding compiler argument:
-omit-trace-statements=false
堆栈下溢基本上意味着编译器搞砸了。
如果您想确切地了解事件处理程序的字节码,可以使用 SWFWire Inspector 查看事件处理程序的字节码搞砸了。您还可以使用SWFWire 调试器来查看调用了哪些方法,但在这种情况下,您已经知道它在哪里正在发生。
如果您发布损坏的 swf,我可以为您提供更多信息。
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.
肖恩是对的,要调试它,您可以查看字节代码,但这听起来对我没有吸引力。
根据我的经验和研究,这通常是由于存在跟踪语句,该语句在发布模式下错误地编译出来,并生成无效的字节代码。所以,我会说“调试”它,“查找使用跟踪的地方。尝试在有问题的函数中将它们全部注释掉,看看问题是否消失。”
就我而言,它是一个跟踪语句作为 catch 块的第一行:
我发现其他人也有这个确切的问题 此处。
Sean is right that to debug it you can look at the byte code, but that didn't sound appealing to me.
Based on my experience and research, it is often due to the presence of a trace statement that incorrectly gets compiled out in release mode, and generates invalid byte code. So, I would say to "debug" it, "Look for places where you are using trace. Try commenting them all out in the offending function and see if the issue goes away."
In my case, it was a trace statement as the first line of a catch block:
I found someone else with this exact issue here.
此代码还会导致仅在发布模式下堆栈下溢(标志 -debug=false):
mxlmc flex sdk 版本 4.5.0.20967、flashplayer 版本 10.3.181.14 (linux)。
检查您的代码中是否有类似的表达式。
This code also leads to stack underflow only in release mode (flag -debug=false):
mxlmc flex sdk version 4.5.0.20967, flashplayer version 10.3.181.14 (linux).
Check your code for similar expressions.
当我从 flash builder 4.5 编译候选版本时,此代码给我带来了问题
通过在跟踪和大括号之间插入空格来解决
希望这会有所帮助。
This code caused me issues when I compiled a release candidate from flash builder 4.5
Resolved by inserting a space between the the trace and curly brace
Hope this helps.
对于寻找相同问题的人,我刚刚发现这是由 switch 语句的“默认”情况下的跟踪语句引起的。注释掉跟踪,堆栈下溢已解决。
For people looking for the same problem, I just got this caused by a trace statement in the 'default' case of a switch statement. Commented out the trace, stack underflow resolved.
有趣...我从网上下载的一个基于 Away3D 的图形演示的 SWF 遇到了这个错误。当时我在 Tamarin VM 上运行它,而不是在实际的 Flash/AIR 运行时上,因此可以在“verifyFailed(kStackUnderflowError)”行上设置断点,看看发生了什么。
-Dverbose 标志也有助于找到罪魁祸首:
使用 SWFInvestigator 查看 ABC,我发现了这一点:
所以存在一个明显的问题,即“trace”已被删除,但编译器已在其中放置了“pop”:我不会没有想到这是需要的,因为跟踪调用应该是通过“callpropvoid”进行的?
我不知道为什么这不会在 AIR/Flash 上失败。
无论如何:在我看来像是 ASC 编译器问题,即可能其中一个 ActionScript3 编译器有此错误 - 因此到目前为止已经提到了解决方法。
Interesting... I was getting this error with a SWF that I'd pulled off the web, an Away3D based graphics demo. At the time I was running this on the Tamarin VM rather than the actual Flash/AIR runtimes, so could stick a breakpoint on the "verifyFailed(kStackUnderflowError)" line and see what was happening.
The -Dverbose flag also helped find the culprit:
And looking at the ABC using SWFInvestigator, I found this:
So there is an obvious issue where the 'trace' has been removed but the compiler has put a 'pop' in there: I wouldn't have thought this was needed as a trace call should presumably have been made via 'callpropvoid'?
Quite why this doesn't fail on AIR/Flash I don't know..
Anyway: looks to me like an ASC compiler problem i.e perhaps one of the ActionScript3 compilers had a fault with this - hence the workarounds that have been mentioned so far.
它非常简单,并且与括号前后的空格、跟踪命令或其他任何东西没有任何关系:这只是一件非常简单的事情:
不要循环空!
这意味着,在开发过程中,我们有时都会 // 注释一些行,当这导致
编译器得到 :
时,我的好朋友们,这是编译器不喜欢的东西!
所以,没有空循环,你又上路了...
狩猎快乐,
P。
It's quite simple, and it doesn't have anything to do with spaces before or after brackets, trace commands or whatever else: it's just 1 really simple thingy:
DO NOT LOOP EMPTY!
Meaning, while developing, we all //comment some lines sometimes, and when that results in
the compiler gets :
and that my good friends, is something the compiler doesn't like!
so, NO empty loops, and you're on your way again...
Happy hunting,
P.
我遇到了完全相同的问题,但在我的情况下,问题的原因是编译器不希望它找到它的地方的跟踪语句,就在类开头的包声明之后:
这就是为什么在调试模式下编译解决了这个问题。
I had the exact same problem, but in my case the cause of the problem was a trace statement in a place where the compiler didn't expect it to find it, right after a package declaration at the beginning of the class:
And that's why compiling in debug mode removed the problem.