summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-08-12 10:48:12 -0700
committerAndreas Gampe <agampe@google.com>2015-08-12 16:54:23 -0700
commite682a0250702c65a668e39eefdd1c49cfea5f388 (patch)
treeeb5e67e3957f63dbde2c8836474545992c06c6f8 /test
parent6aec9daecf37fcf02e47ffa7c8faa8a3de2dc412 (diff)
downloadart-e682a0250702c65a668e39eefdd1c49cfea5f388.zip
art-e682a0250702c65a668e39eefdd1c49cfea5f388.tar.gz
art-e682a0250702c65a668e39eefdd1c49cfea5f388.tar.bz2
ART: Change UninitializedThis tracking in the verifier
Only relying on register types is error-prone. For example, we may inadvertently reject correct code when the constructor terminates abnormally. Bug: 20843113 (cherry picked from commit f10b6e109bfb595b6752d1b59db680694ac1684d) (cherry picked from commit af31802e5b74f5b9b8d3aadbaaf48cfde14ff7d1) Change-Id: I8826cd167780df25a6166740f183d216483fa550
Diffstat (limited to 'test')
-rw-r--r--test/800-smali/expected.txt1
-rw-r--r--test/800-smali/smali/b_20843113.smali34
-rw-r--r--test/800-smali/src/Main.java1
3 files changed, 36 insertions, 0 deletions
diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt
index 77668da..ebcaad1 100644
--- a/test/800-smali/expected.txt
+++ b/test/800-smali/expected.txt
@@ -28,4 +28,5 @@ b/22331663
b/22331663 (pass)
b/22331663 (fail)
b/22881413
+b/20843113
Done!
diff --git a/test/800-smali/smali/b_20843113.smali b/test/800-smali/smali/b_20843113.smali
new file mode 100644
index 0000000..ab3dc41
--- /dev/null
+++ b/test/800-smali/smali/b_20843113.smali
@@ -0,0 +1,34 @@
+.class public LB20843113;
+.super Ljava/lang/Object;
+
+
+.method public constructor <init>(I)V
+.registers 2
+
+:Label1
+ # An instruction that may throw, so as to pass UninitializedThis to the handler
+ div-int v1, v1, v1
+
+ # Call the super-constructor
+ invoke-direct {v0}, Ljava/lang/Object;-><init>()V
+
+ # Return normally.
+ return-void
+
+:Label2
+
+
+:Handler
+ move-exception v0 # Overwrite the (last) "this" register. This should be
+ # allowed as we will terminate abnormally below.
+
+ throw v0 # Terminate abnormally
+
+.catchall {:Label1 .. :Label2} :Handler
+.end method
+
+# Just a dummy.
+.method public static run()V
+.registers 1
+ return-void
+.end method
diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java
index 7ee1e45..e487374 100644
--- a/test/800-smali/src/Main.java
+++ b/test/800-smali/src/Main.java
@@ -102,6 +102,7 @@ public class Main {
testCases.add(new TestCase("b/22331663 (fail)", "B22331663Fail", "run",
new Object[] { false }, new VerifyError(), null));
testCases.add(new TestCase("b/22881413", "B22881413", "run", null, null, null));
+ testCases.add(new TestCase("b/20843113", "B20843113", "run", null, null, null));
}
public void runTests() {