简体   繁体   English

当我为调试编译我的程序时,Lua 运行正常,但为什么我为发布编译它,我得到一个 c0000005 错误

[英]When I compile my program for Debugging the Lua runs fine but why I compile it for release I get a c0000005 error

I'm using LUA for a SDL project.我将 LUA 用于 SDL 项目。 I downloaded the precompiled LIB and DLL file from here (http://sourceforge.net/projects/luabinaries/files/5.2/Windows%20Libraries/Dynamic/) (lua-5.2_Win32_dll10_lib.zip) and have incorporated it into my project.我从这里 (http://sourceforge.net/projects/luabinaries/files/5.2/Windows%20Libraries/Dynamic/) (lua-5.2_Win32_dll10_lib.zip) 下载了预编译的 LIB 和 DLL 文件,并将其合并到我的项目中。 When I build a debug build the application runs 100% fine.当我构建调试版本时,应用程序运行 100% 正常。 When I set it to release mode and press the Play button in Visual Studio it also runs fine.当我将它设置为发布模式并按下 Visual Studio 中的播放按钮时,它也运行良好。

BUT if I run the Release file by doubling clicking it in the folder I get the error c0000005 with the lua52.dll.但是,如果我通过在文件夹中双击它来运行 Release 文件,我会收到带有 lua52.dll 的错误 c0000005。

I'm running MicroSoft Visual C++ 2010 Express.我正在运行 MicroSoft Visual C++ 2010 Express。

I went through deleting lines till it started working and the lines that causes the error are.我经历了删除行直到它开始工作并且导致错误的行是。

void aiBrainmanager::run(string holdData){

int errfunc = 0;
int s;
int s = luaL_loadstring(L, holdData.c_str());

if ( s==0 ) {
    s = lua_pcall(L, 0, LUA_MULTRET, errfunc);
}
if (errfunc !=0) {

}
if (s !=0) {

    aiBrainmanager::target->stopWorking();
}


}

Any idea what setting is wrong or how to fix it.知道什么设置错误或如何修复它。

0xc0000005 is a memory violation. 0xc0000005 是 memory 违规。 The fact that it works in debug, means a number possible things.它在调试中工作的事实意味着许多可能的事情。

  1. Memory is not being initialised or set correctly (in debug it's initialed to 0) so string are terminated for example. Memory 没有被初始化或设置正确(在调试中它被初始化为 0)所以字符串被终止例如。
  2. Memory requirements are larger than th buffers allow (in debug it could be padded). Memory 要求大于缓冲区允许的范围(在调试中可以填充)。
  3. You code is doing something different in debug than compile (#if etc.)您的代码在调试中做的事情与编译时不同(#if 等)

Looking at your code I would look at:查看您的代码,我会查看:

Why are you checking for error and then not doing anything?????你为什么要检查错误然后什么都不做?????

if (errfunc !=0) { 
 // What happens in here??????
} 

The lua_pcall function returns 0 in case of success or one of the following error codes (defined in lua.h): lua_pcall function在成功的情况下返回 0 或以下错误代码之一(在 lua.h 中定义):

  • LUA_ERRRUN: a runtime error. LUA_ERRRUN:运行时错误。

  • LUA_ERRMEM: memory allocation error. LUA_ERRMEM: memory 分配错误。 For such errors, Lua does not call the error handler function.对于此类错误,Lua 不会调用错误处理程序 function。

  • LUA_ERRERR: error while running the error handler function LUA_ERRERR:运行错误处理程序时出错 function

I think you'll find you're getting a LUA_ERRMEM我想你会发现你得到了一个LUA_ERRMEM

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在jgrasp中编译C ++程序时,为什么会出现此错误? - Why do I get this error when I compile a C++ program in jgrasp? 如何使我的C ++程序在Unix上编译? - How can I get my C++ program to compile on Unix? 我的程序运行良好,我可以复制对象,但是当我使用复制分配 (=) 时,它仍然运行良好。 为什么不报错? - My program runs fine and I am able copy the object however when I used the copy assignment (=) it still runs fine. Why is it not giving error? 当我尝试编译此C ++程序时,它给了我一个错误 - When I try to compile this C++ program, it gives me an error 当我在Dev C ++中编译代码时,出现以下错误:[错误] ID返回1退出状态 - When I compile my code in Dev C++, I get this error: [Error] Id returned 1 exit status 为什么我在尝试编译时遇到此编译错误? - Why am i getting this compile error when i try to compile? 尝试编译XPCOM代码时为什么会出现错误C2440? - Why do I get error C2440 when I try to compile XPCOM code? 为什么在使用递归Lambda时出现编译错误? - Why I get compile error when using a recursive lambda? 如何从 c# 中的本机 dll 捕获 c0000005 异常 - How do I catch c0000005 exception from native dll in c# 为什么我会收到错误:当我尝试编译C ++代码时,在Eclipse中初始化'Item :: Item(int)'[-fpermissive]的参数1? - Why am I getting error: initializing argument 1 of 'Item::Item(int)' [-fpermissive] in Eclipse when I try to compile my C++ code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM