Skip to content

Unreachable block exception #2275

Open
Open
@ambergorzynski

Description

@ambergorzynski

Issue details

I found this error in the process of investigating #2274 - reporting it separately since it appears to be a different problem. I attempt to decompile a class file that was originally written in Java bytecode using Jasmin. The original program can be compiled using javac and executed successfully. However, jadx gievs a runtime exception 'Found unreachable blocks'

Original program - block_1 is indeed unreachable but the program is accepted by javac and can be executed fine so in that sense it is a valid Java program:

.method public testCase([I[I)V
    .limit stack 5
    .limit locals 6

block_0:
    iconst_0
    istore_3

    goto block_2
            
block_1: 
    sipush 1

    ifeq block_1
    goto block_2
            
block_2: 
    iinc 3 1
    return
        
.end method

The output from jadx is an unreachable block exception:

package defpackage;

/* compiled from: program.j */
/* loaded from: TestCase.class */
public class TestCase {
    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Found unreachable blocks
        	at jadx.core.dex.visitors.blocks.DominatorTree.sortBlocks(DominatorTree.java:34)
        	at jadx.core.dex.visitors.blocks.DominatorTree.compute(DominatorTree.java:24)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.computeDominators(BlockProcessor.java:209)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:50)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    public void testCase(int[] r7, int[] r8) {
        /*
            r6 = this;
            r0 = 0
            r9 = r0
            r0 = 0
            goto L11
        L8:
            r1 = 1
            if (r1 == 0) goto L8
            goto L11
        L11:
            int r9 = r9 + 1
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.TestCase.testCase(int[], int[]):void");
    }
}

Relevant log output or stacktrace

No response

Provide sample and class/method full name

I attach a .zip file with the following:

  • program.j which is the original bytecode progam
  • TestCase.class which is the class file associated with program.j
  • TestCase.java which is the output of applying jadx to TestCase.class
  • run.sh which is a script for reproducing compilation and execution of the original program. If you want to run this you will need to download Jasmin and change the paths at the start of the script
  • Wrapper.java which is a just wrapper that calls the function in the program that I was interested in, attached for running reproducibility
    example.zip

Jadx version

1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreIssues in jadx-core modulebug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions