-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
270 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Display more info in crash report. | |
## Why make it? | ||
Forge 1.13.2 - 1.14.3 removed mod list and coremod list in crash report, while users need them to analyze what caused crash. | ||
Forge 1.14.4 added mod list back, but it is not formatted. It's hard to read when plenty of mods loaded. Meanwhile, coremods list is still not shown. | ||
Mod list added in Forge 1.14.4 crash report can be shown below: | ||
Mod list added in Forge 1.14.4 crash report: | ||
``` | ||
Mod List: | ||
CustomSkinLoader_Forge-14.11-SNAPSHOT-89.jar CustomSkinLoader {[email protected] DONE} | ||
|
@@ -13,7 +13,7 @@ Mod List: | |
## What added? | ||
This mod is designed to take mod list and coremod list back with pretty printing. | ||
Feel free to open an issue if other info needed. | ||
What added in crash report is shown below: | ||
What added in crash report: | ||
``` | ||
Forge Mods: | ||
| ID | Name | Version | Source | Status | | ||
|
@@ -28,3 +28,20 @@ Forge CoreMods: | |
| customskinloader | transformers | transformers.js | Loaded | | ||
| forge | fieldtomethodtransformers | fieldtomethodtransformers.js | Loaded | | ||
``` | ||
## What's more? | ||
We are trying to analyze some crash automaticly. | ||
Now, we can help you to solve `java.lang.VerifyError`. | ||
You can open an issue to submit crash report, I will try my best to find the way to solve. | ||
What added for some crash: | ||
``` | ||
Possible Reason: | ||
Bytecode in class 'me.xfl03.morecrashinfo.util.CrashMaker' failed to verify. | ||
CoreMod 'MoreCrashInfo' modified that class, which may cause crash. | ||
Possible Solution: | ||
Please remove or update 'MoreCrashInfo(MoreCrashInfo-1.0.3.jar)' and try again. | ||
Error Info: | ||
Class: me.xfl03.morecrashinfo.util.CrashMaker | ||
Owner: MoreCrashInfo | ||
Audit: xf:fml:morecrashinfo:CrashMakerTransformer | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/me/xfl03/morecrashinfo/handler/CrashHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.xfl03.morecrashinfo.handler; | ||
|
||
import cpw.mods.modlauncher.log.TransformingThrowablePatternConverter; | ||
import me.xfl03.morecrashinfo.handler.exception.*; | ||
import net.minecraft.crash.CrashReport; | ||
|
||
import java.util.*; | ||
import java.util.function.Function; | ||
|
||
public class CrashHandler { | ||
|
||
private static Map<Class, Function<Throwable, ExceptionHandler>> handlers = new HashMap<>(); | ||
private static ExceptionHandler handler; | ||
|
||
public static void registerHandler(Class exception, Function<Throwable, ExceptionHandler> handler) { | ||
handlers.put(exception, handler); | ||
} | ||
|
||
// net.minecraftforge.fml.CrashReportExtender.addCrashReportHeader | ||
public static void addCrashReportHeader(StringBuilder stringbuilder, CrashReport crashReport) { | ||
Throwable cause = crashReport.getCrashCause(); | ||
handler = Optional.ofNullable(handlers.get(cause.getClass())) | ||
.orElse(ExceptionHandler::new).apply(cause); | ||
handler.handleHeader(stringbuilder); | ||
} | ||
|
||
// net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace | ||
public static String generateEnhancedStackTrace(final Throwable throwable) { | ||
StringBuilder stringbuilder = new StringBuilder(); | ||
handler.handleException(stringbuilder); | ||
stringbuilder.append(TransformingThrowablePatternConverter.generateEnhancedStackTrace(throwable)); | ||
return stringbuilder.toString(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/me/xfl03/morecrashinfo/handler/ExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package me.xfl03.morecrashinfo.handler; | ||
|
||
public class ExceptionHandler { | ||
protected Throwable cause; | ||
|
||
public ExceptionHandler(Throwable cause) { | ||
this.cause = cause; | ||
} | ||
|
||
public void handleHeader(StringBuilder sb) { | ||
} | ||
|
||
public void handleException(StringBuilder sb) { | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/me/xfl03/morecrashinfo/handler/exception/VerifyErrorHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package me.xfl03.morecrashinfo.handler.exception; | ||
|
||
import me.xfl03.morecrashinfo.handler.ExceptionHandler; | ||
import me.xfl03.morecrashinfo.util.ModHelper; | ||
import net.minecraftforge.fml.ModContainer; | ||
import net.minecraftforge.fml.ModList; | ||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo; | ||
import net.minecraftforge.forgespi.language.IModInfo; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
public class VerifyErrorHandler extends ExceptionHandler { | ||
private String className; | ||
private List<? extends ModContainer> transformers; | ||
private Optional<? extends ModContainer> owner; | ||
|
||
public VerifyErrorHandler(Throwable cause) { | ||
super(cause); | ||
className = getClass(cause.getMessage()); | ||
transformers = ModHelper.getTransformers(className); | ||
owner = ModHelper.getModByClass(className); | ||
} | ||
|
||
@Override | ||
public void handleHeader(StringBuilder sb) { | ||
sb.append("Possible Reason:\n\tBytecode in class '").append(className).append("' failed to verify. ") | ||
.append(getReason()).append("\n\n"); | ||
} | ||
|
||
private String getReason() { | ||
if (!transformers.isEmpty()) { | ||
|
||
return String.format( | ||
"\n\tCoreMod '%s' modified that class, which may cause crash.\n" + | ||
"Possible Solution:\n\tPlease remove or update %s'%s' and try again.", | ||
transformers.stream().map(it -> it.getModInfo().getDisplayName()) | ||
.collect(Collectors.joining(",")), | ||
transformers.size() > 1 ? "one of " : "", | ||
transformers.stream().map(it -> it.getModInfo().getDisplayName() + | ||
"(" + ModHelper.getSource(it.getModInfo()) + ")") | ||
.collect(Collectors.joining(",")) | ||
); | ||
} else if (owner.isPresent()) { | ||
IModInfo info = owner.get().getModInfo(); | ||
return String.format( | ||
"\n\tMod '%s' might has been broken.\n" + | ||
"Possible Solution:\n\tPlease remove or update '%s' and try again.", | ||
info.getDisplayName(), | ||
info.getDisplayName() + "(" + ModHelper.getSource(info) + ")" | ||
); | ||
} | ||
return ""; | ||
} | ||
|
||
@Override | ||
public void handleException(StringBuilder sb) { | ||
sb.append("Error Info:\n\tClass: ").append(className) | ||
.append("\n\tOwner: ").append(owner.map(it -> it.getModInfo().getDisplayName()).orElse("Unknown")) | ||
.append("\n\tAudit: ").append(ModHelper.getAuditLine(className)).append("\n\n"); | ||
} | ||
|
||
private String getClass(String message) { | ||
String[] t = message.split("Location:"); | ||
if (t.length < 2) return null; | ||
t = t[1].split("\\."); | ||
return t[0].trim().replace('/', '.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.xfl03.morecrashinfo.util; | ||
|
||
public class CrashMaker { | ||
public static void makeCrash() { | ||
throw new RuntimeException(new RuntimeException(new RuntimeException("Crashed for test."))); | ||
} | ||
|
||
public static void doNothing() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"crashtransformers": "crashtransformers.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var InsnNode = Java.type('org.objectweb.asm.tree.InsnNode'); | ||
var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode'); | ||
var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode'); | ||
|
||
var Opcodes = Java.type('org.objectweb.asm.Opcodes'); | ||
|
||
function initializeCoreMod() { | ||
return { | ||
'CrashReportExtenderTransformer': { | ||
'target': { | ||
'type': 'CLASS', | ||
'name': 'net/minecraftforge/fml/CrashReportExtender' | ||
}, | ||
'transformer': function (cn) { | ||
cn.methods.forEach(function (mn) { | ||
if (mn.name === 'addCrashReportHeader') { | ||
mn.instructions.clear(); | ||
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); | ||
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); | ||
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, | ||
"me/xfl03/morecrashinfo/handler/CrashHandler", | ||
"addCrashReportHeader", | ||
"(Ljava/lang/StringBuilder;Lnet/minecraft/crash/CrashReport;)V", false)); | ||
mn.instructions.add(new InsnNode(Opcodes.RETURN)); | ||
} else if (mn.name === 'generateEnhancedStackTrace') { | ||
mn.instructions.clear(); | ||
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); | ||
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, | ||
"me/xfl03/morecrashinfo/handler/CrashHandler", | ||
"generateEnhancedStackTrace", | ||
"(Ljava/lang/Throwable;)Ljava/lang/String;", false)); | ||
mn.instructions.add(new InsnNode(Opcodes.ARETURN)); | ||
} | ||
}); | ||
return cn; | ||
} | ||
}, | ||
'CrashMakerTransformer': { | ||
'target': { | ||
'type': 'CLASS', | ||
'name': 'me/xfl03/morecrashinfo/util/CrashMaker' | ||
}, | ||
'transformer': function (cn) { | ||
// Uncomment to cause java.lang.ClassFormatError | ||
//cn.methods.add(cn.methods.get(0)); | ||
|
||
//Uncomment to cause java.lang.VerifyError | ||
//cn.methods.forEach(function (mn) { mn.instructions.clear(); mn.instructions.add(new InsnNode(Opcodes.ARETURN)); }); | ||
} | ||
} | ||
} | ||
} |