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

Magisk Zygisk breaks NDK C++ native breakpoints and stacktraces #6229

Closed
twisted89 opened this issue Aug 28, 2022 · 6 comments
Closed

Magisk Zygisk breaks NDK C++ native breakpoints and stacktraces #6229

twisted89 opened this issue Aug 28, 2022 · 6 comments
Assignees
Labels
confirmed Issue confirmed to exist and the reason is known core This issue is related to Magisk Core

Comments

@twisted89
Copy link

twisted89 commented Aug 28, 2022

Please actually test this before closing the issue without explanation!
The NDK issue was created before I realised Magisk was the real cause, I've left them open to cover all bases.

Device: Tested multiple - Samsung S20 FE, LG G6, HTC One M7
Android version: 11 &12
Magisk version name: 25.2
Magisk version code: 25203

With the latest Magisk installed and the Zygisk option enabled NDK C++ breakpoints cease to function, LLDB reports the error

warning: failed to set breakpoint side 0xa3d741c for breakpoint -5.1: error: 9 sending the breakpoint request.

Upon uninstalling Magisk or disabling Zygisk breakpoints then work again.

android/ndk#1754

@twisted89
Copy link
Author

Guessing this is just getting ignored then.

@twisted89
Copy link
Author

twisted89 commented Sep 21, 2022

Response from Google bug report

https://issuetracker.google.com/issues/243471116#comment10

I verified that native debugging works with Magisk, but it does not work with Magisk+Zygisk.

This is outside our scope of Android Studio support. I suggest reaching out to Magisk owner.

If you file a bug against Magisk, you may add this information:

LLDB has a mechanism for detecting when an .so is loaded.
This is implemented by inserting a breakpoint, called a rendezvous breakpoint, into a specific location in the dynamic linker.
Enabling Zygisk seems to break this mechanism.
This can be observed as follows:

Create a simple C++ native activity app using Android Studio.
Start debugging the app in Android Studio. Let the app load the activity.
Pause the app using the Native debugger.
Open the LLDB console tab and type image list.
Expected:
The native-lib.so is in the list.
Actual:
The native-lib.so is missing in the list.
The list has a bunch of other .so files, but those are the system .so files that have already been loaded at the time LLDB attached.
Possible Workaround (other than disabling Zygisk):

Start your app.
Wait until it loads your .so file(s).
Use Android Studio's Attach Debugger to Android Process.
Your breakpoints should now work.
Note that you cannot debug the startup part of your app using this technique as the app won't wait until the debugger is attached and continue running.

Since this doesn't seem to be an Android Studio issue, I'll close this as intended-behavior.

@ys1231
Copy link

ys1231 commented Nov 17, 2022

I have the same problem, At present, you can only turn off the zygisk mode.
This problem bothered me for two days. At first, I had all kinds of guesses.
The problem was found only after repeated tests.

@canyie canyie added the needs investigation Reason of this issue is yet unkown label Jan 23, 2023
@canyie
Copy link
Collaborator

canyie commented Feb 26, 2023

Try this module instead of official zygisk?
https://github.com/Dr-TSNG/ZygiskOnKernelSU

@canyie canyie added confirmed Issue confirmed to exist and the reason is known and removed needs investigation Reason of this issue is yet unkown labels Feb 26, 2023
@5ec1cff
Copy link
Contributor

5ec1cff commented Feb 27, 2023

Try executing umount -l /system/bin/app_process64 in global namespace (e.g. adb shell ) before debugging.

@yujincheng08 yujincheng08 linked a pull request Mar 1, 2023 that will close this issue
3 tasks
@yujincheng08 yujincheng08 added the core This issue is related to Magisk Core label Mar 2, 2023
@yujincheng08 yujincheng08 self-assigned this Mar 13, 2023
@yujincheng08 yujincheng08 changed the title Magisk Zygisk breaks NDK C++ native breakpoints Magisk Zygisk breaks NDK C++ native breakpoints and stacktraces Mar 13, 2023
@canyie
Copy link
Collaborator

canyie commented Nov 8, 2023

Fixed in 9fbd079

@canyie canyie closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Issue confirmed to exist and the reason is known core This issue is related to Magisk Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants