Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[core] JadxRuntimeException: Duplicate predecessors in PHI #2239

Closed
pubiqq opened this issue Aug 5, 2024 · 2 comments
Closed

[core] JadxRuntimeException: Duplicate predecessors in PHI #2239

pubiqq opened this issue Aug 5, 2024 · 2 comments
Assignees
Labels
bug Core Issues in jadx-core module

Comments

@pubiqq
Copy link
Contributor

pubiqq commented Aug 5, 2024

Issue details

After 821cc66, jadx started throwing "JadxRuntimeException: Duplicate predecessors in PHI" when decompiling some methods.

Relevant log output or stacktrace

Stacktraces

        /*  JADX ERROR: JadxRuntimeException in pass: ConstructorVisitor
            jadx.core.utils.exceptions.JadxRuntimeException: Duplicate predecessors in PHI insn: B:16:0x00b6, 0x00b6: PHI (r11v0 ?? I:java.lang.StringBuilder) = (r11v10 ?? I:java.lang.StringBuilder) binds: [B:16:0x00b6] A[DONT_GENERATE, DONT_INLINE]
            	at jadx.core.dex.instructions.PhiInsn.bindArg(PhiInsn.java:44)
            	at jadx.core.dex.visitors.ConstructorVisitor.insertPhiInsn(ConstructorVisitor.java:119)
            	at jadx.core.dex.visitors.ConstructorVisitor.processInvoke(ConstructorVisitor.java:78)
            	at jadx.core.dex.visitors.ConstructorVisitor.replaceInvoke(ConstructorVisitor.java:50)
            	at jadx.core.dex.visitors.ConstructorVisitor.visit(ConstructorVisitor.java:36)
            */
        private java.lang.String arcsToString(
        /*  JADX ERROR: JadxRuntimeException in pass: ConstructorVisitor
            jadx.core.utils.exceptions.JadxRuntimeException: Duplicate predecessors in PHI insn: B:16:0x00b6, 0x00b6: PHI (r11v0 ?? I:java.lang.StringBuilder) = (r11v10 ?? I:java.lang.StringBuilder) binds: [B:16:0x00b6] A[DONT_GENERATE, DONT_INLINE]
            	at jadx.core.dex.instructions.PhiInsn.bindArg(PhiInsn.java:44)
            	at jadx.core.dex.visitors.ConstructorVisitor.insertPhiInsn(ConstructorVisitor.java:119)
            	at jadx.core.dex.visitors.ConstructorVisitor.processInvoke(ConstructorVisitor.java:78)
            	at jadx.core.dex.visitors.ConstructorVisitor.replaceInvoke(ConstructorVisitor.java:50)
            */
        /*  JADX ERROR: Method generation error
            jadx.core.utils.exceptions.JadxRuntimeException: Code variable not set in r13v0 ??
            	at jadx.core.dex.instructions.args.SSAVar.getCodeVar(SSAVar.java:238)
            	at jadx.core.codegen.MethodGen.addMethodArguments(MethodGen.java:223)
            	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:168)
            	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:401)
            	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:335)
            	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:301)
            	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
            	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
            	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
            	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
            */

Provide sample and class/method full name

Smali

.method private arcsToString(Ljava/util/List;)Ljava/lang/String;
    .locals 12
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List<",
            "Landroidx/gridlayout/widget/GridLayout$Arc;",
            ">;)",
            "Ljava/lang/String;"
        }
    .end annotation

    .local p1, "arcs":Ljava/util/List;, "Ljava/util/List<Landroidx/gridlayout/widget/GridLayout$Arc;>;"
    invoke-static {}, Landroidx/gridlayout/widget/GridLayout$Axis;->$jacocoInit()[Z

    move-result-object v0

    .line 1446
    iget-boolean v1, p0, Landroidx/gridlayout/widget/GridLayout$Axis;->horizontal:Z

    const/4 v2, 0x1

    if-eqz v1, :cond_0

    const/16 v1, 0x94

    aput-boolean v2, v0, v1

    const-string/jumbo v1, "x"

    goto :goto_0

    :cond_0
    const/16 v1, 0x95

    aput-boolean v2, v0, v1

    const-string/jumbo v1, "y"

    :goto_0
    const/16 v3, 0x96

    aput-boolean v2, v0, v3

    .line 1447
    .local v1, "var":Ljava/lang/String;
    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    .line 1448
    .local v3, "result":Ljava/lang/StringBuilder;
    const/4 v4, 0x1

    .local v4, "first":Z
    const/16 v5, 0x97

    aput-boolean v2, v0, v5

    .line 1449
    invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v5

    const/16 v6, 0x98

    aput-boolean v2, v0, v6

    :goto_1
    invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z

    move-result v6

    if-eqz v6, :cond_3

    invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Landroidx/gridlayout/widget/GridLayout$Arc;

    .line 1450
    .local v6, "arc":Landroidx/gridlayout/widget/GridLayout$Arc;
    if-eqz v4, :cond_1

    .line 1451
    const/4 v4, 0x0

    const/16 v7, 0x99

    aput-boolean v2, v0, v7

    goto :goto_2

    .line 1453
    :cond_1
    const-string v7, ", "

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const/16 v7, 0x9a

    aput-boolean v2, v0, v7

    .line 1455
    :goto_2
    iget-object v7, v6, Landroidx/gridlayout/widget/GridLayout$Arc;->span:Landroidx/gridlayout/widget/GridLayout$Interval;

    iget v7, v7, Landroidx/gridlayout/widget/GridLayout$Interval;->min:I

    .line 1456
    .local v7, "src":I
    iget-object v8, v6, Landroidx/gridlayout/widget/GridLayout$Arc;->span:Landroidx/gridlayout/widget/GridLayout$Interval;

    iget v8, v8, Landroidx/gridlayout/widget/GridLayout$Interval;->max:I

    .line 1457
    .local v8, "dst":I
    iget-object v9, v6, Landroidx/gridlayout/widget/GridLayout$Arc;->value:Landroidx/gridlayout/widget/GridLayout$MutableInt;

    iget v9, v9, Landroidx/gridlayout/widget/GridLayout$MutableInt;->value:I

    .local v9, "value":I
    const/16 v10, 0x9b

    aput-boolean v2, v0, v10

    .line 1458
    const-string v10, "-"

    new-instance v11, Ljava/lang/StringBuilder;

    if-ge v7, v8, :cond_2

    invoke-direct {v11}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v11, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v11

    invoke-virtual {v11, v8}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v11

    invoke-virtual {v11, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    const-string v11, ">="

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    const/16 v11, 0x9c

    aput-boolean v2, v0, v11

    goto :goto_3

    :cond_2
    invoke-direct {v11}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v11, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v11

    invoke-virtual {v11, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v11

    invoke-virtual {v11, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v8}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    const-string v11, "<="

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    neg-int v11, v9

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    const/16 v11, 0x9d

    aput-boolean v2, v0, v11

    :goto_3
    invoke-virtual {v3, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 1462
    .end local v6    # "arc":Landroidx/gridlayout/widget/GridLayout$Arc;
    .end local v7    # "src":I
    .end local v8    # "dst":I
    .end local v9    # "value":I
    const/16 v6, 0x9e

    aput-boolean v2, v0, v6

    goto/16 :goto_1

    .line 1463
    :cond_3
    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    const/16 v6, 0x9f

    aput-boolean v2, v0, v6

    return-object v5
.end method

Jadx version

821cc66

@pubiqq pubiqq added bug Core Issues in jadx-core module labels Aug 5, 2024
@skylot
Copy link
Owner

skylot commented Aug 5, 2024

@pubiqq thank you for this and #2240 samples! It made much easier developing fix for these issues 👍

(Related to #2236)

@skylot
Copy link
Owner

skylot commented Aug 9, 2024

Fixed

@skylot skylot closed this as completed Aug 9, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants