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

Sony Z3 Compact bootloop #31

Closed
michyprima opened this issue Mar 17, 2015 · 49 comments

Comments

@michyprima
Copy link

commented Mar 17, 2015

install goes fine. First boot is okay. xposed works. From 2nd boot the phone will bootloop. Nothing will make the phone boot again but a factory reset.

@rovo89

This comment has been minimized.

Copy link
Owner

commented Mar 18, 2015

Please post a logcat of the bootloop.

@michyprima

This comment has been minimized.

Copy link
Author

commented Mar 18, 2015

I can't as adb will not work anymore. Any suggestion on how I could get a logcat without adb?
Also I forgot to mention it does not loop in the "usual" way. It does a full restart after a while on the boot animation

@michyprima

This comment has been minimized.

Copy link
Author

commented Mar 18, 2015

Another clue: I saw the nfc firmware updater force close when it booted. Might this be useful?

@rovo89

This comment has been minimized.

Copy link
Owner

commented Mar 18, 2015

Not really. I can't do anything without the logs. You could ask on XDA if someone has the same problem on your ROM and can get a logcat.

@michyprima

This comment has been minimized.

Copy link
Author

commented Mar 18, 2015

Please don't close this issue. I will try again to get a logcat.

@michyprima

This comment has been minimized.

Copy link
Author

commented Mar 18, 2015

@AndroPlus-org

This comment has been minimized.

Copy link

commented Mar 22, 2015

Another logs from Xperia Z3 (Z3 and Z3 Compact are almost same system):
http://x.androplus.org/1xpcVj2
[1] error.log - Xposed Log after installing and reboot. This time Xposed is working. (sorry for enabling too many modules)
[2] boot_stopped.log - Boot log after reboot and stopped booting. Bootlooped.
[3] boot_working.log - Boot log after wipe dalvik cache via recovery. Xposed is working.
[4] boot_stopped.log - Boot log after reboot and stopped booting. Bootlooped.

/system/framework:
http://x.androplus.org/1xpcXYd

some stock files in /system/lib and /bin:
http://x.androplus.org/1GFMJAq

Xposed is working only after first installation and after wiping dalvik cache...

@rovo89

This comment has been minimized.

Copy link
Owner

commented Mar 22, 2015

Both failing logs have a NPE in android.app.ContextImpl.checkPermission(). So probably ActivityManagerNative.getDefault() returns null. No idea why. Maybe someone with this ROM could create a test module to log the return value of this and related methods?

@michyprima

This comment has been minimized.

Copy link
Author

commented Mar 22, 2015

So patching checkpermission might work as a temporary workaround?

@rovo89

This comment has been minimized.

Copy link
Owner

commented Mar 23, 2015

Probably not. Then the next method using the activity manager would most likely fail...

@michyprima

This comment has been minimized.

Copy link
Author

commented Mar 24, 2015

I still don't understand why this happens only after play services are updated. I mean, shouldn't them be a separate portion of the system?

@borz93

This comment has been minimized.

Copy link

commented Mar 24, 2015

This is a catlog from serajr Xposed Test Module for LP in Xperia Z2 Stock Lollipop.
Source: http://forum.xda-developers.com/showpost.php?p=59653356&postcount=224
catlog: http://pastebin.com/CjeNZKsp

@rovo89

This comment has been minimized.

Copy link
Owner

commented Mar 25, 2015

Thanks! That's from a working system though, right? What I would need is some analysis of the situation when the bootloop occurs.

@ghost

This comment has been minimized.

Copy link

commented Mar 27, 2015

here's a log from Z2 stock lollipop bootllooped running xposed with nothing but serajr's test module enabled.

http://rghost.net/8ybJj7Xyr

it appears that no module starts before the system hangs!

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 5, 2015

Hey @rovo89 , I tried starting all from scretch, factory reset, flash Xposed, install APK and install GravityBox, everything works great, no bootloop.

EDIT!
not specific app, but number of apps installed

I started installing app one at a time, it turns out that there is specific apps limit, after installing 25 apps, i got this error and than the services stared dropping

04-06 14:29:57.208 1237-1237/? I/art﹕ DexFile_isDexOptNeeded failed to open oat file '/data/dalvik-cache/arm/data@app@com.coffeebeanventures.easyvoicerecorder-1@base.apk@classes.dex' for file location '/data/app/com.coffeebeanventures.easyvoicerecorder-1/base.apk': Failed to allocate ElfFile reservation for /data/dalvik-cache/arm/data@app@com.coffeebeanventures.easyvoicerecorder-1@base.apk@classes.dex: ashmem_create_region failed for 'ElfFile reservation for /data/dalvik-cache/arm/data@app@com.coffeebeanventures.easyvoicerecorder-1@base.apk@classes.dex': Too many open files
04-06 14:29:57.208 1237-1237/? I/art﹕ DexFile_isDexOptNeeded failed to open oat file '/data/app/com.coffeebeanventures.easyvoicerecorder-1/arm/base.odex' for file location '/data/app/com.coffeebeanventures.easyvoicerecorder-1/base.apk': Failed to open oat filename for reading: No such file or directory

log is here:
https://gist.github.com/Shahar2k5/d31fa7a36765a8de2a60

@rovo89

This comment has been minimized.

Copy link
Owner

commented Apr 7, 2015

@hussainalhaddad The log you posted doesn't have the test module activated, but some others...
@Shahar2k5 Your log seems to be taken too late, it probably starts after the reason for the crash has already occured.

I'm wondering whether the "Too many open files" error is just a consequence or the reason of the crash. Could anyone execute "ulimit -n" to find out how many open files are allowed?
And also, it might still be helpful to get a proper log with the test module installed.

@ghost

This comment has been minimized.

Copy link

commented Apr 7, 2015

@rovo89 as i mentioned, the system crashes before loading any modules... the other modules are just listed but not loaded.

Also i'm pretty sure it has something to do with dex2oat. now i believe when we deodex the rom, this would have nothing to do right? that's why it works when deodexing!

what are the parameters you're using in your dex2oat?

@AndroPlus-org

This comment has been minimized.

Copy link

commented Apr 8, 2015

The result of "ulimit -n" was 1024.

I deodexed system and now I don't get bootloop.
Here is logs:
http://x.androplus.org/1HQ88r5
livebootWtestmodule.log -> log with test module enabled
xposed_error_20150408_194100.log -> xposed log with test module enabled
livebootWOtestmodule.log -> log without any module including test module

java.lang.NoSuchMethodError: android.app.ActivityManagerNative#gDefault()#exact
happens but xposed works without problem when I enable some other modules... strange.

I'll try to revert back to odex (stock) system and get logs when I have enough time.

@michyprima

This comment has been minimized.

Copy link
Author

commented Apr 8, 2015

I can confirm deodexing gets around the issue.

@rovo89

This comment has been minimized.

Copy link
Owner

commented Apr 9, 2015

dex2oat does what the name says, it converts the .dex files (usually contained in the APK/JAR as classes.dex) and compiles them to .oat files. The .dex files are still rather close to Java/Smali, whereas .oat files contain native code.

Odexed ROMs come with precompiled .oat files, which are named .odex and stored in the /system partition. This is to speed up the boot process, as it means that usually the system files don't need to be compiled on these ROMs.

However, Xposed needs to disable some ART optimizations and therefore needs to recompile the .odex files. This is possible because they still contain the original .dex files that they were compiled from. This recompilation is something that I have developed. It's strange though that the first boot (were the recompilation happens) works fine, and I didn't see dex2oat error messages for /system/framework/services.jar...

Could you create a log with the deodex'ed ROM after clearing the Dalvik cache? Just for comparison...

@ghost

This comment has been minimized.

Copy link

commented Apr 10, 2015

i think when we clear the dalvik cache, the rom will start without them because they don't exist, and create them as soon as android starts past the point where it normally hangs, and then read them on the next boot and get stuck.

i also noticed that creating the dex files with xposed installed is a lot slower than without it.. the issue could be in creating the dex..or the rom simply can't read them.

i'll post some logs from a deodexed rom, and maybe deodex a full rom with xposed dex2oat?! possible??

btw, the modified xposed for 5.1 works great on cm12.1 without clearing cache where xposed for 5 on cm12 still needs clearing cache

@ghost

This comment has been minimized.

Copy link

commented Apr 11, 2015

ok.. i just deodexed only the framework folder with no issues at all.. i skipped the app and priv-app so i don't get issues with google services... and of course xposed worked perfectly.. so it's probably a file or more that aren't compatible with the dex2oat modifications... i'll dig even more to find which file(s).

@AndroPlus-org

This comment has been minimized.

Copy link

commented Apr 11, 2015

Here's log with deodexed system after clearing dalvik cache:
http://x.androplus.org/1HeLNWb

@cpurick

This comment has been minimized.

Copy link

commented Apr 16, 2015

Can just anybody fix this, or does it have to be rovo89? I can't develop for Android, but I'd be happy to contribute to a bounty for this. These recompiles are burning out my battery.

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 17, 2015

@hussainalhaddad i deodexed only the framework but i still get bootloop, can you point me to a guide or upload the deodexed framework please?
Thanks.

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2015

@Shahar2k5 have you cleared the dalvik cache after deodexing?? it's important to do so.... anyway, i used JoelDroid2.3 from http://www.s4mods.ml/2015/02/deodex-android-50-lollipop.html

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 17, 2015

I tried using joel, deodexin only the framework, which i got out from the system.ext4 file.
I flashed a clean stock rom, clear dalvik and cache, replaced framework and got a bootloop, without xposed even… just clean stock with deodexed framework… :-(
Can you give me a hand pls?
Maybe via email or skype?

@McBane87

This comment has been minimized.

Copy link

commented Apr 17, 2015

Deodexed Framework on Z1c was not working for me, too.
On first time starting with deodexed ROM and cleaned dalvik cahce it was booting, but all other times even after complete reinstall was never able to get the device boot again. Maybe I was one time lucky.

Only thing which seems to be different. Boot takes more time now before crashing and rebooting.

@Shakar2k5:
Maybe you didn't corrected update-script in the provided ZIP-File? The Script thinks you deodexed app,priv-app and framework by default and is deleting all 3 folders before copy new ones.

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 18, 2015

@McBane87 i did fix the script, didnt help…

@McBane87

This comment has been minimized.

Copy link

commented Apr 18, 2015

@Shahar2k5
Yeah as I said.it is not working for me, too. deodexed framework without xposed is also causing bootloop.

@michyprima

This comment has been minimized.

Copy link
Author

commented Apr 18, 2015

you cannot deodex the framework without deodexing everything.

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 18, 2015

@michyprima what i did was taking out app,priv-app and framework from the system.ext4 via ext2explore, then deodex it with JoelDroid tool, flashed a stock, prerooted xzdr rom i made using prfcreator.
Then i replaced the app, privapp and framework and got playstore and GPServices crashes...

@ghost

This comment has been minimized.

Copy link

commented Apr 18, 2015

@michyprima yes you can.. why not?!

i'll upload my version for Z2 23.1.A.0.726 if anyone wants it

@cpurick

This comment has been minimized.

Copy link

commented Apr 18, 2015

Roberto, that's really good. Following those threads, AndroPlus found a "too many files open" error in the logs, and uploaded a kernel with INR_OPEN_CUR bumped to 4096. (This is in post #10 of Roberto's second link.)

Gustavo RD78 applied it to his kernel in post #20 and said it fixed the problem.

Not saying everyone needs to have 4096 open files, but maybe there's a leak somewhere in the dex2oat recompiles?

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 19, 2015

@rovo89 when using ulimit its session only, and not system wide.
is there anyway you can call 'ulimit -n 4096' when starting the xposed process?

@MaxRink

This comment has been minimized.

Copy link

commented Apr 19, 2015

The issue is present on every Sony LP-ROM so far.
But you should be able to set ulimit systemwide in sysctl.conf.

@rovo89

This comment has been minimized.

Copy link
Owner

commented Apr 20, 2015

Not saying everyone needs to have 4096 open files, but maybe there's a leak somewhere in the dex2oat recompiles?

A leak in dex2oat probably wouldn't cause this, as a) it runs only on the first boot (and works fine there) and b) terminates once one file is recompiled, which closes any open files.

But good to know that the "too many open files" error is indeed relevant and not just a side-effect of the root cause. Can someone try if lsof or busybox lsof works, in order to list the open files? This should be executed with Xposed installed and working on the second boot, so ideally by someone who has the custom kernel and many apps installed.

@michyprima

This comment has been minimized.

@McBane87

This comment has been minimized.

Copy link

commented Apr 21, 2015

Just want to confirm that the Ulimit-Workaround is also working with Z1 Compact.
I compiled new Kernel and now no Bootloops anymore.

@Shahar2k5

This comment has been minimized.

Copy link

commented Apr 21, 2015

Hey @rovo89 ,
can you please tell me when and where in the system the xposed starts to load ?

Thanks,

Shahar.

@rovo89

This comment has been minimized.

Copy link
Owner

commented Apr 27, 2015

This will be hopefully be helpful to nail down the file descriptor leak:
http://forum.xda-developers.com/showpost.php?p=60373854&postcount=417

I will look through my changes when I find the time. If I can't spot anything directly, I'll add some more logging and post a debug version here.

@AndroPlus-org

This comment has been minimized.

Copy link

commented Apr 28, 2015

After I flash xposed-sdk21-arm-20150426.zip, some modules stopped working.
(some Xperia user already reported on Xposed discussion thread)
log:
http://x.androplus.org/1Fu57hM

The error messages are related to this commit
rovo89/XposedBridge@55fbe25
Should module developers do something to prevent this error, or it's related to above leak?

@cpurick

This comment has been minimized.

Copy link

commented Apr 28, 2015

I'm wondering if the open file count is worth checking on some other device. Are Sony phones more sensitive to a bug that opens too many files on every phone, or is there a reason it only open too many files on Sony devices?

If we expect every device to be limited to 1024, then it's opening too many on Sony. But if other devices only work because their default limit happens to be higher, then it's possible this is also leaking on those devices without symptoms, like it does on a Sony running some of the current workarounds.

@rovo89

This comment has been minimized.

Copy link
Owner

commented Apr 28, 2015

@WedyDQ10 These are just warnings. Before that commit, there would have been an exception (no such method), but now it doesn't crash anymore, it just warns. I guess I have to add the stack trace to this warning, then it's clearer which module is causing this. Most likely, it's causes by App Settings, which I have already patched for myself. When I remember it, I will post a new APK.

I think the resource leak could also happen on other devices. So far, I have an idea where the leak might happen, but I couldn't try it yet. I'm not sure though, as nearly the same code is also present in AOSP (but of course, it could also be wrong there).

@rovo89 rovo89 added the bug label Apr 28, 2015
@rovo89

This comment has been minimized.

Copy link
Owner

commented Apr 30, 2015

Could someone test this please:
(removed, please use 3.0 alpha4 or later)

Note: This is just a debug version, please don't link to it. In case it works, I will post a new, official version soon.

@mionica

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2015

This is fixed for good.

[i] waiting for boot to finish...
[i] > boot completed after 27s
[v]
[i] system_server has only 270 open files
[i](and Xposed is installed)
[i] this probably means the fix is no longer required :)
[v]

good man!

@cpurick

This comment has been minimized.

Copy link

commented Apr 30, 2015

Thank you!!!

@cpurick

This comment has been minimized.

Copy link

commented May 1, 2015

I swear, Lollipop runs 100% better since this went in. Thanks.

B--B added a commit to AOSP-JF/platform_art that referenced this issue Sep 15, 2015
Otherwise, resources will be exhausted sooner or later on some ROMs.
This can lead to bootloops or sudden restarts.

Some parts of the code were copied from OpenDexFilesFromImage(), which opens
the file for later use. But in OatHeader::FromFile(), we just want to read
the header and then close the file again.

Fixes rovo89/Xposed#31
Repository owner locked and limited conversation to collaborators Apr 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
10 participants
You can’t perform that action at this time.