dotnet-installer/src/SourceBuild/tarball/patches/linker/0001-Fix-exception-when-generating-warning-for-method-definition.patch

27 lines
1.4 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: vitek-karas <10670590+vitek-karas@users.noreply.github.com>
Date: Fri, 12 Aug 2022 13:12:09 -0700
Subject: [PATCH] Fix exception when generating warning for method definition
If we produce a warning for the method itself (no IL offset) and the method has debug symbols, it can happen that there's no sequence point for the first instruction. In that case the current code will crash because we expect to always find sequence point for offset 0.
Fix this by looking for the first sequence point instead.
This patch is originally PR https://github.com/dotnet/linker/pull/2972.
---
src/linker/Linker/MessageOrigin.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/linker/Linker/MessageOrigin.cs b/src/linker/Linker/MessageOrigin.cs
index 24d18c065d..402e529e7f 100644
--- a/src/linker/Linker/MessageOrigin.cs
+++ b/src/linker/Linker/MessageOrigin.cs
@@ -83,7 +83,7 @@ public MessageOrigin (MessageOrigin other, int ilOffset)
string? fileName = FileName;
if (Provider is MethodDefinition method &&
method.DebugInformation.HasSequencePoints) {
- var offset = ILOffset ?? 0;
+ var offset = ILOffset ?? method.DebugInformation.SequencePoints[0].Offset;
SequencePoint? correspondingSequencePoint = method.DebugInformation.SequencePoints
.Where (s => s.Offset <= offset)?.Last ();