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

Trying to load DiscordRPC native library even if module is disabled - causing MC to crash #187

Closed
graemeg opened this issue Nov 14, 2021 · 14 comments
Labels
bug Something isn't working

Comments

@graemeg
Copy link

graemeg commented Nov 14, 2021

Describe the bug
I was trying to use the latest official Lambda release v2.07.01 on my FreeBSD system but it simply crashes MC. As Minecraft with Forge runs fine on my system. I tried Impact, ForgeHax and the Seppuku mods and they work just fine. Seems Lambda is trying to load a native library for Discord integration, even though I have the module disabled. This doesn't seem right.

To Reproduce

  1. Use FreeBSD 12.2 system
  2. Used MultiMC to set up a new 1.12.2 instance.
  3. Enabled Forge
  4. Add official Lamba Client
  5. Try and launch MC and it will crash due to missing discord .so native library

Expected behaviour
I double checked in the default.json file, and I have the DiscordRPC disabled, but it seems Lambda is still trying to load some or other discord library regardless of enabled: false setting.

    {
      "name": "DiscordRPC",
      "settings": {
        "bind": "None",
        "enabled": false,
        "visible": true,
        "default": false,
        "priority_in_gui": 0,
        "clicks": 0,
        "line_1_left": "VERSION",
        "line_1_right": "USERNAME",
        "line_2_left": "DIMENSION",
        "line_2_right": "HEALTH",
        "coords_confirm": false
      }

Debug info

Time: 11/14/21 7:13 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Lambda (lambda)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.lambda.client.module.modules.misc.DiscordRPC
	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
	at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
	at java.lang.reflect.Field.get(Field.java:393)
	at com.lambda.commons.utils.ClassUtils.getInstance(ClassUtils.kt:27)
	at com.lambda.client.module.ModuleManager.load0(ModuleManager.kt:43)
	at com.lambda.client.module.ModuleManager.load0(ModuleManager.kt:16)
	at com.lambda.client.AsyncLoader$DefaultImpls.load(Loader.kt:49)
	at com.lambda.client.module.ModuleManager.load(ModuleManager.kt:16)
	at com.lambda.client.LoaderWrapper$loadAll$1.invokeSuspend(Loader.kt:32)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at com.lambda.client.LoaderWrapper.loadAll(Loader.kt:31)
	at com.lambda.client.LambdaMod.init(LambdaMod.kt:61)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:749)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535)
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)
	at net.minecraft.client.main.Main.main(SourceFile:123)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196)
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
	at org.multimc.EntryPoint.listen(EntryPoint.java:143)
	at org.multimc.EntryPoint.main(EntryPoint.java:34)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: FreeBSD (amd64) version 12.2-RELEASE-p7
	Java Version: 1.8.0_302, OpenJDK BSD Porting Team
	Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), OpenJDK BSD Porting Team
	Memory: 2435216680 bytes (2322 MB) / 2732589056 bytes (2606 MB) up to 3818913792 bytes (3642 MB)
	JVM Flags: 2 total; -Xms2048m -Xmx4096m
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2854 5 mods loaded, 5 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	| State | ID        | Version      | Source                                  | Signature                                |
	|:----- |:--------- |:------------ |:--------------------------------------- |:---------------------------------------- |
	| LCHI  | minecraft | 1.12.2       | minecraft.jar                           | None                                     |
	| LCHI  | mcp       | 9.42         | minecraft.jar                           | None                                     |
	| LCHI  | FML       | 8.0.99.99    | forge-1.12.2-14.23.5.2854-universal.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 |
	| LCHI  | forge     | 14.23.5.2854 | forge-1.12.2-14.23.5.2854-universal.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 |
	| LCHE  | lambda    | 2.07.01      | lambda-2.07.01-mc1.12.2.jar             | None                                     |

	Loaded coremods (and transformers): 
LambdaMixinLoader (lambda-2.07.01-mc1.12.2.jar)

Additional context / media
Let me know if there is anything else you need or debug builds I can test. I don't mind.

@graemeg graemeg added the bug Something isn't working label Nov 14, 2021
@czho
Copy link
Member

czho commented Nov 14, 2021

This is one of those bugs that exists just because we didn't test it on freebsd yet, ill see what I can to get it fixed. Alot of us run linux so I know how it feels to have just random shit not be supported for basically no reason.

@graemeg
Copy link
Author

graemeg commented Nov 14, 2021

Thank you very much. As I mentioned, if you need any assistance it testing, I'm more than happy to help where I can.

@graemeg
Copy link
Author

graemeg commented Nov 14, 2021

Just to add. Renaming the DiscordRPC.kt (so it doesn't compile), commenting two lines in Capes.kt and removing the jarLibs Discord line in build.gradle (just for good measure)... When I then build the Lambda client, it runs just fine under FreeBSD.

@3jq
Copy link

3jq commented Nov 16, 2021

Sadly, discord rpc library is currently not supported for freebsd. Maybe this issue will be solved in future.

@graemeg
Copy link
Author

graemeg commented Nov 16, 2021

I honestly don't care about the DiscordRPC module (I don't need it), but if Lambda could be modified so it doesn't try and load anything Discord related, when the module is disabled, that should fix the issue. At the moment it tries to initialize the discord library, even though the DiscordRPC module is disabled - which doesn't seem right.

@NepNep21
Copy link
Contributor

Can you send the full logs/latest.log file with https://paste.ee?

@graemeg
Copy link
Author

graemeg commented Nov 17, 2021

Sure, here is the link: https://paste.ee/p/mycnW
Log has been attached too.

latest.log

@NepNep21
Copy link
Contributor

I don't know how freebsd works but you can try installing JNA through the package manager (make sure the jar containing the native is in the game's classpath), if that doesn't work maybe you can try adding this manually https://github.com/java-native-access/jna/blob/master/lib/native/freebsd-x86-64.jar

It's not an ideal solution, and i'll see if i can get it to at least not crash on launch later, but this could be a fix to be able to use rpc

@NepNep21
Copy link
Contributor

I'm not sure how i missed that, but my changes to discord rpc happened after the latest release, can you test if the latest commit with no modifications works even without my previous comment? If it doesn't i will set up lazy native initialization so that people who don't want to separately install JNA can still use lambda (though without rpc)

@graemeg
Copy link
Author

graemeg commented Nov 28, 2021

I build and ran the latest master and plugins branches (I did the latter because I saw it had more recent commits). In both cases Lambda fails to start up under FreeBSD. I think lazy loading would be the best way to go.

@NepNep21
Copy link
Contributor

Please try this version, if it works i will make a PR https://github.com/NepNep21/lambda/tree/lazy-rpc

@NepNep21
Copy link
Contributor

NepNep21 commented Dec 9, 2021

Sorry if i'm being annoying but it has been a while, have you tested it yet? does it work?

@huddy987
Copy link
Contributor

bump, @graemeg can you please test @NepNep21's change

@graemeg
Copy link
Author

graemeg commented Dec 28, 2021

Apologies for the delay, I've been away on work for a while. I've just tested the lazy-rpc branch and it seems to work well. 🥳 As expected (based on what was changed in the branch) the modules still show in the menus (as it should), and now gracefully show a error without crashing the client, when I try and manually enable the Discord module.

Screenshot of the "graceful showing an error":

shot

So yeah, this seems to work perfectly under FreeBSD now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants