-
Notifications
You must be signed in to change notification settings - Fork 257
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
It's impossible to debug applications on Android O public preview 3 with either gdbserver or ndk-gdb from NDK r15b #447
Comments
1|angler:/ $ run-as com.example.native_activity a+x /data/data/com.example.native_activity/ there's a missing "chmod" there. where did this command come from? |
My bad - somehow the "chmod" command was lost during the copy&paste. Below is an extract from android-ndk-r15b/prebuilt/windows-x86_64/bin/ndk-gdb.py
|
what does |
Yes, chmod correctly does its job then invoked manually, but it doesn't help in the end: angler:/ $ run-as com.example.native_activity chmod a+x /data/data/com.example.native_activity/ /data/data/com.example.native_activity/cache: /data/data/com.example.native_activity/code_cache: |
does that app have INTERNET permission? if not, it won't be able to open the TCP socket. (and where did you get this command from? ndk-gdb uses unix domain sockets, not TCP.) |
Okay, then let's separate concerns:
c:\wrk\android\android-ndk-samples\native-media>c:\wrk\android-sdk/build-tools/25.0.2/aapt.exe d permissions c:\wrk\android\android-ndk-samples\native-media\bin\NativeMedia-debug.apk c:\wrk\android\android-ndk-samples\native-media>adb install -r c:\wrk\android\android-ndk-samples\native-media\bin\NativeMedia-debug.apk c:\wrk\android\android-ndk-samples\native-media>adb shell Key Set Manager: Packages: Package Changes: Dexopt state: Compiler stats: Enabled overlay paths: |
This issue still exists with the stable release. |
@jmgao: have you had a chance to look at this? |
Same issue here, using gdbserver from NDK r15c, Android O release version |
Does anyone have a workaround here? |
@rprichard: maybe something you can look at since @jmgao is unlikely to be able to any time soon? |
I think the SELinux error is happening because I would expect gdbserver's The |
If sysconf (_SC_NPROCESSORS_ONLN) is faked to 1 instead of an actual number of online cores, IIUC neither gdb nor gdbserver never reads /proc/stat directly. But both heavily relies on per-process Currently gdb/gdbserver uses the following sysconf()'s:
|
Not on a modern device, no, but gdbserver is built using an outdated libc.a from Lollipop which did use /proc/stat: https://android.googlesource.com/platform/bionic/+/lollipop-release/libc/bionic/sysconf.cpp#98 |
So, there are 2 separate permission issues on Android Oreo, both of them seems to be caused by SELinux policies.
|
AFAICT, the consequence of this issue is that
There's a problem with the /system/bin/run-as tool in Android O. I've filed an internal bug report for it. The run-as tool in O is clearing the supplementary gid list. Previously,
I think this run-as issue also affects the output of The def get_app_data_dir(args, package_name):
cmd = ["/system/bin/sh", "-c", "pwd", "2>/dev/null"]
cmd = get_run_as_cmd(package_name, cmd)
(rc, stdout, _) = args.device.shell_nocheck(cmd)
... The command isn't printing anything because a bad SELinux policy prevents run-as from accessing the stdin/stdout/stderr Unix domain sockets that adbd passes it. That bug was present in O Preview 3, and was fixed in this commit -- https://android-review.googlesource.com/#/c/platform/system/sepolicy/+/409621/. It looks fixed in O Preview 4. Because it's just a preview, I don't think there's a need for ndk-gdb to work around it, but if there were, passing |
Using the -t switch for adb shell didn't solve anything for me. I still have the "Can't open socket: Permission denied" error. |
Yes, that only fixes one of the three issues. There's a platform bug here with no workaround. |
Right, the The "Can't open socket: Permission denied" error happens when gdbserver is run with a TCP socket. Using gdbserver with a Unix domain socket (as is done with ndk-gdb) works. |
How does one use gdbserver with a Unix domain socket? |
To use gdbserver with a Unix domain socket rather than a TCP socket, you'll need commands that look something like this:
In another shell:
These commands establish the gdb connection, but the debugger immediately exits. The ndk-gdb script does more setup work that I've omitted here. |
@DanAlbert You mentioned: "There's a platform bug here with no workaround". Is this going to be addressed, and if so, when? I'm wondering why there's apparently no outcry from many developers that are unable to debug their NDK apps on Android 8 because of this issue? |
There are a few issues in this bug report:
I think I'll file a separate issue for the last item, so I can close this one. |
I think the inability of |
@rprichard Ah, thanks.. MR1 is in Developer Preview soon, yes? |
It looks like O MR1 is already in Developer Preview: https://developer.android.com/preview/download.html |
Description
It's impossible to debug applications on Android O public preview 3 with either gdbserver or ndk-gdb
Here's are the results what I get for “native-activity” Android NDK sample built from the source publised at https://github.com/googlesamples/android-ndk.git (I'm using android-mk branch):
c:\android-ndk-r15b\prebuilt\windows-x86_64\bin\ndk-gdb.cmd --attach --verbose
ADB command used: 'adb -s CVH7N15B09000307'
ADB version: Android Debug Bridge version 1.0.36 Revision 0e9850346394-android
Using project directory: c:\ android-ndk-samples\native-activity
Found package name: com.example.native_activity
Attaching to existing application process.
Application ABIs: arm64-v8a, armeabi, armeabi-v7a, mips, mips64, x86, x86_64
Device ABIs: arm64-v8a, armeabi-v7a, armeabi
Selecting ABI: arm64-v8a
Detected pretty printer: none
ERROR: Failed to make application data directory world executable
angler:/ $ run-as com.example.native_activity /data/data/com.example.native_activity/gdbserver --multi :7856
Can't open socket: Permission denied.
Exiting
1|angler:/ $ run-as com.example.native_activity a+x /data/data/com.example.native_activity/
run-as: exec failed for a+x: Permission denied
I've spotted an AVC denial entries in ADB logcat, here's the one of them:
07-07 19:35:04.333 25626-25626/? W/gdbserver: type=1400 audit(0.0:160573): avc: denied { read } for name="stat" dev="proc" ino=4026548024 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:proc_stat:s0 tclass=file permissive=0
Environment Details
[ro.bootimage.build.date]: [Wed May 31 20:07:56 UTC 2017]
[ro.bootimage.build.date.utc]: [1496261276]
[ro.bootimage.build.fingerprint]: [google/angler/angler:8.0.0/OPP3.170518.006/4055970:user/release-keys]
[ro.build.characteristics]: [nosdcard]
[ro.build.date]: [Wed May 31 20:07:56 UTC 2017]
[ro.build.date.utc]: [1496261276]
[ro.build.description]: [angler-user 8.0.0 OPP3.170518.006 4055970 release-keys]
[ro.build.display.id]: [OPP3.170518.006]
[ro.build.expect.baseband]: [angler-03.81]
[ro.build.expect.bootloader]: [angler-03.69]
[ro.build.fingerprint]: [google/angler/angler:8.0.0/OPP3.170518.006/4055970:user/release-keys]
[ro.build.flavor]: [angler-user]
[ro.build.host]: [wphr7.hot.corp.google.com]
[ro.build.id]: [OPP3.170518.006]
[ro.build.product]: [angler]
[ro.build.tags]: [release-keys]
[ro.build.type]: [user]
[ro.build.user]: [android-build]
[ro.build.version.all_codenames]: [REL]
[ro.build.version.base_os]: []
[ro.build.version.codename]: [REL]
[ro.build.version.incremental]: [4055970]
[ro.build.version.preview_sdk]: [0]
[ro.build.version.release]: [8.0.0]
[ro.build.version.sdk]: [26]
[ro.build.version.security_patch]: [2017-05-05]
[ro.vendor.build.date]: [Wed May 31 20:07:56 UTC 2017]
[ro.vendor.build.date.utc]: [1496261276]
[ro.vendor.build.fingerprint]: [google/angler/angler:8.0.0/OPP3.170518.006/4055970:user/release-keys]
Pkg.Desc = Android NDK
Pkg.Revision = 15.1.4119039
The text was updated successfully, but these errors were encountered: