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

Better Thread Dumps #843

Closed
wants to merge 1 commit into from
Closed

Conversation

Gamebuster19901
Copy link
Contributor

Thread dumps are now more complete and are in a format compatible with programs that read jstack thread dumps.

This code was not tested on this repository. However I use the code in a different project (https://github.com/WilderForge/WilderForge/blob/3d905748a018801c12c0cf764e4343decabf3ece/src/main/java/com/wildermods/wilderforge/launch/logging/CrashInfo.java#L276C1-L282C26)

Example thread dump from that project in this crash report:

---- WilderForge Crash Report----
//I never asked to be created.

Time: 2024-09-25T04:24:38.353888521Z
Description: Manually Triggered Debug Crash With Thread Dump Enabled (CTRL + ALT + SHIFT + F1 + C)

net.fabricmc.loader.impl.FormattedException: com.badlogic.gdx.utils.GdxRuntimeException: java.lang.Error: Manually Triggered Debug Crash With Thread Dump Enabled CTRL + ALT + SHIFT + F1 + C)
	at com.wildermods.provider.WildermythGameProvider.launch(WildermythGameProvider.java:389)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: java.lang.Error: Manually Triggered Debug Crash With Thread Dump Enabled CTRL + ALT + SHIFT + F1 + C)
	at com.badlogic.gdx.backends.lwjgl3.NiceLwjgl3Application.<init>(NiceLwjgl3Application.java:86)
	at com.worldwalkergames.legacy.LegacyDesktop.main(LegacyDesktop.java:151)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.wildermods.provider.WildermythGameProvider.launch(WildermythGameProvider.java:386)
	... 2 more
Caused by: java.lang.Error: Manually Triggered Debug Crash With Thread Dump Enabled CTRL + ALT + SHIFT + F1 + C)
	at com.wildermods.wilderforge.launch.WilderForge.lambda$init$0(WilderForge.java:93)
	at com.worldwalkergames.communication.observer.signals.Signal2.dispatch(Signal2.java:188)
	at com.worldwalkergames.legacy.input.GlobalInputProcessor.keyDown(GlobalInputProcessor.java:49)
	at com.badlogic.gdx.InputMultiplexer.keyDown(InputMultiplexer.java:80)
	at com.worldwalkergames.legacy.ui.FaultTolerantInputMultiplexer.keyDown(FaultTolerantInputMultiplexer.java:20)
	at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:58)
	at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:378)
	at com.badlogic.gdx.backends.lwjgl3.NiceLwjgl3Application.loop(NiceLwjgl3Application.java:104)
	at com.badlogic.gdx.backends.lwjgl3.NiceLwjgl3Application.<init>(NiceLwjgl3Application.java:80)
	... 6 more

---- Additonal Information----

--System Details--
Wildermyth Version: 1.16+550 Patch
Operating System: Linux
	Architecture: amd64
	Version: 6.8.0-40-generic
Cores: 24
Memory:
	Max heap size: 7.8 GiB
	Current heap size: 1.0 GiB
	Heap used: 458.1 MiB
	Free heap: 601.9 MiB
Graphical information:
	Vendor: 
		NVIDIA Corporation
	Card: 
		NVIDIA GeForce RTX 3080/PCIe/SSE2
	Monitors:
		Total monitors (OpenGL) 2:
			Monitor 0:
				Name: DP-0
				Resolution: 3840x2160@60hz
			Monitor 1:
				Name: HDMI-0
				Resolution: 1920x1080@75hz
		Total monitors (Java): 2
			Monitor 0
				Name: :0.0
				Resolution: 5760x2160@50hz
			Monitor 1
				Name: :0.1
				Resolution: 1920x1080@0hz
Java Version: OpenJDK Runtime Environment 21.0.4+7-Ubuntu-1ubuntu222.04 
	Vendor: Ubuntu
Uptime: PT16.814S


-- Coremod Details --
Coremods Detected: 7:

	asm 9.0
	fabricloader 0.16.3
	java 21
	mixin 0.8.7
	mixinextras 0.4.1
	wilderforge ${WILDERFORGE_VERSION}
	wildermyth 1.16+550


---- THREAD DUMP ----

"main" prio=5 Id=1 RUNNABLE
	at [email protected]/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at [email protected]/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:518)
	at [email protected]/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:506)
	at com.wildermods.wilderforge.launch.logging.CrashInfo.getThreadDump(CrashInfo.java:279)
	at com.wildermods.wilderforge.launch.logging.CrashInfo.appendThreadDump(CrashInfo.java:233)
	at com.wildermods.wilderforge.launch.logging.CrashInfo.logCrash(CrashInfo.java:92)
	at [email protected]/java.lang.invoke.LambdaForm$DMH/0x00007d21c00e0800.invokeSpecial(LambdaForm$DMH)
	at [email protected]/java.lang.invoke.LambdaForm$MH/0x00007d21c05d4400.invoke(LambdaForm$MH)
	...

"Reference Handler" daemon prio=10 Id=9 RUNNABLE
	at [email protected]/java.lang.ref.Reference.waitForReferencePendingList(Native Method)
	at [email protected]/java.lang.ref.Reference.processPendingReferences(Reference.java:246)
	at [email protected]/java.lang.ref.Reference$ReferenceHandler.run(Reference.java:208)

"Finalizer" daemon prio=8 Id=10 WAITING on java.lang.ref.NativeReferenceQueue$Lock@59aa1d1c
	at [email protected]/java.lang.Object.wait0(Native Method)
	-  waiting on java.lang.ref.NativeReferenceQueue$Lock@59aa1d1c
	at [email protected]/java.lang.Object.wait(Object.java:366)
	at [email protected]/java.lang.Object.wait(Object.java:339)
	at [email protected]/java.lang.ref.NativeReferenceQueue.await(NativeReferenceQueue.java:48)
	at [email protected]/java.lang.ref.ReferenceQueue.remove0(ReferenceQueue.java:158)
	at [email protected]/java.lang.ref.NativeReferenceQueue.remove(NativeReferenceQueue.java:89)
	at [email protected]/java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:173)

"Signal Dispatcher" daemon prio=9 Id=11 RUNNABLE

"Notification Thread" daemon prio=9 Id=26 RUNNABLE

"Common-Cleaner" daemon prio=8 Id=27 TIMED_WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@169d4aba
	at [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@169d4aba
	at [email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269)
	at [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1847)
	at [email protected]/java.lang.ref.ReferenceQueue.await(ReferenceQueue.java:71)
	at [email protected]/java.lang.ref.ReferenceQueue.remove0(ReferenceQueue.java:143)
	at [email protected]/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:218)
	at [email protected]/jdk.internal.ref.CleanerImpl.run(CleanerImpl.java:140)
	at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
	...

"Decompiler thread" daemon prio=1 Id=33 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@612bb755
	at [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@612bb755
	at [email protected]/java.util.concurrent.locks.LockSupport.park(LockSupport.java:371)
	at [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
	at [email protected]/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
	at [email protected]/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
	at [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1707)
	at [email protected]/java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:435)
	at app//org.spongepowered.asm.mixin.transformer.debug.RuntimeDecompilerAsync.run(RuntimeDecompilerAsync.java:66)
	...

"process reaper" daemon prio=10 Id=69 TIMED_WAITING on java.util.concurrent.SynchronousQueue$Transferer@6ba226cd
	at [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.SynchronousQueue$Transferer@6ba226cd
	at [email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:410)
	at [email protected]/java.util.concurrent.LinkedTransferQueue$DualNode.await(LinkedTransferQueue.java:452)
	at [email protected]/java.util.concurrent.SynchronousQueue$Transferer.xferLifo(SynchronousQueue.java:194)
	at [email protected]/java.util.concurrent.SynchronousQueue.xfer(SynchronousQueue.java:233)
	at [email protected]/java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:336)
	at [email protected]/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1069)
	at [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	...

"Java2D Disposer" daemon prio=10 Id=113 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@62e99458
	at [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@62e99458
	at [email protected]/java.util.concurrent.locks.LockSupport.park(LockSupport.java:371)
	at [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
	at [email protected]/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
	at [email protected]/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
	at [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1707)
	at [email protected]/java.lang.ref.ReferenceQueue.await(ReferenceQueue.java:67)
	at [email protected]/java.lang.ref.ReferenceQueue.remove0(ReferenceQueue.java:158)
	...

Thread dumps are now more complete and can be read by programs expecting a mxbean output.
@Gamebuster19901 Gamebuster19901 changed the title Update DefaultUncaughtExceptionHandler.java Better Thread Dumps Sep 25, 2024
@Gamebuster19901 Gamebuster19901 marked this pull request as draft September 25, 2024 05:54
@Gamebuster19901
Copy link
Contributor Author

There appears to be a bug in openjdk 17 which limits the stacktrace size to around 8 even if a higher amount is specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant