-
Notifications
You must be signed in to change notification settings - Fork 222
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
Incorrect code while decompiling #108
Comments
So is the problem that the try block is empty? Because the code itself didn't disappear. I'm not sure if there's a meaningful way to represent an invalid ldc throwing at the Java level. |
I manipulated this particular example to show worst-case. Without the |
It's not a logical error, just a side effect of the way xmagicthrow is implemented. It doesn't actually stop the optimizer from pruning normal instructions, it just inserts an extra instruction into the IR after every (non jump) bytecode operation which is treated as being able to throw anything. Thus ldc is still assumed to not throw and optimized out as applicable, but the try/catch is maintained. |
I see. Would it be possible to fix this bug? I don't know much of how Krakatau works but I fear that due to the small amount of bytecode required people will happily integrate it into whatever obfuscator they're spinning up and then the one decompiler that actually works decently doesn't. |
It's a hard problem and I'm not sure what the right answer is. |
Could there be an option to disable optimizations? I'm not sure how you've designed the framework so that may not be very easy, but sometimes disabling optimizations may be a good thing (E.g. if I insert many many many reducible blocks and force krakatau to try and optimize all of them, then it'll just hang and produce no meaningful output) |
The thing is that for normal code, you want the optimizations, because doing otherwise leads to tons of unnecessary clutter in the output. There's also the separate issue that prior to the addition of EBBs, throw optimization was necessary to get reasonable performance. But that shouldn't be true now, so it is worth revisiting. Still, it would take a fair bit of work to implement and make sure it works, and it seems like it isn't very important. |
Hmm... There really doesn't seem to be a good solution to this. I suppose a cheap solution would be to just define Or maybe it's possible to modify whatever internal structure which stores exceptions thrown by instructions to change |
The following program causes the following code to be decompiled if
-xmagicthrow
is enabled:and this if not:
I remember you had reservations about handling this sort of throwable-based edge case, but I think
-xmagicthrow
was supposed to be a "this should handle them all", which is why I'm reporting this particular instanceThe text was updated successfully, but these errors were encountered: