{"action":"created","issue":{"url":"https://api.github.com/repos/rovo89/android_art/issues/28","repository_url":"https://api.github.com/repos/rovo89/android_art","labels_url":"https://api.github.com/repos/rovo89/android_art/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/rovo89/android_art/issues/28/comments","events_url":"https://api.github.com/repos/rovo89/android_art/issues/28/events","html_url":"https://github.com/rovo89/android_art/issues/28","id":126968910,"number":28,"title":"arm64 / odex / 6.0.1: Some apps are not compiled at boot time","user":{"login":"m0vie","id":1491108,"avatar_url":"https://avatars.githubusercontent.com/u/1491108?v=3","gravatar_id":"","url":"https://api.github.com/users/m0vie","html_url":"https://github.com/m0vie","followers_url":"https://api.github.com/users/m0vie/followers","following_url":"https://api.github.com/users/m0vie/following{/other_user}","gists_url":"https://api.github.com/users/m0vie/gists{/gist_id}","starred_url":"https://api.github.com/users/m0vie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m0vie/subscriptions","organizations_url":"https://api.github.com/users/m0vie/orgs","repos_url":"https://api.github.com/users/m0vie/repos","events_url":"https://api.github.com/users/m0vie/events{/privacy}","received_events_url":"https://api.github.com/users/m0vie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2016-01-15T22:11:43Z","updated_at":"2016-03-19T18:37:51Z","closed_at":null,"body":"I just set up a new nexus 6p like the following:\r\n* Unlock\r\n* Upgrade to latest 6.0.1 mmb29p stock rom\r\n* Enable ADB debugging\r\n* Flash twrp-2.8.7.2-angler in bootloader\r\n* Flash xposed-v79-sdk23-arm64.zip in recovery\r\n\r\nAfter rebooting 48 apps were optimized just fine.\r\n\r\nBut some others were not optimized on the boot but lateron, in which case it was not successful.\r\n\r\n```\r\n01-15 22:34:27.709  7105  7152 I ActivityManager: Start proc 8355:com.google.process.gapps/u0a12 for service com.google.android.gms/.clearcut.service.ClearcutLoggerService\r\n01-15 22:34:27.710  8319  8319 E dex2oat : Failed to create oat file: /data/dalvik-cache/arm64/system@app@NfcNci@NfcNci.apk@classes.dex: Permission denied\r\n01-15 22:34:27.710  8319  8319 I dex2oat : dex2oat took 566.510us (threads: 2) \r\n01-15 22:34:27.712  8270  8270 W System  : ClassLoader referenced unknown path: /system/priv-app/TelephonyProvider/lib/arm64\r\n01-15 22:34:27.713  8244  8244 W art     : Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg /system/framework/XposedBridge.jar --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xnorelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/system/app/NfcNci/oat/arm64/NfcNci.odex --oat-file=/data/dalvik-cache/arm64/system@app@NfcNci@NfcNci.apk@classes.dex) because non-0 exit status\r\n01-15 22:34:27.713  8244  8244 W art     : Entry not found\r\n ```\r\n\r\nThis leads to an infinitle FC loop.\r\n\r\nInvestigating the issue I did the following:\r\n* set permission of /data/dalvik-cache/arm64/ to 777\r\n\r\nThis still did not work:\r\n\r\n```\r\n01-15 22:52:09.205  5402  7721 I ActivityManager: Start proc 10156:com.android.nfc/1027 for restart com.android.nfc\r\n01-15 22:52:09.218 10156 10156 W re-initialized>: type=1400 audit(0.0:51): avc: denied { write } for name=\"arm64\" dev=\"dm-0\" ino=1064963 scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=0\r\n01-15 22:52:09.265 10171 10171 E dex2oat : Failed to create oat file: /data/dalvik-cache/arm64/system@app@NfcNci@NfcNci.apk@classes.dex: Permission denied\r\n01-15 22:52:09.258 10171 10171 W dex2oat : type=1400 audit(0.0:52): avc: denied { write } for name=\"arm64\" dev=\"dm-0\" ino=1064963 scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=0\r\n01-15 22:52:09.265 10171 10171 I dex2oat : dex2oat took 761.510us (threads: 2) \r\n01-15 22:52:09.267 10156 10156 W art     : Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg /system/framework/XposedBridge.jar --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xnorelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m -j2 --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/system/app/NfcNci/oat/arm64/NfcNci.odex --oat-file=/data/dalvik-cache/arm64/system@app@NfcNci@NfcNci.apk@classes.dex) because non-0 exit status\r\n01-15 22:52:09.267 10156 10156 W art     : Entry not found\r\n```\r\nSo now the problem is the sepolicy: `dex2oat` is being run as UID nfc and not system.\r\n\r\nSo lets' try after `setenforce permissive`:\r\n```\r\n01-15 22:57:22.227  5402  9126 I ActivityManager: Start proc 11883:com.android.nfc/1027 for restart com.android.nfc\r\n01-15 22:57:22.248 11883 11883 W re-initialized>: type=1400 audit(0.0:243): avc: denied { write } for name=\"arm64\" dev=\"dm-0\" ino=1064963 scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=0\r\n01-15 22:57:22.278 11896 11896 I setenforce: type=1400 audit(0.0:244): avc: denied { setenforce } for scontext=u:r:init:s0 tcontext=u:object_r:kernel:s0 tclass=security permissive=1\r\n01-15 22:57:22.278   349   349 W auditd  : type=1404 audit(0.0:245): enforcing=0 old_enforcing=1 auid=4294967295 ses=4294967295\r\n01-15 22:57:22.313 11895 11895 I dex2oat : /system/bin/dex2oat -j2 --dex-file=/system/app/NfcNci/oat/arm64/NfcNci.odex --oat-file=/data/dalvik-cache/arm64/system@app@NfcNci@NfcNci.apk@classes.dex\r\n01-15 22:57:22.308 11895 11895 I dex2oat : type=1400 audit(0.0:246): avc: denied { write } for name=\"arm64\" dev=\"dm-0\" ino=1064963 scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=1\r\n01-15 22:57:22.308 11895 11895 I dex2oat : type=1400 audit(0.0:247): avc: denied { add_name } for name=\"system@app@NfcNci@NfcNci.apk@classes.dex\" scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=1\r\n01-15 22:57:22.308 11895 11895 I dex2oat : type=1400 audit(0.0:248): avc: denied { create } for name=\"system@app@NfcNci@NfcNci.apk@classes.dex\" scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=1\r\n01-15 22:57:22.308 11895 11895 I dex2oat : type=1400 audit(0.0:249): avc: denied { write } for path=\"/data/dalvik-cache/arm64/system@app@NfcNci@NfcNci.apk@classes.dex\" dev=\"dm-0\" ino=1065162 scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=1\r\n01-15 22:57:22.308 11895 11895 I dex2oat : type=1400 audit(0.0:250): avc: denied { setattr } for name=\"system@app@NfcNci@NfcNci.apk@classes.dex\" dev=\"dm-0\" ino=1065162 scontext=u:r:nfc:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=1\r\n01-15 22:57:22.553 11895 11895 I dex2oat : dex2oat took 241.603ms (threads: 2) arena alloc=368KB java alloc=551KB native alloc=2MB free=1372KB\r\n01-15 22:57:22.563   372   372 I SELinux : SELinux: Loaded service_contexts from /service_contexts.\r\n01-15 22:57:22.563   372   372 I SELinux : avc:  received setenforce notice (enforcing=0)\r\n01-15 22:57:22.575 11883 11883 I NfcService: Starting NFC service\r\n```\r\nThe file could now be created, but has UID/GID of nfc/nfc:\r\n```\r\n# ls -Z /data/dalvik-cache/arm64/*Nfc*\r\n-rw-r--r-- nfc      nfc               u:object_r:dalvikcache_data_file:s0 system@app@NfcNci@NfcNci.apk@classes.dex\r\n```\r\nAnd everything works perfectly.\r\n\r\nThe problem seems to be specific to odexed system apps for which dex2oat fails when being run on-demand.\r\n\r\nI also tried the whole thing using various versions of SuperSU (2.66, 2.52, no SuperSU at all), to no avail so it seems to be unrelated to any other changes."},"comment":{"url":"https://api.github.com/repos/rovo89/android_art/issues/comments/198764133","html_url":"https://github.com/rovo89/android_art/issues/28#issuecomment-198764133","issue_url":"https://api.github.com/repos/rovo89/android_art/issues/28","id":198764133,"user":{"login":"stangri","id":4768176,"avatar_url":"https://avatars.githubusercontent.com/u/4768176?v=3","gravatar_id":"","url":"https://api.github.com/users/stangri","html_url":"https://github.com/stangri","followers_url":"https://api.github.com/users/stangri/followers","following_url":"https://api.github.com/users/stangri/following{/other_user}","gists_url":"https://api.github.com/users/stangri/gists{/gist_id}","starred_url":"https://api.github.com/users/stangri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stangri/subscriptions","organizations_url":"https://api.github.com/users/stangri/orgs","repos_url":"https://api.github.com/users/stangri/repos","events_url":"https://api.github.com/users/stangri/events{/privacy}","received_events_url":"https://api.github.com/users/stangri/received_events","type":"User","site_admin":false},"created_at":"2016-03-19T18:37:51Z","updated_at":"2016-03-19T18:37:51Z","body":"Had the same problem on Nexus 6. @michaelprager's trick didn't help, besides NFC there were problems with the other services. Even with the trick above I've had only a handful of apps (sometimes 13, sometimes 31, sometimes 31 and the count up would start from 10) which would optimize after cleaning cache. \r\n\r\nTL;DR version -- before flashing Xposed I've flashed LED Enabler and I believe that was the reason Xposed flash \"didn't take\". \r\n\r\nWhat did help me was:\r\n1. dirty-flash shamu-mmb29v\r\n2. adb reboot bootloader; fastboot boot twrp-3.0.0-1-shamu.img\r\n3. flash chainfire's SuperSU-v2.68.zip\r\n4. restart system\r\n5. ensure I have root, uninstall Xposed apk and all Xposed modules\r\n6. adb reboot bootloader; fastboot boot twrp-3.0.0-1-shamu.img\r\n7. make room in /system/ for Xposed (mount /system in twrp, adb shell and remove some IMEs)\r\n8. restart system\r\n9. make sure nothing is broken yet\r\n10. adb reboot bootloader; fastboot boot twrp-3.0.0-1-shamu.img\r\n11. flash xposed-v80-sdk23-arm.zip, use \"clean dalvik/cache\" option of twrp\r\n12. restart system\r\n13. reinstall (redownload) Xposed apk and modules\r\n14. adb reboot bootloader; fastboot boot twrp-3.0.0-1-shamu.img\r\n15. reinstall LED Enabler\r\n"}}