Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.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++代码来调用Lua代码< /P> for (int i =0; i < 2000; i++) { lua_getglobal(g_L, "AnalyzeScript"); lua_pushstring(g_L, "1"); lua_pushstring(g_L, "2"); lua_pushstring(g_L, "3"); if(lua_pcall(g_L,3,0,0) != 0) { // char temp[200]={0}; sprintf(temp, "err: %s", lua_tostring(g_L, -1)); // MessageBoxA(0,temp,0,0); }_Lua - Fatal编程技术网

“所有原因”;无法恢复失效的协同程序“; 我有下面的C++代码来调用Lua代码< /P> for (int i =0; i < 2000; i++) { lua_getglobal(g_L, "AnalyzeScript"); lua_pushstring(g_L, "1"); lua_pushstring(g_L, "2"); lua_pushstring(g_L, "3"); if(lua_pcall(g_L,3,0,0) != 0) { // char temp[200]={0}; sprintf(temp, "err: %s", lua_tostring(g_L, -1)); // MessageBoxA(0,temp,0,0); }

“所有原因”;无法恢复失效的协同程序“; 我有下面的C++代码来调用Lua代码< /P> for (int i =0; i < 2000; i++) { lua_getglobal(g_L, "AnalyzeScript"); lua_pushstring(g_L, "1"); lua_pushstring(g_L, "2"); lua_pushstring(g_L, "3"); if(lua_pcall(g_L,3,0,0) != 0) { // char temp[200]={0}; sprintf(temp, "err: %s", lua_tostring(g_L, -1)); // MessageBoxA(0,temp,0,0); },lua,Lua,一切正常,除了“无法恢复死亡的协同程序”(哪个协同程序在另一个地方) 看起来调用lua func 2000次会破坏lua堆栈,如果我将2000改为200,一切都会正常 为什么?我无法重现你的错误。我对代码做了一些修改: /* test.c */ #include "lua.h" #include "lauxlib.h" void main() { int i; lua_State *g_L = luaL_newstate(); luaL_openlibs(g_L);

一切正常,除了“无法恢复死亡的协同程序”(哪个协同程序在另一个地方)

看起来调用lua func 2000次会破坏lua堆栈,如果我将2000改为200,一切都会正常


为什么?

我无法重现你的错误。我对代码做了一些修改:

/* test.c */
#include "lua.h"
#include "lauxlib.h"

void main() {
    int i;
    lua_State *g_L = luaL_newstate();
    luaL_openlibs(g_L);
    luaL_dofile(g_L, "s.lua");
    for (i =0; i < 2000; i++)
    {
        lua_getglobal(g_L, "AnalyzeScript");
        lua_pushstring(g_L, "1");
        lua_pushstring(g_L, "2");
        lua_pushstring(g_L, "3");

        if(lua_pcall(g_L,3,0,0) != 0)
        {
//          char temp[200]={0}; sprintf(temp, "err: %s",  lua_tostring(g_L, -1));
//          MessageBoxA(0,temp,0,0);
        }
    }
    lua_close (g_L);
}
文件test.lua正是您发布的内容。
也许问题出在其他地方…

什么是“协同程序”?你能告诉我们吗?我知道我的任务还不够,确切地说我在钩子函数中调用了for,哪个函数在计时器中执行,我不能准确地描述这个函数是什么,因为我不认为它是特别的我知道我的任务还不够,确切地说我在钩子函数中调用了for,哪个函数在计时器中执行,我不能准确地描述这个函数是什么,因为我认为它并不特别
/* test.c */
#include "lua.h"
#include "lauxlib.h"

void main() {
    int i;
    lua_State *g_L = luaL_newstate();
    luaL_openlibs(g_L);
    luaL_dofile(g_L, "s.lua");
    for (i =0; i < 2000; i++)
    {
        lua_getglobal(g_L, "AnalyzeScript");
        lua_pushstring(g_L, "1");
        lua_pushstring(g_L, "2");
        lua_pushstring(g_L, "3");

        if(lua_pcall(g_L,3,0,0) != 0)
        {
//          char temp[200]={0}; sprintf(temp, "err: %s",  lua_tostring(g_L, -1));
//          MessageBoxA(0,temp,0,0);
        }
    }
    lua_close (g_L);
}
gcc test.c -I/fakepath/lua-5.2.0/src /fakepath/lua-5.2.0/src/liblua.a -lm -ldl