Repository navigation
fix: copy a short return tail reached from a loop body and from before the loop - #3026
Open
HuzaifaChaudary wants to merge 1 commit into
Open
HuzaifaChaudary wants to merge 1 commit into
HuzaifaChaudary wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fixes #2781 . the method from the issue decompiled to code that keeps looping after
str = "pass"and returns false , where the real method logs and returns true .the loop body jumps to
log(...); return true;, and the same two instructions are also reached from theelsebranch before the loop . the loop's normal exit goes toreturn false, so abreakcan't reach that tail , and the jump was dropped .splitReturnwould copy the return for each predecessor , but the return sits in its own block after thelogcall , so the block with two predecessors isn't the return block .this adds
splitLoopExitTailnext tosplitReturn: if a return is preceded by a short straight tail (up to 4 instructions) that is reached both from a loop body exit and from outside the loop , the tail is copied for the loop side . it only fires when the tail is not the loop's normal exit , so a compound loop condition or a plainbreakkeeps its current output . the issue method now comes out asthe new smali test is the issue's method with the android types swapped for
java.langones , and it fails without the change . jadx-core tests : 1034 passed , 0 failed .i also decompiled a 20 MB apk (the sample from #2892) with and without the change . nothing changed apart from
throwsclauses that already differ between two runs of the unchanged build ,MethodThrowsVisitorhits aConcurrentModificationExceptionthere with-j 8.spotlessCheckcould not fetch its eclipse formatter here , so the formatting is checked by hand against the file .