unicorn icon indicating copy to clipboard operation
unicorn copied to clipboard

Fixes #1661 - Hook block infinite loop when changing PC

Open AeonLucid opened this issue 1 year ago • 4 comments

Issue is described in #1661.

I have the exact same issue. My arm64 code is jumping to a block that is hooked with HOOK_BLOCK, I then handle it in my own code and set the X0 and PC so the arm64 code resumes. This used to work fine with Unicorn 1. Now, when I run the same code it fails to work properly and keeps calling the block, creating an infinite loop.

Then, I added a HOOK_CODE block in an attempt to debug it. To my confusion it started working after I added the debug hook.

Reverting commit https://github.com/unicorn-engine/unicorn/commit/b7bc13650c56ebaad47264c7c7cf5a5a72e25fd4 fixes the issue.

I can't tell you why because I don't understand the internals well, it is the first commit I tried when @paulkermann mentioned it was a regression in RC7.

If there is a better fix please feel free to commit to the PR.

AeonLucid avatar Jul 23 '22 10:07 AeonLucid

This revert will cause a few other regressions when no UC_HOOK_CODE is installed. To fix it correctly, could provide a reproduction script?

wtdcode avatar Jul 23 '22 10:07 wtdcode

This revert will cause a few other regressions when no UC_HOOK_CODE is installed. To fix it correctly, could provide a reproduction script?

I provided one, in both the issue and this PR.

AeonLucid avatar Jul 23 '22 10:07 AeonLucid

This revert will cause a few other regressions when no UC_HOOK_CODE is installed. To fix it correctly, could provide a reproduction script?

I provided one, in both the issue and this PR.

Good, I will look into it.

wtdcode avatar Jul 23 '22 10:07 wtdcode

@wtdcode Great, thanks! If you have time, can you also check https://github.com/unicorn-engine/unicorn/pull/1648? I have added a repro for that one as well.

AeonLucid avatar Jul 23 '22 12:07 AeonLucid

Fixed in c4a0813

wtdcode avatar Aug 31 '22 15:08 wtdcode