ExceptionInspector throws NullReferenceException every frame when a patch method belongs to no mod (dynamic assembly)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 76/100
Rechercherichtung
Beginne mit Mods.AddMetadata und verfolge dann, wie ExceptionInfo.GetReport Mod-Details erstellt und wie Columns.Column deren Metadaten verwendet. Reproduziere den Fehler mit einer Harmony-Patch-Methode aus einer dynamischen Assembly und einer Exception, die diese durchläuft. Fertig ist die Arbeit, wenn beim Öffnen des Inspectors für Patches ohne Mod-Metadaten keine wiederholten Exceptions mehr ausgelöst werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
When a captured exception has a stack frame whose method carries a Harmony patch from an assembly that no mod owns (for example a runtime-generated assembly), the inspector window throws a NullReferenceException on every frame. The log fills with thousands of errors and the window cannot be used.
Seen with Visual Exceptions 1.5.0.0 on RimWorld 1.7.5005, Harmony 3.
Cause
Mods.AddMetadata creates a ModInfo for every patch method, also when GetModMetaData(assembly) returns null:
static IEnumerable<ModInfo> AddMetadata(IEnumerable<MethodInfo> methods)
{
return methods.Select(method =>
{
var assembly = method.DeclaringType.Assembly;
var metaData = GetModMetaData(assembly);
return new ModInfo { method = method, metaData = metaData };
});
}
ExceptionInfo.GetReport then adds an ExceptionDetails.Mod with meta == null, and Columns.Column(this ExceptionDetails.Mod mod) dereferences it:
var name = mod.meta.Name.Truncate(200, truncatedModNamesCache);
Stack frames do not have this problem, because GetMetadataIfMod returns null for non-mod code and GetAllMethods skips those. Only patches are missing the check.
How it showed up
A player ran the Overclock mod with "Parallel pawn ticks (experimental)" on. That feature builds its prefix classes at runtime with AssemblyBuilder.DefineDynamicAssembly (types named IdPrefix_<n>_<method> and IdState_<n>) and patches thousands of mod methods with them. Those types are in no mod's loadedAssemblies.
During loading, another mod requested a graphic with a null texture path, which throws ArgumentNullException in ContentFinder<Texture2D>.Get. One frame of that exception had such a generated prefix on it. Once the inspector opened at the main menu:
Exception filling window for VisualExceptions.ExceptionInspector: System.NullReferenceException: Object reference not set to an instance of an object.
at VisualExceptions.Columns.Column_Patch1(Mod mod)
at VisualExceptions.ExceptionInspector.<>c.<DoWindowContents>b__9_2(Mod mod)
at System.Linq.Enumerable.ListSelectIterator`2.MoveNext()
at System.Linq.Enumerable.MaxFloat[TSource,TResult](IEnumerable`1 source, Func`2 selector)
at VisualExceptions.Columns.MaxWidth(IEnumerable`1 drawers)
at VisualExceptions.ExceptionInspector.DoWindowContents_Patch1(ExceptionInspector this, Rect inRect)
at Verse.Window.InnerWindowOnGUI_Patch3(Window this, Int32 x)
This repeated 2,515 times in under a minute.
Steps to reproduce
- Have any Harmony patch whose patch method is declared in a dynamic assembly, on a method of a mod.
- Throw an exception that passes through that method and is caught by one of the handlers Visual Exceptions instruments.
- Open the inspector.
- Vorherrschende Sprache
- C#
- Sterne
- 10
- Forks
- 2
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Ähnliche Issues
-
area:repo elsa 3 prio low triaged type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
elsa-workflows/elsa-core#9258 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
iokode/OpinionatedFramework#140 ·
-
accessibility effort: small enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
pedersebastian/CustomBossChallenge#185 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
xceedsoftware/wpftoolkit#1812 ·