Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KopiLua IO should print a warning on first use #1677

Closed
nlburgin opened this issue Sep 20, 2019 · 5 comments
Closed

KopiLua IO should print a warning on first use #1677

nlburgin opened this issue Sep 20, 2019 · 5 comments
Labels
re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console)

Comments

@nlburgin
Copy link

nlburgin commented Sep 20, 2019

Tested on 2.3.2

When I restart a script that uses a specific file (not generating a unique file name for each run) opened in "w+" mode, the file doesn't get initially truncated to a zero-length file like it's supposed to. If I manually delete it, it won't get recreated no matter how many times I restart the script, instead the file writes fail silently with no indication anything went wrong until I go to check on the file and it's not there. If I restart bizhawk then it will work.

I believe this is due to the file locks from the initial run of the script not getting cleaned up if the script is interrupted before calling io.close(), interfering with later runs of the script trying to open the file.

This seems very closely related to #455, except it happened to me when a script was stopped and restarted, not when the whole lua console was closed. Since that bug looks like it was fixed by adding a line of code to the function that gets called when the window is closed (e281950), it's possible this is the exact same bug which was not sufficiently fixed for all cases. So it might make more sense to close this ticket and reopen that one, but IDRK.

@nlburgin nlburgin changed the title Lua file IO bug Lua apparently failing to clean up file handles when script is abnormally terminated. Sep 20, 2019
@nlburgin nlburgin changed the title Lua apparently failing to clean up file handles when script is abnormally terminated. Lua failing to clean up file handles when script is stopped with a file open Sep 20, 2019
@YoshiRulz
Copy link
Member

see also #995 — try Config > Customize... > Advanced > Lua+LuaInterface

@YoshiRulz YoshiRulz added the re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console) label Sep 21, 2019
@nlburgin
Copy link
Author

nlburgin commented Sep 22, 2019

Hm... I tried LuaInterface a while back, but I haven't tested it for this specific issue.

I had used it for a while but eventually turned it back off because I seemed to be running into the same memory leaks that caused KopiLua to be added as default in the first place. It didn't really seem especially prone to crashing per se, but that's only because my Windows "page file" (what Linux would call the swap) is big enough to turn memory issues into disk thrashing slowdowns instead of crashes.

Still, I should probably check to see if this bug is reproducible under that engine.

EDIT: Yeah, I just switched back to LuaInterface and it seems like this bug doesn't exist there. I was able to remove and restart a script without losing the ability to open its log file.

@nlburgin nlburgin changed the title Lua failing to clean up file handles when script is stopped with a file open KopiLua engine failing to clean up file handles when script is stopped with a file open Sep 23, 2019
@YoshiRulz
Copy link
Member

I'm going to leave this duplicate open as a reminder to at least add a warning for the next release, if not remove NLua+KopiLua. Also move the engine selection to LuaConsole.

@YoshiRulz YoshiRulz added this to the 2.4 milestone Sep 23, 2019
@YoshiRulz YoshiRulz changed the title KopiLua engine failing to clean up file handles when script is stopped with a file open KopiLua IO should print a warning on first use Sep 23, 2019
@vadosnaprimer
Copy link
Contributor

Defaulting to NLua makes absolutely no sense at this point.

@adelikat
Copy link
Contributor

we default to luaitnerface now

@YoshiRulz YoshiRulz removed this from the 2.5 milestone Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console)
Projects
None yet
Development

No branches or pull requests

4 participants