-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[core] There is a bug in the decompile "while" loop in version 1.3.x #1472
Comments
@threerog it will be much easier to reproduce your issue if you share sample dex or apk. |
hc3.b.j |
I'm using jadx 1.3.x, we often encounter the error problem of "while" context. Is this the first time. |
@threerog method in class public static final int j(byte[] bArr, int i) {
int i2;
while (true) {
i2 = i - 1;
if (i == 0 || bArr[i2] != 0) {
break;
}
i = i2;
}
return i2 + 1;
} Class |
Carefully compare the pictures. The logic of version 1.3 is verified to be wrong, and version 1.2 is correct |
I disagree, check smali: .method public static final j([BI)I
.registers 3
:goto_0
add-int/lit8 v0, p1, -0x1
if-eqz p1, :cond_a
aget-byte p1, p0, v0
if-nez p1, :cond_a
move p1, v0
goto :goto_0
:cond_a
add-int/lit8 v0, v0, 0x1
return v0
.end method If For other case I commit a workaround fix to restore correct order of operations. For complete fix I don't have negative case, so I postpone it until new cases will be found. @threerog thanks for report! 👍 |
@skylot: Sorry for answering to a closed ticket. This is just an idea: If you are able to detect those missing cases or patterns, you could add a debug message to the generated code (e.g. "Please review this decompiled code carefully - in case of decompilation errors report this issue with reference ." I remember the "multi-entry loop pattern" message which is a good indicator for broken, but often compilable code. Without a message errors like this are hard to find and would require a code review. To reduce false-positive reports of those issues, messages for missing patterns could be limited to certain conditions (e.g. on active in debug mode, ...). I'm sure all missing patterns and cases can be found. |
Unfortunately, I can't in most cases 😢 |
This is the result comparison between version 1.3 and 1.2:
![1](https://user-images.githubusercontent.com/87128510/165939122-edb8c553-8655-4b0b-b8ba-68bd86d3626c.png)
![2](https://user-images.githubusercontent.com/87128510/165939127-5976c122-8cf5-476d-bcb1-ec6abbbfb79b.png)
Missing jump out statements and reverse the order of loop variables
The text was updated successfully, but these errors were encountered: