ExceptionInspector throws NullReferenceException every frame when a patch method belongs to no mod (dynamic assembly)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu với Mods.AddMetadata, sau đó theo dõi cách ExceptionInfo.GetReport tạo thông tin chi tiết về mod và cách Columns.Column sử dụng siêu dữ liệu của chúng. Tái hiện lỗi bằng một phương thức Harmony patch từ một assembly động và một ngoại lệ đi qua phương thức đó. Hoàn tất khi việc mở inspector không còn liên tục gây ra ngoại lệ đối với các patch không có siêu dữ liệu mod.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 10
- Fork
- 2
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
iokode/OpinionatedFramework#140 ·
-
accessibility effort: small enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pedersebastian/CustomBossChallenge#185 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
dotnet/command-line-api#2887 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
JiaFeiMiao-K-Cat/DiscImageStudio#331 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Tool] NtildeĐang mởhas-image has-license has-readme new-tool ready-to-approve repo-verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
shanselman/TinyToolTown#918 ·
Maintainer thường phản hồi trong vòng 1 ngày