Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/129.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 未捕捉到异常-O2_C++_G++ - Fatal编程技术网

C++ 未捕捉到异常-O2

C++ 未捕捉到异常-O2,c++,g++,C++,G++,我目前正在向NoAI API添加一些函数。然而,我有一个问题,它似乎起源于OpenTTD代码。问题是,除了一个系统外,该代码在我测试过的所有系统上都有效 在ScriptObject::docomand方法中,抛出Script\u Suspend类的实例。这应该在ScriptInstance::GameLoop方法中捕获。在一个系统上,当使用-O2或-O3编译程序时,不会捕获异常,程序会崩溃。它在-O0和-O1上运行良好 要调试程序,我使用以下函数在多个点打印堆栈跟踪: 堆栈跟踪-O0 In Sc

我目前正在向NoAI API添加一些函数。然而,我有一个问题,它似乎起源于OpenTTD代码。问题是,除了一个系统外,该代码在我测试过的所有系统上都有效

ScriptObject::docomand
方法中,抛出
Script\u Suspend
类的实例。这应该在
ScriptInstance::GameLoop
方法中捕获。在一个系统上,当使用-O2或-O3编译程序时,不会捕获异常,程序会崩溃。它在-O0和-O1上运行良好

要调试程序,我使用以下函数在多个点打印堆栈跟踪:

堆栈跟踪-O0

In Script_Instance::GameLoop
./openttd-build/openttd(_ZN14ScriptInstance8GameLoopEv+0x156) [0x75f3ae]
./openttd-build/openttd(_ZN2AI8GameLoopEv+0xef) [0x52c455]
./openttd-build/openttd(_Z13StateGameLoopv+0xc26) [0x6a93a3]
./openttd-build/openttd(_Z8GameLoopv+0x7a) [0x6a967c]
./openttd-build/openttd(_ZN16VideoDriver_Null8MainLoopEv+0x19) [0x80ea6d]
./openttd-build/openttd(_Z12openttd_mainiPPc+0x145b) [0x6a7ff2]
./openttd-build/openttd(main+0x3a) [0x6bcebe]
/lib64/libc.so.6(__libc_start_main+0xf4) [0x3f0801d8a4]
./openttd-build/openttd [0x4f39f9]
In ScriptObject::DoCommand:
./openttd-build/openttd(_ZN12ScriptObject9DoCommandEjjjjPKcPFvP14ScriptInstanceE+0x23a) [0x74b420]
./openttd-build/openttd(_ZN13ScriptCompany7SetNameEP4Text+0x81) [0x738d8d]
./openttd-build/openttd(_ZN9SQConvert19DefSQStaticCallbackI13ScriptCompanyPFbP4TextEEExP4SQVM+0x185) [0x5525d5]
./openttd-build/openttd(_ZN4SQVM10CallNativeEP15SQNativeClosurexxR11SQObjectPtrRb+0x334) [0x528fc4]
./openttd-build/openttd(_ZN4SQVM7ExecuteER11SQObjectPtrxxxS1_yNS_13ExecutionTypeE+0x6dc) [0x52348c]
./openttd-build/openttd(_ZN4SQVM4CallER11SQObjectPtrxxS1_yy+0xbc) [0x525992]
./openttd-build/openttd(_Z7sq_callP4SQVMxyyi+0x99) [0x4f88c1]
./openttd-build/openttd(_ZN8Squirrel10CallMethodE11tagSQObjectPKcPS0_i+0xf6) [0x7615c0]
./openttd-build/openttd(_ZN14ScriptInstance8GameLoopEv+0x326) [0x75f57e]
./openttd-build/openttd(_ZN2AI8GameLoopEv+0xef) [0x52c455]
./openttd-build/openttd(_Z13StateGameLoopv+0xc26) [0x6a93a3]
./openttd-build/openttd(_Z8GameLoopv+0x7a) [0x6a967c]
./openttd-build/openttd(_ZN16VideoDriver_Null8MainLoopEv+0x19) [0x80ea6d]
./openttd-build/openttd(_Z12openttd_mainiPPc+0x145b) [0x6a7ff2]
./openttd-build/openttd(main+0x3a) [0x6bcebe]
/lib64/libc.so.6(__libc_start_main+0xf4) [0x3f0801d8a4]
./openttd-build/openttd [0x4f39f9]
In Script_Suspend Constructor:
./openttd-build/openttd(_ZN14Script_SuspendC2EiPFvP14ScriptInstanceE+0x8f) [0x73a81b]
./openttd-build/openttd(_ZN12ScriptObject9DoCommandEjjjjPKcPFvP14ScriptInstanceE+0x290) [0x74b476]
./openttd-build/openttd(_ZN13ScriptCompany7SetNameEP4Text+0x81) [0x738d8d]
./openttd-build/openttd(_ZN9SQConvert19DefSQStaticCallbackI13ScriptCompanyPFbP4TextEEExP4SQVM+0x185) [0x5525d5]
./openttd-build/openttd(_ZN4SQVM10CallNativeEP15SQNativeClosurexxR11SQObjectPtrRb+0x334) [0x528fc4]
./openttd-build/openttd(_ZN4SQVM7ExecuteER11SQObjectPtrxxxS1_yNS_13ExecutionTypeE+0x6dc) [0x52348c]
./openttd-build/openttd(_ZN4SQVM4CallER11SQObjectPtrxxS1_yy+0xbc) [0x525992]
./openttd-build/openttd(_Z7sq_callP4SQVMxyyi+0x99) [0x4f88c1]
./openttd-build/openttd(_ZN8Squirrel10CallMethodE11tagSQObjectPKcPS0_i+0xf6) [0x7615c0]
./openttd-build/openttd(_ZN14ScriptInstance8GameLoopEv+0x326) [0x75f57e]
./openttd-build/openttd(_ZN2AI8GameLoopEv+0xef) [0x52c455]
./openttd-build/openttd(_Z13StateGameLoopv+0xc26) [0x6a93a3]
./openttd-build/openttd(_Z8GameLoopv+0x7a) [0x6a967c]
./openttd-build/openttd(_ZN16VideoDriver_Null8MainLoopEv+0x19) [0x80ea6d]
./openttd-build/openttd(_Z12openttd_mainiPPc+0x145b) [0x6a7ff2]
./openttd-build/openttd(main+0x3a) [0x6bcebe]
/lib64/libc.so.6(__libc_start_main+0xf4) [0x3f0801d8a4]
./openttd-build/openttd [0x4f39f9]
堆栈跟踪-O2

In Script_Instance::GameLoop
./openttd-build/openttd(_ZN14ScriptInstance8GameLoopEv+0x19f) [0x7584bf]
In SciptObject::DoCommand:
./openttd-build/openttd(_ZN12ScriptObject9DoCommandEjjjjPKcPFvP14ScriptInstanceE+0x26d) [0x74660d]
./openttd-build/openttd [0x116e700]
In Script_Suspend:
./openttd-build/openttd(_ZN14Script_SuspendC2EiPFvP14ScriptInstanceE+0x7e) [0x735aee]
./openttd-build/openttd(_ZN12ScriptObject9DoCommandEjjjjPKcPFvP14ScriptInstanceE+0x2c0) [0x746660]
./openttd-build/openttd [0x116e700]
我注意到-O2中的堆栈轨迹要短得多。这可能是某种损坏的调用堆栈吗?如果是,原因是什么


使用的编译器是CentOS 5.11上的GCC 4.7

听起来合乎逻辑,但这并不能解释未捕获的
脚本\u Suspend
实例。你知道在优化过程中还有什么变化会导致这种情况吗?@GeertKonijnendijk
但它没有解释脚本没有被捕获。
未定义的行为意味着你的程序可能会以你意想不到的方式运行。