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

fix: handle unknown opcodes (#342) #583

Merged
merged 3 commits into from
Apr 12, 2019
Merged

fix: handle unknown opcodes (#342) #583

merged 3 commits into from
Apr 12, 2019

Conversation

asashour
Copy link
Contributor

Fix #342

If an opcode is incorrect, then we shouldn't throw Exception, because this will make the method has no blocks.

Instead, print warning, and replace it with NOP, this is also what apktool does.

@skylot
Copy link
Owner

skylot commented Apr 11, 2019

@asashour can you describe some case which you trying to fix?
Because code you changed will be executed only for instructions not yet supported by jadx (#384 #385). And removing such insns will produce incorrect code, which is bad.
Also if you want to show warning please use mth.addWarn("Unsupported insn"); this will add a comment into generated code and mark method as "inconsistent"

P.S. explicitly throw an exception in try/catch block is a terrible idea

@asashour
Copy link
Contributor Author

asashour commented Apr 11, 2019

There are two cases here:

  1. Correct Opcodes, recognized by OpcodeInfo.getName(), but not handled in Jadx, previously DecodeException was thrown, and they remain also thrown.
  2. Incorrect Opcodes, not recognized by OpcodeInfo.getName(), and should be simply ignored.

I guess OpcodeInfo is the reference, and if we have new opcodes, then we should upgrade the dependency.


If OpcodeInfo is not the reference, then in this case how to handle 0x73, which is marked 'unused' in the doc?

@skylot
Copy link
Owner

skylot commented Apr 11, 2019

Incorrect Opcodes will throw exception from parser here.
For unsupported add method warning as I suggest above.

@skylot
Copy link
Owner

skylot commented Apr 11, 2019

As a example of bad opcodes you can use apk from this issue #224

@skylot skylot merged commit 395cae4 into skylot:master Apr 12, 2019
@asashour asashour deleted the 342 branch April 12, 2019 15:24
@bobolau
Copy link

bobolau commented Apr 18, 2019

when to support instruction: 'invoke-custom'?

@asashour
Copy link
Contributor Author

@bobolau : please subscribe to #384

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

decompile static block throw exception
3 participants