LuaLanes / lanes

Lanes is a lightweight, native, lazy evaluating multithreading library for Lua 5.1 to 5.4.
Other
437 stars 94 forks source link

Ошибка /Program Files/lua/lanes.lua:535: too many C levels (limit is 200) in function at line 495 near 'next_wakeup' #178

Closed egor230 closed 4 years ago

egor230 commented 4 years ago

собрал lanes для lua 5.3.5 поскольку очень нужна многопоточность в моем проект. Но при запуске выходит ошибка /Program Files/lua/lanes.lua:535: too many C levels (limit is 200) in function at line 495 near 'next_wakeup' как ее исправить?

benoit-germain commented 4 years ago

Hmmm. First time I see that one. Can you provide some kind of minimal example that demonstrates the problem? This seems to be related to the timers service. Can you initialize lanes with the timers disabled to see if it fixes your issue?

egor230 commented 4 years ago

Thank You very much for Your answer benoit-germain.

Really need multi-threading for lua plugin for gta vice city on the basis of sdk plugin DK https://pastebin.com/VatypnLb

Install lanes library via LuaRocks, I have lua 5.3.5 installed. For verification I use IntelliJ IDEA Community Edition 2019.1.3 development environment

Here is a video recorded from the screen for clarity https://www.youtube.com/watch?v=fvz1vq-rKNU&feature=youtu.be

benoit-germain commented 4 years ago

From what I see in your video I suspect the problem is with your setup of package.path and package.cpath, The error you see is probably just a symptom. I might be able to improve on its aspect but it is unlikely that it will solve your issue.

egor230 commented 4 years ago

thank you for Your benoit-germain. You were right, the problem is in the ways of lua. Please tell me how to configure them correctly? I downloaded the library https://sourceforge.net/projects/luabinaries/files/5.3.5/Windows%20Libraries/Dynamic/lua-5.3.5_Win64_dll15_lib.zip/download and executables https://sourceforge.net/projects/luabinaries/files/5.3.5/Tools%20Executables/lua-5.3.5_Win64_bin.zip/download

joined in folder C:\Program Files\lua added it to the computer properties for additional environment variables settings. path, LUA_PATH, LUA_CPATH How was that supposed to go?

benoit-germain commented 4 years ago

The best advice I can give you is to start by having a look at the manual, where everything is better explained that I ever could.

egor230 commented 4 years ago

thank you very much for Your reply. I managed to solve the problem with the paths. but got a new error %1 �� �������� ����������� Win32.

I try to implement multithreading in Lua Api through coroutines using lua_sethook. here's the code

void LUAHook(lua_State* L, lua_Debug* ar) {
    lua_yield(L, 0);
};
 const char* LUA = R"(
function foo()
for i = 1, 4 do
print(" func foo \n")
end end

function main()
for i = 1, 3 do
print(" func main "..i.."\n")
if j == nil
then
 foo1()
j=1
end
end  end
)";
int foo1(lua_State* L) {
    lua_State* L1 = lua_newthread(L); 
    lua_sethook(L, LUAHook, LUA_MASKLINE, 1);
    lua_getglobal(L1, "foo");
    lua_sethook(L1, LUAHook, LUA_MASKLINE, 1);
    lua_resume(L1, L, 0);

return  0;
};
int main() {
    lua_State* L = luaL_newstate(); luaL_openlibs(L);
    lua_register(L, "foo1", foo1);
    luaL_dostring(L, LUA);
    int ret;
    lua_getglobal(L, "main");// функция lua возобновляется с последней 
    //  прерванной позиции.
    ret = lua_resume(L, NULL, 0);

    return 0;
};

me need to display the following in the console

func main 1 func foo func main 2 func foo func main 3 func foo

benoit-germain commented 4 years ago

Sorry but the error is unreadable. Also I've never used coroutines, so I have no experience with them, especially when mixing them with hooks. From what I have read in the documentation what you are doing seems legit, but I can't say anything else on the subject.

egor230 commented 4 years ago

thank you very much for Your prompt reply. I myself have been experiencing difficulties for a long time without your multithreading library, maybe there is a way to embed it. as in MoonLoader for GTA San Andress?

benoit-germain commented 4 years ago

Oh my, sorry for the late reply. Of course you can embed Lanes in an application. The documentation explains the way to go. Please tell me if the explanations need more work.