Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unreachable block exception #2275

Open
ambergorzynski opened this issue Sep 12, 2024 · 0 comments
Open

Unreachable block exception #2275

ambergorzynski opened this issue Sep 12, 2024 · 0 comments
Labels
bug Core Issues in jadx-core module

Comments

@ambergorzynski
Copy link

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

@ambergorzynski ambergorzynski added bug Core Issues in jadx-core module labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

1 participant