-
Notifications
You must be signed in to change notification settings - Fork 380
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 in Mono megathread #2951
Comments
On a fresh build of Bizhawk, upon opening the Lua editor, bizhawk crashes with terminal output
and then a bunch of thread dumps. I don't know if this is a configuration error on my part, but if it isn't, and you'd like more details, I can open a new issue. |
The actual error message:
Looks like this was fixed by mono/mono#19434, and all Mono releases from 6.12.0.151 are unaffected.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
About the crash on mono < 6.12.151, Is there any other workaround besides deleting the config every time?
Seems more informative than the backtraces I was getting with the system-wide version of Mono, but hm. |
If you'd care to join me down the rabbit-hole, I've added Nix build scripts to the repo for both EmuHawk and the required version of Mono. That build is definitely immune from the crash. Unfortunately, I had to uninstall the older Mono and have broken my host OS such that I can't reinstall it, so I can't help look for another workaround. |
Nix, huh? I've been meaning to look into it, but won't have time until the weekend. That said, I'll give it a spin then, maybe I can set up a builder VM. |
The necessary mono versions (6.12.0.151+) aren't available yet in the ubuntu package repos either. Never used nix before now, but I took a stab at it. After installing nix, I cloned the bizhawk repo, and ran |
Hmm I thought it might be unstable because it includes |
That seemed to get a little farther, but now there's another issue. CLI output here. And the full log mentioned in the error. |
That's the same problem GitLab CI had on fresh clones, which I fixed by building edit: fixed in 9448e56 |
Please post the results of that conversation if something comes up, I'm interested in setting up in a couple days. |
By the |
Oh, I meant to say it ran (and exited) once, generated a config and then ran again fine, meaning the crash doesn't happen anymore with this method. My bad. This builds works perfectly as far as my basic tests of the Lua interface go. |
I've been trying to get this working with no success for a few days now. I've tried on two seperate systems, one running Fedora and one running Arch. System mono provides similar results to @magpie514, with the same mono regression (crash on subsequent runs of the Lua Console) Building mono from source (from latest master) exhibits similar behavior, though it creates an unhandled exception instead: Mono exception output Running it through Nix has been unsuccessful on both Arch and Fedora, which seem to be attached to Nix: LibGL/driver failures on Fedora, and build failures on Arch. I don't feel like fighting with Nix, at least not right now. Please let me know if any additional information is necessary. |
I have a patch for debugging that NRE as another user had reported it (probably want to manually copy diff): https://gitlab.com/TASVideos/BizHawk/-/commit/8798cbcc7dc99b2270730fd4ff530380a268451d I'm very interested in debugging Nix failures though. You can DM me the logs at YoshiRulz#4472 on Discord or wherever. |
it turns out that this is the same error that @magpie514 has, pretty much exactly. This still happens on the latest git release & the latest nightly build from the official repos which is mono 6.13.0 and by most accounts should be a later version then the version of mono with this bug. Even using the Preview build, which is 6.12.0.158 exhibits the same issue. |
@TauAkiou I solved that with the Nix method, but I honestly can't tell why it's failing for you. |
The issue with Nix on Arch is related to it not finding autoconf or libtool in the Nix environment, which more refers to a problem with setup on Arch or, more likely, me not knowing how Nix works particularly well and not setting it up properly. What's more confusing, though is that it works perfectly fine on Fedora, but Fedora doesn't have OpenGL configured properly, and that's a separate issue. I'm more confused as to why BizHawk is exhibiting the same problem despite being run on versions that shouldn't be vulnerable to the bug. My guess is that somehow, the metadata fixes either aren't working or aren't applied in these builds for some bizarre reason. |
On Arch, are you using On Fedora, pull (to 54e7bf2) and try again. I borrowed a Fedora machine and added the missing paths to the wrapper script. edit: btw we resolved this (mostly) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I've had issues with a script using luasockets (Specifically, it fails to find the library). Is that a known issue? Still, thanks for getting this far already :D |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I'm new to bizhawk, and pretty unfamiliar with lua in general. I've been messing with the co-op lua script, and I've managed to get to the point of it trying to load luasocket which fails with this error: NLua.Exceptions.LuaScriptException: error loading module 'socket.core' from file '/usr/lib64/lua/5.4/socket/core.so': Google seems to be suggesting this has something to do with compile flags bizhawk was compiled with, but I'm not sure. I do know I can use luasocket through the lua interpreter. I'm on gentoo, with mono-6.12.0.122. |
On Linux, the Lua used will be the system lua (since 339915c / 2.9 rc3), so it would be the fault of the package manager here if the symbol was truly missing. However, we do use that function internally, so if it was missing it would crash sooner. Perhaps there's something weird with that .so where it can't properly find the lua used? EDIT: Searching through the internet seems to also point to possibly lua sockets being compiled with flags which give it a static linking requirement for liblua due to not actually explicitly linking against liblua, which would not work for us (we have to dynamically link), so that might also be an issue. |
Hmm, looking at the files belonging to the lua package I'm only seeing a .so library, no .a. So I'm not sure it's possible that sockets statically linked? Regardless, I'm willing to try adding whatever link flags are necessary to ensure it compiles correctly, just not sure what those are. I've been messing with strace, and I can see bizhawk opens and loads dlls/NLua.dll to memory, twice. Then, when I open the lua console, it loads /usr/lib64/liblua5.4.so to memory. Can you explain what part NLua.dll is playing here? Continuing with strace, if I tell bizhawk to load the co-op script, it reads in related .lua files and eventually comes to /usr/lib64/lua/5.4/socket/core.so, which it maps to memory and then immediately unmaps and writes out the error. If I load the co-op script just with the interpreter on the command line, I see /usr/lib64/liblua5.4.so loaded to memory, the co-op .lua files are read, and /usr/lib64/lua/5.4/socket/core.so is mapped in the same fashion as bizhawk did. But then it continues on loading from that point until hitting a predictable error relating to missing bizhawk lua API. So it certainly seems that the system .so files know how to work together, and bizhawk does load them, but I guess it must be doing something different. |
Is |
No change when run that way, and LD_LIBRARY_PATH is unset in my shell. But I did have to modify line 11 of EmuHawkMono.sh to make it gentoo-aware, bizhawk wouldn't start otherwise. Before: After: |
Scratch that, it would start but crash when running a game. |
Add in |
Alright, now I'm getting somewhere. I confirmed that link flag was missing by default when the libraries are linked, and confirmed that after adding the flag the output of ldd shows they now link to my system's /usr/lib64/liblua5.4.so.0. Running the co-op script in bizhawk now gets further, the error regarding luasocket is gone, and I had to adjust some of the script that was written with windows in mind. But I have a different error now, with the game script I'm trying to load in the co-op script. More specifically this is the offending line and error generated:
I'm not sure how to interpret this, is there any chance this will be implemented any time soon? Is there a better/other way the game script could be doing what it's trying to do? I do see that memory.readbyterange is deprecated, but I'm not sure if that's related. |
"NullHawk" is the dummy "core" when no game is loaded. Load a game :P |
I'm sure most of your problems would go away if you (or the script's author) used our provided socket library. |
OH. I suppose that makes sense XD Running the game does indeed seem to work.
That sounds great, though it's not exactly my project. The co-op script is here, and at the moment I'm mainly exploring if it's possible to even run on linux. I'm more interested specifically in Zelda Oracles randomizers, and I'd love to contribute at some point. So I'll certainly keep the provided socket library in mind! |
Now we've ruled out our Lua host as the cause of your issue, we're done here. Enjoy 2.9 everyone. |
A work-around is to load the system lua instead of depending on the EXE exporting the correct symbols: This is a very fragile thing to do, so I'm not certain it's not gonna break stuff. |
The lua host can't statically link lua due to the fact this is c# not some c/c++/whatever language. So we have to dynamically link. And that seemingly means the symbols aren't available for other modules. However, looking at the dlopen page seems to indicate a solution here: https://man7.org/linux/man-pages/man3/dlopen.3.html
We probably just need to set that flag when it's opened so modules will see the other symbols. |
Something to note of ^, I originally intended to use RTLD_NOLOAD, but that isn't part of POSIX and thus not actually available for all Linux OSes (at the very least Debian 11 did not support it). |
are the gitlab builds nightly builds? so in ~14 hours we can fetch a dev build from gitlab CI/CD? |
That's right. |
Tested the nightly and works with our socket.so on my machine |
Note: 2.9 has a new Lua engine, NLua+Lua, as the default.
If you're using 2.8 and getting a crash immediately upon opening the Lua Console like this:
...it's probably because the Lua engine defaults to "Lua+LuaInterface", which usually crashes (the environment required for it to not crash is unclear). Change it to "NLua+KopiLua" in
Config
>Customize...
>Advanced
,or just grab a dev build.The text was updated successfully, but these errors were encountered: