Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitek Karas <10670590+vitek-karas@users.noreply.github.com>2022-08-13 00:04:01 +0300
committerGitHub <noreply@github.com>2022-08-13 00:04:01 +0300
commitfda7b09fc005acb865deaf526c7adbb1be27a5f9 (patch)
treec1e9f84293cca507e20cd403f9ed770c4f00d2b5
parent1ef0acf496369c15911dd5fe78e2d100659fa389 (diff)
Fix exception when generating warning for method definition (#2972)
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.
-rw-r--r--src/linker/Linker/MessageOrigin.cs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/linker/Linker/MessageOrigin.cs b/src/linker/Linker/MessageOrigin.cs
index 24d18c065..402e529e7 100644
--- a/src/linker/Linker/MessageOrigin.cs
+++ b/src/linker/Linker/MessageOrigin.cs
@@ -83,7 +83,7 @@ namespace Mono.Linker
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 ();