unicorn icon indicating copy to clipboard operation
unicorn copied to clipboard

Bug fix for java binding of Apple silicon.

Open zhkl0228 opened this issue 1 year ago • 4 comments

Because Java also has JIT code, Java binding in Apple M1 does not execute "tb_exec_lock" at the end of execution, which will cause "SIGBUS" exception in the execution of JIT code in Java.

zhkl0228 avatar Jul 10 '22 08:07 zhkl0228

I don't think it's the correct way to fix though it might solve your issue for now. Why is java special in this case?

wtdcode avatar Jul 10 '22 15:07 wtdcode

The java code will also be converted into local code by jit. When the unicorn execution is completed, if pthread_jit_write_protect is not called, the jit at the java layer will fail to execute.

zhkl0228 avatar Jul 10 '22 16:07 zhkl0228

This PR also fixed my unicorn bindings crashing in .NET 6 on a M1 Macbook Air. Would be great to get fixed.

Edit: If you want to repro the (most likely same) issue, I have my bindings with an example application (UnicornNet.App) https://github.com/AeonLucid/UnicornNet/tree/uc2 (branch uc2). Make sure to put your MacOS Arm64 dylib into UnicornNet/Libs/arm64, or hack it to your own path UcNative.cs#L44. The one provided in my repository currently has this PR, so to reproduce replace with 2.0.0.

AeonLucid avatar Jul 23 '22 08:07 AeonLucid

It's quite unclear to me how these fixes work without an M1 test environment. I can review this probably after I get one for debugging.

wtdcode avatar Jul 23 '22 13:07 wtdcode

Not stale.

AeonLucid avatar Dec 12 '22 05:12 AeonLucid

Applied the correct fix here: 6e97e59f5416e2cd3ad7d476061d9f7dc38eb66c

wtdcode avatar Aug 03 '23 05:08 wtdcode