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

Fatal Error when renderdoc is installed #197

Closed
Celsiusss opened this issue Dec 2, 2023 · 4 comments
Closed

Fatal Error when renderdoc is installed #197

Celsiusss opened this issue Dec 2, 2023 · 4 comments
Labels
priority: normal this issue does not break any critical functionality - it must be adressed, but not immediately status: confirmed this issue is reproducible or otherwise confirmed to exist status: scheduled the resolution of this issue is scheduled for the next release type: bug this issue breaks or otherwise adversely affects functionality

Comments

@Celsiusss
Copy link

Celsiusss commented Dec 2, 2023

From a clean starting template generated by fabric. No additional code added.

# Dependencies
fabric_version=0.91.1+1.20.2
owo_version=0.11.3+1.20.2

Loading into a singleplayer world crashes the JVM.

I have renderdoc 1.29 installed on my Arch Linux system. Uninstalling it resolved the issue.
I have not supplied the LD_PRELOAD env variable as I did not intend to enable the renderdoc integration.

crash log
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f506a9a0edd, pid=43637, tid=43638
#
# JRE version: OpenJDK Runtime Environment Zulu17.46+19-CA (17.0.9+8) (build 17.0.9+8-LTS)
# Java VM: OpenJDK 64-Bit Server VM Zulu17.46+19-CA (17.0.9+8-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libc.so.6+0x15aedd]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/daniel/dev/sandbox/crystalhollowsmapmod/run/core.43637)
#
# If you would like to submit a bug report, please visit:
#   http://www.azul.com/support/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

--------------- S U M M A R Y ------------

Command Line: -Dfabric.dli.config=/home/daniel/dev/sandbox/crystalhollowsmapmod/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant net.fabricmc.devlaunchinjector.Main

Host: AMD Ryzen 9 3900X 12-Core Processor, 32 cores, 31G, Arch Linux
Time: Sat Dec 2 15:08:41 2023 CET elapsed time: 18.847331 seconds (0d 0h 0m 18s)

--------------- T H R E A D ---------------

Current thread (0x00007f506402bc00): JavaThread "Render thread" [_thread_in_native, id=43638, stack(0x00007f5069213000,0x00007f5069313000)]

Stack: [0x00007f5069213000,0x00007f5069313000], sp=0x00007f50693100c8, free space=1012k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libc.so.6+0x15aedd]
C [jna1593287075366201177.tmp+0xc3b7] Java_com_sun_jna_Native_open+0x87
j com.sun.jna.Native.open(Ljava/lang/String;I)J+0
j com.sun.jna.NativeLibrary.loadLibrary(Ljava/lang/String;Ljava/util/Map;)Lcom/sun/jna/NativeLibrary;+250
j com.sun.jna.NativeLibrary.getInstance(Ljava/lang/String;Ljava/util/Map;)Lcom/sun/jna/NativeLibrary;+154
j com.sun.jna.Library$Handler.(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)V+205
j com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)Lcom/sun/jna/Library;+68
j io.wispforest.owo.renderdoc.RenderDoc.()V+66
v ~StubRoutines::call_stub
V [libjvm.so+0x81bf52] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x312
V [libjvm.so+0x7fb98c] InstanceKlass::call_class_initializer(JavaThread*)+0x1ec
V [libjvm.so+0x7fddc4] InstanceKlass::initialize_impl(JavaThread*)+0x534
V [libjvm.so+0xa46007] LinkResolver::resolve_static_call(CallInfo&, LinkInfo const&, bool, JavaThread*)+0x87
V [libjvm.so+0xa48e63] LinkResolver::resolve_invoke(CallInfo&, Handle, constantPoolHandle const&, int, Bytecodes::Code, JavaThread*)+0x213
V [libjvm.so+0x816a60] InterpreterRuntime::resolve_invoke(JavaThread*, Bytecodes::Code)+0x180
V [libjvm.so+0x817015] InterpreterRuntime::resolve_from_cache(JavaThread*, Bytecodes::Code)+0x105
j io.wispforest.owo.command.debug.OwoDebugCommands$Client.lambda$register$5(Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+59
j io.wispforest.owo.command.debug.OwoDebugCommands$Client$$Lambda$4358+0x00007f4fdca41000.register(Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+2
j net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback.lambda$static$0([Lnet/fabricmc/fabric/api/client/command/v2/ClientCommandRegistrationCallback;Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+26
j net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback$$Lambda$4355+0x00007f4fdca462c0.register(Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+6
j net.minecraft.client.network.ClientPlayNetworkHandler.handler$zzb000$fabric-command-api-v2$onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V+33
j net.minecraft.client.network.ClientPlayNetworkHandler.onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;)V+614
j net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(Lnet/minecraft/network/listener/ClientPlayPacketListener;)V+2
j net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(Lnet/minecraft/network/listener/PacketListener;)V+5
j net.minecraft.network.NetworkThreadUtils.method_11072(Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/Packet;)V+12
j net.minecraft.network.NetworkThreadUtils$$Lambda$8140+0x00007f4fdcf71ce0.run()V+8
J 18960 c2 net.minecraft.util.thread.ThreadExecutor.executeTask(Ljava/lang/Runnable;)V (29 bytes) @ 0x00007f5055cc6364 [0x00007f5055cc6320+0x0000000000000044]
J 18810 c1 net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(Ljava/lang/Runnable;)V (42 bytes) @ 0x00007f504ea725c4 [0x00007f504ea72540+0x0000000000000084]
J 18766 c2 net.minecraft.util.thread.ThreadExecutor.runTask()Z (54 bytes) @ 0x00007f5055c98fc4 [0x00007f5055c98c40+0x0000000000000384]
J 14388 c1 net.minecraft.client.MinecraftClient.render(Z)V (1119 bytes) @ 0x00007f504e520a14 [0x00007f504e51fbe0+0x0000000000000e34]
j net.minecraft.client.MinecraftClient.run()V+121
j net.minecraft.client.main.Main.main([Ljava/lang/String;)V+1557
j java.lang.invoke.LambdaForm$DMH+0x00007f4fdc260000.invokeStaticInit(Ljava/lang/Object;Ljava/lang/Object;)V+10 java.base@17.0.9
j java.lang.invoke.LambdaForm$MH+0x00007f4fdc001800.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V+19 java.base@17.0.9
j net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(Ljava/lang/ClassLoader;)V+74
j net.fabricmc.loader.impl.launch.knot.Knot.launch([Ljava/lang/String;Lnet/fabricmc/api/EnvType;)V+40
j net.fabricmc.loader.impl.launch.knot.KnotClient.main([Ljava/lang/String;)V+4
j java.lang.invoke.LambdaForm$DMH+0x00007f4fdc001000.invokeStatic(Ljava/lang/Object;Ljava/lang/Object;)V+10 java.base@17.0.9
j java.lang.invoke.LambdaForm$MH+0x00007f4fdc001800.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V+19 java.base@17.0.9
j net.fabricmc.devlaunchinjector.Main.main([Ljava/lang/String;)V+307
v ~StubRoutines::call_stub
V [libjvm.so+0x81bf52] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x312
V [libjvm.so+0x8a9c31] jni_invoke_static(JNIEnv_, JavaValue, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, JavaThread*) [clone .isra.186] [clone .constprop.443]+0x351
V [libjvm.so+0x8ac525] jni_CallStaticVoidMethod+0x145
C [libjli.so+0x4809] JavaMain+0xd19
C [libjli.so+0x84e9] ThreadJavaMain+0x9

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Native.open(Ljava/lang/String;I)J+0
j com.sun.jna.NativeLibrary.loadLibrary(Ljava/lang/String;Ljava/util/Map;)Lcom/sun/jna/NativeLibrary;+250
j com.sun.jna.NativeLibrary.getInstance(Ljava/lang/String;Ljava/util/Map;)Lcom/sun/jna/NativeLibrary;+154
j com.sun.jna.Library$Handler.(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)V+205
j com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)Lcom/sun/jna/Library;+68
j io.wispforest.owo.renderdoc.RenderDoc.()V+66
v ~StubRoutines::call_stub
j io.wispforest.owo.command.debug.OwoDebugCommands$Client.lambda$register$5(Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+59
j io.wispforest.owo.command.debug.OwoDebugCommands$Client$$Lambda$4358+0x00007f4fdca41000.register(Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+2
j net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback.lambda$static$0([Lnet/fabricmc/fabric/api/client/command/v2/ClientCommandRegistrationCallback;Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+26
j net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback$$Lambda$4355+0x00007f4fdca462c0.register(Lcom/mojang/brigadier/CommandDispatcher;Lnet/minecraft/command/CommandRegistryAccess;)V+6
j net.minecraft.client.network.ClientPlayNetworkHandler.handler$zzb000$fabric-command-api-v2$onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V+33
j net.minecraft.client.network.ClientPlayNetworkHandler.onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;)V+614
j net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(Lnet/minecraft/network/listener/ClientPlayPacketListener;)V+2
j net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(Lnet/minecraft/network/listener/PacketListener;)V+5
j net.minecraft.network.NetworkThreadUtils.method_11072(Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/Packet;)V+12
j net.minecraft.network.NetworkThreadUtils$$Lambda$8140+0x00007f4fdcf71ce0.run()V+8
J 18960 c2 net.minecraft.util.thread.ThreadExecutor.executeTask(Ljava/lang/Runnable;)V (29 bytes) @ 0x00007f5055cc6364 [0x00007f5055cc6320+0x0000000000000044]
J 18810 c1 net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(Ljava/lang/Runnable;)V (42 bytes) @ 0x00007f504ea725c4 [0x00007f504ea72540+0x0000000000000084]
J 18766 c2 net.minecraft.util.thread.ThreadExecutor.runTask()Z (54 bytes) @ 0x00007f5055c98fc4 [0x00007f5055c98c40+0x0000000000000384]
J 14388 c1 net.minecraft.client.MinecraftClient.render(Z)V (1119 bytes) @ 0x00007f504e520a14 [0x00007f504e51fbe0+0x0000000000000e34]
j net.minecraft.client.MinecraftClient.run()V+121
j net.minecraft.client.main.Main.main([Ljava/lang/String;)V+1557
j java.lang.invoke.LambdaForm$DMH+0x00007f4fdc260000.invokeStaticInit(Ljava/lang/Object;Ljava/lang/Object;)V+10 java.base@17.0.9
j java.lang.invoke.LambdaForm$MH+0x00007f4fdc001800.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V+19 java.base@17.0.9
j net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(Ljava/lang/ClassLoader;)V+74
j net.fabricmc.loader.impl.launch.knot.Knot.launch([Ljava/lang/String;Lnet/fabricmc/api/EnvType;)V+40
j net.fabricmc.loader.impl.launch.knot.KnotClient.main([Ljava/lang/String;)V+4
j java.lang.invoke.LambdaForm$DMH+0x00007f4fdc001000.invokeStatic(Ljava/lang/Object;Ljava/lang/Object;)V+10 java.base@17.0.9
j java.lang.invoke.LambdaForm$MH+0x00007f4fdc001800.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V+19 java.base@17.0.9
j net.fabricmc.devlaunchinjector.Main.main([Ljava/lang/String;)V+307
v ~StubRoutines::call_stub

@gliscowo gliscowo added type: bug this issue breaks or otherwise adversely affects functionality priority: normal this issue does not break any critical functionality - it must be adressed, but not immediately status: investigating this issue is not easily reproducible or fixable, the cause is being investigated labels Dec 4, 2023
@gliscowo
Copy link
Member

gliscowo commented Dec 4, 2023

To start off the investigation here, have you verified that your systemwide RenderDoc installation worksp properly? In our tests we've only been able to replicate this behavior with a broken version of librenderdoc

@Celsiusss
Copy link
Author

Celsiusss commented Dec 5, 2023

I tested it using qrenderdoc and it works fine, but I have to launch the program with some additional env vars for it to run under Wayland

WAYLAND_DISPLAY= QT_QPA_PLATFORM=xcb qrenderdoc

@gliscowo gliscowo added status: scheduled the resolution of this issue is scheduled for the next release status: confirmed this issue is reproducible or otherwise confirmed to exist and removed status: investigating this issue is not easily reproducible or fixable, the cause is being investigated labels Dec 9, 2023
@gliscowo
Copy link
Member

gliscowo commented Dec 9, 2023

So, after doing some further investigation we've narrowed this issue to a bug in JNA (the library used to bind librenderdoc).

In order to only bind to the API if librenderdoc is already loaded into the process when the game starts, we request the library to be opened with the RTLD_NOLOAD flag. This flag causes dlopen(...) to return a null pointer if the library is not already opened, but without encountering an error condition (since this is what the caller requested). JNA however assumes that dlopen(...) returning a null pointer always indicates an error and tries to read the error message which will be a null pointer since the last call to dlopen(...) succeeded and thus causes a segmentation fault in libc's strlen

I've now implemented a fix for this f2f021b by first loading the library using LWJGL's direct binding to dlopen(...) before passing the request to JNA to circumvent this bug. This will be available as part of owo's first 1.20.3 release and I'll look into releasing a quick patch for older game versions as well

Cheers

@gliscowo gliscowo closed this as completed Dec 9, 2023
@Celsiusss
Copy link
Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: normal this issue does not break any critical functionality - it must be adressed, but not immediately status: confirmed this issue is reproducible or otherwise confirmed to exist status: scheduled the resolution of this issue is scheduled for the next release type: bug this issue breaks or otherwise adversely affects functionality
Projects
None yet
Development

No branches or pull requests

2 participants