pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

require'lfs' in Local console crash IDE. #1079

Closed robertlzj closed 4 years ago

pkulchenko commented 4 years ago

It doesn't for me; any further details? version, platform?

robertlzj commented 4 years ago

Win10, newest IDE and lfs.dll in folder clib53. Crash only happens in Local console, Remote console, editor is fine. (I think it's related with #1080 ) ~I'll try on another computer later.~

pkulchenko commented 4 years ago

Yes, it has to be related if you run it from clibs53, as the version to be loaded from the console has to be linked with lua51. I'm certain that it's related to the wrong version to be loaded, but can you run print(package.cpath) from the console to confirm?

robertlzj commented 4 years ago

print(package.cpath) from local console is different from neither run nor debug.

--local console
bin/clibs/?.dll;
C:\Users\RobertLin\AppData\Roaming\LuaRocks\lib\lua\5.3\?.dll;
c:\programfiles\zerobranestudio\\lib\lua\5.3\?.dll;
C:\Users\RobertLin\luaplus\Tools\JamPlus\bin\win32\lua\modules\?.dll;

lfs would been first found at c:\programfiles\zerobranestudio\\lib\lua\5.3\?.dll;, if \\ won't trouble. Or, been found at C:\ProgramFiles\ZeroBraneStudio\bin\clibs\ expanded for bin/clibs/?.dll;. But in both position, I put the right lfs.dll already.

Also test. Script print(require'lfs') in editor using Lua 5.1 won't work, print nothing with no waring in Output, just complete script. Same script in console make crash.

And doesn't lfs.dll compatible with all version of Lua. (I use LuaRocks to get it) So, why crashes still happen?

pkulchenko commented 4 years ago

Script print(require'lfs') in editor using Lua 5.1 won't work, print nothing with no waring in Output, just complete script. Same script in console make crash.

It's because when you Run or Debug your application, it's executed in a separate process, which crashes, but leaves your IDE process intact. When you try to load a wrong library into the same process as the IDE, it crashes and takes down everything with it, including the IDE.

Your path information confirms that you are loading a library from lua53 into the process that expect lua51 library, which will lead to a crash.

The question is, how did you get lua53 path into the one used by the Local console, as it should reference only paths for lua51 modules by default. Did you set it up in LUA_CPATH before loading the IDE or in user.lua?

robertlzj commented 4 years ago

My fault. I did modify LUA_CPATH in environment variables. Now I restore them (almost empty now).

pkulchenko commented 4 years ago

Right, you can use LUA53_CPATH, but shouldn't put lua53 libraries in LUA_CPATH.