space-wizards / RobustToolbox

Robust multiplayer game engine, used by Space Station 14
https://spacestation14.io
Other
551 stars 410 forks source link

I cant play midi #2563

Closed Nuxssss closed 2 years ago

Nuxssss commented 2 years ago

[ERRO] runtime: Caught exception in "Async Queued Callback" System.DllNotFoundException: Unable to load shared library '/home/nuxs/ss13/bin/loader/libswnfd.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: /usr/lib/libbz2.so.1.0: undefined symbol: BZ2_hbMakeCodeLengths at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError) at SS14.Loader.Program.LoadContextOnResolvingUnmanaged(Assembly assembly, String unmanaged) in /home/runner/work/SS14.Launcher/SS14.Launcher/SS14.Loader/Program.cs:line 39 at System.Runtime.Loader.AssemblyLoadContext.GetResolvedUnmanagedDll(Assembly assembly, String unmanagedDllName) at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDllUsingEvent(String unmanagedDllName, Assembly assembly, IntPtr gchManagedAssemblyLoadContext) at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError) at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable1 searchPath, Boolean throwOnError) at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable1 searchPath) at Robust.Client.Utility.ClientDllMap.<>c.b0_0(String name, Assembly assembly, Nullable`1 path) in /home/runner/work/RobustToolbox/RobustToolbox/Robust.Client/Utility/ClientDllMap.cs:line 20 at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags) at Robust.Client.UserInterface.FileDialogManager.sw_NFD_OpenDialog(Byte filterList, Byte defaultPath, Byte** outPath) at Robust.Client.UserInterface.FileDialogManager.<>c__DisplayClass8_0.b0() in /home/runner/work/RobustToolbox/RobustToolbox/Robust.Client/UserInterface/FileDialogManager.cs:line 95 at Robust.Client.UserInterface.FileDialogManager.<>c__DisplayClass11_0.b0() in /home/runner/work/RobustToolbox/RobustToolbox/Robust.Client/UserInterface/FileDialogManager.cs:line 188 at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Robust.Client.UserInterface.FileDialogManager.GetOpenFileName(FileDialogFilters filters) in /home/runner/work/RobustToolbox/RobustToolbox/Robust.Client/UserInterface/FileDialogManager.cs:line 51 at Robust.Client.UserInterface.FileDialogManager.OpenFile(FileDialogFilters filters) in /home/runner/work/RobustToolbox/RobustToolbox/Robust.Client/UserInterface/FileDialogManager.cs:line 35 at Content.Client.Instruments.UI.InstrumentMenu.MidiFileButtonOnOnPressed(ButtonEventArgs obj) in /home/runner/work/space-station-14/space-station-14/Content.Client/Instruments/UI/InstrumentMenu.xaml.cs:line 80 at System.Threading.Tasks.Task.<>c.b127_0(Object state) at Robust.Shared.Asynchronous.RobustSynchronizationContext.ProcessPendingTasks() in /home/runner/work/RobustToolbox/RobustToolbox/Robust.Shared/Asynchronous/RobustSynchronizationContext.cs:line 57

DubiousDoggo commented 2 years ago

Could you give a bit more info on this? Steps to reproduce? What OS are you running?

gradientvera commented 2 years ago

Engine issue, transferring

PJB3005 commented 2 years ago

The problem seems to be in bzip2 or something, which we don't even have as a direct dependency. Can you run something like lddtree on /home/nuxs/ss13/bin/loader/libswnfd.so?

PJB3005 commented 2 years ago

I am also seconding that I am gonna need information on your Linux distro/version at the very least.

PJB3005 commented 2 years ago

For some reason (and god this has been a rabbit hole to debug), initializing ALSA (which FluidSynth does when the SS14 instrument menu opens) causes bzip2 to unload from the process.... I'm investigating further and as part of giving up am basically gonna send what I've found to the arch mailing list hoping somebody there is smart enough to figure this crap out.

PJB3005 commented 2 years ago

I cannot believe I am saying this but it appears to be a bug in glibc 2.35 (which released at the start of February). The changelog mention a new dependency resolver algorithm, and if you disable it via GLIBC_TUNABLES=glibc.rtld.dynamic_sort=1, the bug goes away. I also made a tiny test program that replicates this:

#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>

void main()
{
    printf("honk!\n");
    void* lib;

    lib = dlopen("libfreetype.so.6", RTLD_NOW);
    printf("freetype: %llX\n", lib);

    lib = dlopen("libfluidsynth.so.3", RTLD_NOW);
    printf("fluidsynth: %llX\n", lib);

    // Using dlsym so we don't link directly against fluidsynth and it's dynamically loaded.
    // Function signature matches pretty much.
    void* (*new_fluid_settings_fp)() = dlsym(lib, "new_fluid_settings");

    // Yes, fluidsynth initializes all audio drivers by just CREATING the settings. 
    // Meaning we literally can't stop it from initializing ALSA/PortAudio as a quick workaround.
    void* settings = new_fluid_settings_fp();

    printf("Initialized fluidsynth!\n");

    // GTK3 will fail to load if loaded after fluidsynth initialized.
    lib = dlopen("libgtk-3.so", RTLD_NOW);
    printf("GTK3: %llX\n", lib);

    return;
}

Vera also confirmed this tunable fixes the problem she was having where her client was unable to start consistently.

PJB3005 commented 2 years ago

https://bugs.archlinux.org/task/73967 bug filed with arch linux, I'll file it with glibc as soon as they inevitably tell me it's an upstream issue.

PJB3005 commented 2 years ago

Another user report on the steam forums this time: https://steamcommunity.com/app/1482520/discussions/0/5561388294329160548/?tscn=1647015094

PJB3005 commented 2 years ago

Latest version of the launcher specifies the glibc tunable now, so this should no longer happen.