Status Update
Comments
Co...@163.com <Co...@163.com> #3
Thanks for quick response.
But I found my report have misunderstanding content.
app/src/main/java/com/example/myapplication/MainActivity.kt:15: Warning: Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements [NonConstantResourceId]
val resId = R.id.text
~~~
This is not actual report, but expected
report.
And actual code have const
modifier at this field and I missed it in expected result.
And if android.nonFinalResIds
is turned on, this line will get error by kotlin compiler.
Because const val
field can be assigned by contant value only on kotlin compiler.
So, IMHO, const val
field for kotlin
And should check expected lint report about const val
field assignment from resource Id.
ch...@google.com <ch...@google.com> #5
Can you share the artifact in Google Drive?
Co...@163.com <Co...@163.com> #6
ch...@google.com <ch...@google.com> #7
Thanks for sharing the file. I was unable to reproduce the error. According to the dump, the R8 version used to generate the dump was R8 8.3.37. Which version of R8 did you see this error with?
Co...@163.com <Co...@163.com> #8
ch...@google.com <ch...@google.com> #9
The input code to the compiler appears to be incorrect. Specifically, the method seems to be assigning an int[][]
into an int[]
, which explains the error message: "Cannot constrain type: @Nullable (@Nullable (INT[])[]) for value: v9 by constraint: INT".
It looks like you have applied some bytecode transformation prior to running D8 and that this transformation may have a bug (?). In particular, the stack height of the given code is 2147483647.
ch...@google.com <ch...@google.com> #10
The stack height in the .class
file actually appears to be 4. Maybe the stack height has been set to 2147483647 by D8 as part of some desugaring. I will take another look.
ch...@google.com <ch...@google.com> #11
Indeed this is done in
ch...@google.com <ch...@google.com> #12
It looks as if the given input bytecode is invalid to me.
0: aload_0
1: getfield #25 // Field org/.../GF2nField.mDegree:I
4: dup
5: dup2
6: istore_2
7: multianewarray #36, 2 // class "[[I"
11: iload_2
12: multianewarray #36, 2 // class "[[I"
After the dup2
, the stack is [mDegree:I, mDegree:I, mDegree:I, mDegree:I]. Then we istore_2
so before the first multianewarray
we have [mDegree:I, mDegree:I, mDegree:I]. IIUC, multianewarray
consumes two ints from the stack, so it leaves the stack as [mDegree:I, arr7:[[I]. Then we iload_2
and get [mDegree:I, arr7:[[I, mDegree:I], and then again do multianewarray
, which should consume two ints from the stack, but only the uppermost value on the stack is an int.
ch...@google.com <ch...@google.com> #13
zerny@ does this look right to you?
Repro project is in /google/data/rw/teams/r8/bugs/b335663479/repro.zip and dump at /google/data/rw/teams/r8/bugs/b335663479/dump.zip.
ze...@google.com <ze...@google.com> #14
The Integer.MAX_VALUE is just to avoid computing the actual max. It should not cause an issue.
To the reporter: is this a coverage build or do you have some other plugin running that might transform the bytecode?
Co...@163.com <Co...@163.com> #15
Co...@163.com <Co...@163.com> #16
ze...@google.com <ze...@google.com> #17
In your repro project I can find an original version of the code that does not have the issue:
javap -p -v -cp ./bc/mylibrary/libs/bcprov-jdk15to18-1.77-no-sign.jar org.bouncycastle.bangsun.pqc.legacy.math.linearalgebra.GF2nONBField
<snip>
int[][] invMatrix(int[][]);
descriptor: ([[I)[[I
flags: (0x0000)
Code:
stack=4, locals=6, args_size=2
0: aload_0
1: getfield #29 // Field mDegree:I
4: aload_0
5: getfield #29 // Field mDegree:I
8: multianewarray #40, 2 // class "[[I"
12: astore_2
13: aload_1
14: astore_2
15: aload_0
16: getfield #29 // Field mDegree:I
19: aload_0
20: getfield #29 // Field mDegree:I
23: multianewarray #40, 2 // class "[[I"
<snip>
The subsequent input that is found in the dump.zip is incorrect however, and it appears that R8 is likely to blame. The code has a marker for an R8 classfile-to-classfile compilation:
#2 = String #1 // ~~R8{\"backend\":\"cf\",\"compilation-mode\":\"release\",\"has-checksums\":false,\"pg-map-id\":\"1c75180\",\"r8-mode\":\"full\",\"version\":\"8.3.37\"}
I'll need to find the intermediate R8 compilation step for this to find out what is going on. I'll post back once I find out more.
ch...@google.com <ch...@google.com> #18
Good catch. I didn't see this the first time, presumably because the build was cached so I didn't get the dump with -Dcom.android.tools.r8.dumpinputtodirectory
.
Uploaded the R8 cf-to-cf dump to /google/data/rw/teams/r8/bugs/b335663479/r8-dump.zip. Feel free to assign this back to me.
ze...@google.com <ze...@google.com> #19
I have a local repro and fix so I'll keep this one.
ap...@google.com <ap...@google.com> #20
Branch: main
commit 040b4118bf9ca73b0b04e549a9c5dced76d62540
Author: Ian Zerny <zerny@google.com>
Date: Wed Apr 24 11:08:54 2024
Always pop unused multianewarray return value
Bug:
Change-Id: I86aa3e5b3bf49a228c842bcb2e7bb5d39ef5b85b
M src/main/java/com/android/tools/r8/cf/LoadStoreHelper.java
M src/main/java/com/android/tools/r8/ir/code/Invoke.java
M src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMultiNewArray.java
M src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayTest.java
A src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayWithOnStackValueTest.java
ap...@google.com <ap...@google.com> #21
Branch: 8.3
commit 5232c342bad0fba596e37b9933cf345a116dfb40
Author: Ian Zerny <zerny@google.com>
Date: Thu Apr 25 08:55:47 2024
Always pop unused multianewarray return value
Bug:
Change-Id: I86aa3e5b3bf49a228c842bcb2e7bb5d39ef5b85b
M src/main/java/com/android/tools/r8/cf/LoadStoreHelper.java
M src/main/java/com/android/tools/r8/ir/code/Invoke.java
M src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMultiNewArray.java
M src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayTest.java
A src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayWithOnStackValueTest.java
ap...@google.com <ap...@google.com> #22
Branch: 8.3
commit 878cf775318a47e299c1849be5e9764d87680b4f
Author: Ian Zerny <zerny@google.com>
Date: Thu Apr 25 08:56:00 2024
Version 8.3.41
Bug:
Change-Id: I304e2807f8bdc76b9d113c8ece79a6a1de46b22e
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #23
Branch: 8.2
commit e62c035a712cf2f8ee8f581a35b56a09cda4c181
Author: Ian Zerny <zerny@google.com>
Date: Thu Apr 25 09:08:01 2024
Always pop unused multianewarray return value
Bug:
Change-Id: I86aa3e5b3bf49a228c842bcb2e7bb5d39ef5b85b
M src/main/java/com/android/tools/r8/cf/LoadStoreHelper.java
M src/main/java/com/android/tools/r8/ir/code/Invoke.java
M src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMultiNewArray.java
M src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayTest.java
A src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayWithOnStackValueTest.java
ap...@google.com <ap...@google.com> #24
Branch: 8.2
commit edd7ff987d2f20d4a450ba0db8430735deb38edb
Author: Ian Zerny <zerny@google.com>
Date: Thu Apr 25 09:08:12 2024
Version 8.2.55
Bug:
Change-Id: I0940a055fb3cedaf2c84eb03b18d7890444097e3
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #25
Branch: 8.1
commit fc24a3b00bdf13a9852566105c2f80e384077bd1
Author: Ian Zerny <zerny@google.com>
Date: Thu Apr 25 09:36:24 2024
Version 8.1.82
Bug:
Change-Id: I04e9f17ec51f8436d7f29cc752ddc02de2f3757c
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #26
Branch: 8.1
commit dc4b99264cd8579ec534f4bece0c3de44441e2ab
Author: Ian Zerny <zerny@google.com>
Date: Thu Apr 25 09:36:11 2024
Always pop unused multianewarray return value
Bug:
Change-Id: I86aa3e5b3bf49a228c842bcb2e7bb5d39ef5b85b
M src/main/java/com/android/tools/r8/cf/LoadStoreHelper.java
M src/main/java/com/android/tools/r8/ir/code/Invoke.java
M src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
M src/main/java/com/android/tools/r8/ir/code/InvokeMultiNewArray.java
M src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayTest.java
A src/test/java/com/android/tools/r8/cf/UnusedMultiNewArrayWithOnStackValueTest.java
ze...@google.com <ze...@google.com> #27
A fix for this has been released to the R8 branches. To use it locally you may amend your build.gradle(.kts) file with:
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:<R8VERSION>")
}
}
}
where <R8VERSION>
is the appropriate version for your AGP version. For example, in AGP 8.4 use R8 version 8.4.26
or above.
For some reason the 8.4 cherry-pick is not linked in this issue.
The fix CL for 8.4 is
Co...@163.com <Co...@163.com> #28
ze...@google.com <ze...@google.com> #29
Great to hear. Thanks for filing the issue and for the great reproduction!
an...@google.com <an...@google.com> #30
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Jellyfish | 2023.3.1 Patch 1
- Android Gradle Plugin 8.4.1
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
int[][] invMatrix(int[][] var1) {
int[][] var10000 = new int[this.mDegree][this.mDegree];
int[][] var2 = var1;
int[][] var3 = new int[this.mDegree][this.mDegree];
int var4;
for(var4 = 0; var4 < this.mDegree; ++var4) {
var3[var4][var4] = 1;
}
for(var4 = 0; var4 < this.mDegree; ++var4) {
for(int var5 = var4; var5 < this.mDegree; ++var5) {
var2[this.mDegree - 1 - var4][var5] = var2[var4][var4];
}
}
return (int[][])null;
}
After confusion:
int[][] invMatrix(int[][] var1) {
int var2;
int var10000 = var2 = super.mDegree;
int[][] var5 = new int[new int[var10000][var10000]][var2];
int var3;
for(var3 = 0; var3 < super.mDegree; ++var3) {
var5[var3][var3] = 1;
}
int var4;
for(var2 = 0; var2 < super.mDegree; ++var2) {
for(var3 = var2; var3 < (var4 = super.mDegree); ++var3) {
var1[var4 - 1 - var2][var3] = var1[var2][var2];
}
}
return null;
}
error:Cannot constrain type: @Nullable (@Nullable (INT[])[]) for value: v9 by constraint: INT