Strip invalid locals information instead of failing compilation.

The LocalVariableTable in a class file can be completely invalid.
This typically happens when there is bytecode instrumentation in
play. Instead of failing with an exception, we typically bail out
and then just strip the locals information from the method when
it doesn't make sense.

This change extends that approach to situations where the start
or end point of a local variable refers to the middle of an
instruction encoding instead of the start of an instruction.

R=christofferqa@google.com

Bug: 110164501
Change-Id: I4c37ec45112f0f8f9a203cdc4ac744049a95cbe3
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/JarState.java b/src/main/java/com/android/tools/r8/ir/conversion/JarState.java
index 99bca1c..b67d12e 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/JarState.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/JarState.java
@@ -339,6 +339,12 @@
     }
     int start = source.getOffset(node.start);
     int end = source.getOffset(node.end);
+    // If the locals information is invalid the node start or end could be a label that does
+    // not exist in the program.
+    if (start == -1 || end == -1) {
+      throw new InvalidDebugInfoException(
+          "Locals information for '" + node.name + "' has undefined start or end point.");
+    }
     // Ensure that there is an entry at the starting point of the local.
     {
       LocalsAtOffset atStart;