Status Update
Comments
sg...@google.com <sg...@google.com> #2
This looks like a duplicate of
This fix landed in R8 8.0.62, 8.1.64 and 8.2.24. AGP 8.0.2 is using R8 8.0.46, AGP 8.1.2 is using R8 8.1.68, and AGP 8.2.0-beta06 is using R8 8.2.33.
In other words, you will need the patch until updating to AGP 8.1.2 or 8.2.0 (or 8.0.3, if that should happen).
to...@xperi.com <to...@xperi.com> #3
I double-checked and the issue reproduces for me on r8 main (4569e47e1c762cd600e3866f5c07bee8817c99a3) which does contain 50ac58bc0b6ecb41b44e0845a047f1fd47302dcd "Bail out of control-flow analysis on error states" from
sg...@google.com <sg...@google.com> #4
Thanks for validation, and sorry for asking, I just realized that you already wrote The problem still exist in r8's main branch as of today. in
Will it be possible for you to share a reproduction through a dump of your project passing -Dcom.android.tools.r8.dumpinputtofile=mydump.zip
to the compilation, see
As you are already building from source, you could also try to apply the following patch, to see if that helps:
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/info/bridge/BridgeAnalyzer.java b/src/main/java/com/android/tools/r8/ir/optimize/info/bridge/BridgeAnalyzer.java
index 853c734bb1..11c3f5b21f 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/info/bridge/BridgeAnalyzer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/info/bridge/BridgeAnalyzer.java
@@ -12,6 +12,7 @@ import static com.android.tools.r8.ir.code.Opcodes.INVOKE_VIRTUAL;
import static com.android.tools.r8.ir.code.Opcodes.RETURN;
import com.android.tools.r8.graph.DexEncodedMethod;
+import com.android.tools.r8.graph.DexMethod;
import com.android.tools.r8.ir.code.AssumeAndCheckCastAliasedValueConfiguration;
import com.android.tools.r8.ir.code.BasicBlock;
import com.android.tools.r8.ir.code.CheckCast;
@@ -24,6 +25,8 @@ import com.android.tools.r8.ir.code.InvokeMethodWithReceiver;
import com.android.tools.r8.ir.code.Return;
import com.android.tools.r8.ir.code.Value;
import com.android.tools.r8.utils.BooleanUtils;
+import com.android.tools.r8.utils.SetUtils;
+import java.util.Set;
public class BridgeAnalyzer {
@@ -36,8 +39,12 @@ public class BridgeAnalyzer {
InvokeMethodWithReceiver uniqueInvoke = null;
CheckCast uniqueReturnCast = null;
InstructionListIterator instructionIterator = code.entryBlock().listIterator(code);
+ Set<Instruction> seen = SetUtils.newIdentityHashSet();
while (instructionIterator.hasNext()) {
Instruction instruction = instructionIterator.next();
+ if (!seen.add(instruction)) {
+ return failure();
+ }
switch (instruction.opcode()) {
case ARGUMENT:
break;
ch...@google.com <ch...@google.com>
to...@xperi.com <to...@xperi.com> #5
Hi, no problem, double-checking unusual claims doesn't hurt. I had some progress minimizing the issue and may be able to share a reproducer later today, as it seems I can repro it with a third party (OSS) library jar file, and no "internal" code.
ap...@google.com <ap...@google.com> #6
Branch: main
commit 61974822ae3fd9593e3fb93765146ea6e7d4e42a
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Mon Oct 30 10:40:44 2023
Add seen-check in bridge method analyzer
Bug:
Change-Id: If3ba849c073ad0d13e133b15ece7a531f8a82fa5
M src/main/java/com/android/tools/r8/ir/optimize/info/bridge/BridgeAnalyzer.java
A src/test/java/com/android/tools/r8/ir/optimize/InfiniteLoopTest.java
ch...@google.com <ch...@google.com> #7
This should now be resolved on main (by 61974822ae3fd9593e3fb93765146ea6e7d4e42a
). Please don't hesitate to reopen this issue if the issue remains.
ap...@google.com <ap...@google.com> #8
Branch: 8.2
commit ad442529486eeb1d2cfa24d9f05ccdaea738a7bb
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Mon Oct 30 11:09:36 2023
Version 8.2.34
Bug:
Change-Id: Ib9bbfe92373d8fd82b5792e479571a16269cb510
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #9
Branch: 8.2
commit cf6b621d9bd67d91b5a0369208e3201fa5835acc
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Mon Oct 30 11:09:23 2023
Add seen-check in bridge method analyzer
Bug:
Change-Id: If3ba849c073ad0d13e133b15ece7a531f8a82fa5
M src/main/java/com/android/tools/r8/ir/optimize/info/bridge/BridgeAnalyzer.java
A src/test/java/com/android/tools/r8/ir/optimize/InfiniteLoopTest.java
ch...@google.com <ch...@google.com> #10
This should now be cherry picked to all relevant release branches (8.2.34).
to...@xperi.com <to...@xperi.com> #11
I can confirm this is fixed for me with 61974822ae3fd9593e3fb93765146ea6e7d4e42a. Thanks!
Let me know if you're still in need of a repro case.
sg...@google.com <sg...@google.com> #12
Thank you for checking. The fix includes a regression test, so you don't need to spend time on a repro.
an...@google.com <an...@google.com> #13
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 Hedgehog | 2023.1.1 Patch 1
- Android Gradle Plugin 8.2.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
Since a relatively recent change, R8 never finishes processing in one of the projects I work on. It is an Android project using roughly the same machinery as the Chromium build, so I'm working with a direct
java ... -cp r8.jar
-style call, but I'm currently unable to share a reproducer test case (proprietary code and issue not minimized). I'm not sure why this only reproduces in this one project, and not elsewhere.I do have a jstack dump of when it's stuck (attached), and managed to bisect the issue in r8 to a change in the function where the code gets stuck. I hope that's enough to start looking.
The relevant-looking stack is
and the bisect pointed tohttps://r8.googlesource.com/r8/+/3c21ca42d6450665b9bdb3ef0872a3b1ca744ac5 which modifies BridgeAnalyzer.analyzeMethod.
I'm not familiar with this code at all but it looks like it could be possible to never exit the while loop in some gotoInstruction edge case after this change. The problem still exist in r8's main branch as of today.