lua - lua_pcall cause "cannot resume dead coroutine" -


i have such c++ code below call lua code

for (int =0; < 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 code below

local cnt = 0 function analyzescript(foldername, filename, pout)     cnt = cnt + 1     print(cnt) end 

every thing ok, except "cannot resume dead coroutine"(which coroutine in place)

it looks 2000 times call lua func ruin lua stack, if change 2000 200, every goes ok!

why?

i not reproduce error. i've changed code little:

/* 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");     (i =0; < 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); } 

it compiled in linux following command (i have lua distribution installed in /fakepath/lua-5.2.0):

gcc test.c -i/fakepath/lua-5.2.0/src /fakepath/lua-5.2.0/src/liblua.a -lm -ldl 

file test.lua you've posted. maybe problem somewhere else...


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -