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

Jadx cast wrong types to array instance and int constants #1327

Open
AIRTEspresso opened this issue Jan 9, 2022 · 3 comments
Open

Jadx cast wrong types to array instance and int constants #1327

AIRTEspresso opened this issue Jan 9, 2022 · 3 comments
Labels
bug Core Issues in jadx-core module hard-to-fix

Comments

@AIRTEspresso
Copy link

AIRTEspresso commented Jan 9, 2022

Describe error
Hi, it is my again, the one who doing researches based on Jadx. Here is another decompilation error I found duing my usage of Jadx.
Here is the source code :

    public static void vMeth(int i) {

        int i1=50465, i2=9, i15=169, i16=-55953, i17=-241, i18=8, iArr2[]=new int[N], iArr3[][][]=new int[N][N][N];
        float f3=0.138F;
        long lArr[]=new long[N];

        FuzzerUtils.init(iArr2, -191);
        FuzzerUtils.init(iArr3, -40138);
        FuzzerUtils.init(lArr, -11L);

        for (i1 = 10; i1 < 384; ++i1) {
            boolean b1=false;
            i = byMeth(58.600F, -171);
            iArr2[i1 - 1] = (int)f3;
            iArr2[(13 >>> 1) % N] *= i;
            Test.bFld = b1;
            for (i15 = 1; 5 > i15; ++i15) {
                Test.instanceCount = (long)f3;
                iArr3 = iArr3;
                i += i15;
                lArr[i1] = Test.instanceCount;
                i17 -= i1;
                i += i18;
                Test.instanceCount += (((i15 * i1) + i17) - i16);
                iArr3[i1 - 1][i1 - 1][i15] = i2;
                i17 += i15;
            }
        }
        vMeth_check_sum += i + i1 + i2 + Float.floatToIntBits(f3) + i15 + i16 + i17 + i18 + FuzzerUtils.checkSum(iArr2)
            + FuzzerUtils.checkSum(iArr3) + FuzzerUtils.checkSum(lArr);
    }

and here is the code Jadx decompiled from the dex file:

    public static void vMeth(int i) {
        int[] iArr = new int[N];
        int[][][] iArr2 = (int[][][]) Array.newInstance(int.class, N, N, N);
        long[] jArr = new long[N];
        FuzzerUtils.init(iArr, -191);
        FuzzerUtils.init((Object[][]) iArr2, (Object) -40138);
        FuzzerUtils.init(jArr, -11L);
        int i2 = 169;
        int i3 = -241;
        int i4 = 10;
        while (i4 < 384) {
            byte byMeth = byMeth(58.6f, -171);
            int i5 = i4 - 1;
            iArr[i5] = (int) 0.138f;
            iArr[6] = iArr[6] * byMeth;
            bFld = false;
            i = byMeth;
            i2 = 1;
            while (5 > i2) {
                long j = (long) 0.138f;
                instanceCount = j;
                jArr[i4] = j;
                int i6 = i3 - i4;
                i = i + i2 + 8;
                instanceCount = j + ((long) (((i2 * i4) + i6) - -55953));
                iArr2[i5][i5][i2] = 9;
                i3 = i6 + i2;
                i2++;
            }
            i4++;
        }
        vMeth_check_sum += ((long) ((((((i + i4) + 9) + Float.floatToIntBits(0.138f)) + i2) - 55953) + i3 + 8)) + FuzzerUtils.checkSum(iArr) + FuzzerUtils.checkSum((Object[][]) iArr2) + FuzzerUtils.checkSum(jArr);
    }

Jadx generates the method invocation statement ''FuzzerUtils.init((Object[][]) iArr2, (Object) -40138)'', which cast Object[][] to the int[][][] array and cast Object to the integer -40138. It is strange, I also attached the source/decompilation code, the dex file for reference here. I hope they can help :).

@AIRTEspresso AIRTEspresso added bug Core Issues in jadx-core module labels Jan 9, 2022
@skylot
Copy link
Owner

skylot commented Jan 9, 2022

@AIRTEspresso right now, jadx is not very smart about resolving and checking overloaded method usage. In your sample there is no method with exact signature ((int[][][], int)) so we need to find the closest method like java compiler did, but this part is not yet completed, so jadx trying to play safe and just cast all arguments. This issue can be fixed, but it is not easy.

Also, I notice that cast (Object) -40138 is not correct and should be fixed to (Object) (-40138).

@AIRTEspresso
Copy link
Author

Thanks for answer. I have many other buggy reports in different conditions. Should I show you in this issue or open different issues later?

@skylot
Copy link
Owner

skylot commented Jan 10, 2022

I have many other buggy reports in different conditions.

There are nearly infinite number of possible issues, so please report only most common ones using different issues.

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 hard-to-fix
Projects
None yet
Development

No branches or pull requests

2 participants