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

[LUA] File handles are not released #455

Closed
tomzx opened this issue Jul 3, 2015 · 4 comments
Closed

[LUA] File handles are not released #455

tomzx opened this issue Jul 3, 2015 · 4 comments
Labels
Bug (GoogleCode) Grandfathered label from GoogleCode. Use the other bug labels. re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console)

Comments

@tomzx
Copy link
Contributor

tomzx commented Jul 3, 2015

I'm not sure if this is something we can really do anything about, but if a script opens a file using io.open and the emulator is paused, the lua console closed, then the file handle is not released and thus one needs to exit EmuHawk in order to release the file handle.

@tomzx tomzx added the Bug (GoogleCode) Grandfathered label from GoogleCode. Use the other bug labels. label Jul 3, 2015
@zeromus
Copy link
Contributor

zeromus commented Jul 3, 2015

If the lua console is closed, the vm should be destroyed. I would expect the handle to get GC'd and the file closed.
Elsewhere on the web: "The documentation states that the file is closed when the handle is garbage collected after going out of scope"
Which documentation?
Is the VM destroyed and nulled?
Does the method used for VM destroying actually result in things getting GC'd?

@Masterjun3
Copy link
Contributor

Which documentation?

The official one.

Elsewhere on the web: "The documentation states that the file is closed when the handle is garbage collected after going out of scope"

https://www.lua.org/manual/5.1/manual.html#pdf-file:close

Does the method used for VM destroying actually result in things getting GC'd?

Probably?

@zeromus
Copy link
Contributor

zeromus commented Sep 22, 2016

EmuLuaLibrary's Close() method clobbers the _lua without calling Close() on it.
This is positively wrong.

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

nlburgin commented Sep 20, 2019

This bug is still happening to me 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 was going to file a new bug but the issue tracker suggested it might be a duplicate of this one, and after looking at it I think it was right, I think it's this exact bug popping up again after everyone thought it was dead. Please re-open.

It seems like the bug fix didn't work perfectly or else it's regressed since then. Maybe the lua engine switch from #867 has something to do with it? IDRK.

EDIT: Actually the original bug only reported this happening when the whole lua console is closed. For me, it happens when "refreshing" or removing and re-importing a particular script, not necessarily closing the whole lua console. I'm going to make a new report after all, though I strongly suspect it might be related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug (GoogleCode) Grandfathered label from GoogleCode. Use the other bug labels. re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console)
Projects
None yet
Development

No branches or pull requests

5 participants