einsteinx2 / wiiflow-lite-einstein-mod

My customizations to WiiFlow Lite, at first focusing on polishing the UI and UX. Attempting to keep as much source compatibility as possible. Original repo here: https://sourceforge.net/projects/wiiflow-lite/
4 stars 1 forks source link

Investigate memory leak #41

Open einsteinx2 opened 6 years ago

einsteinx2 commented 6 years ago

Fledge told me that WiiFlow has had a memory leak since forever. Not sure how to debug it, but worth looking into.

Hakaisha commented 6 years ago

In my years of using WiiFlow subsequent to the release of WiiFlow Lite, I can tell you it used to be quite buggy and would predictably crash a lot.

The most common crash I would experience in the older releases would be when I booted up WiiFlow and let it set idle for about 10 minutes. After 10 minutes, press a button or try to scroll and the screen would freeze, requiring a hard reboot of the system.

This has thankfully disappeared in WiiFlow Lite, as I often like to just turn it on and listen to the music play. I had assumed the memory leak was fixed at this point.

I do still very seldomly experience a crash in the current release of WiiFlow Lite; but for different reasons. Sometimes if I'm mucking about for a while, selecting different games, scrolling around a lot between different consoles, favoriting and unfavoriting, etc, then choose to start a game, I'll get a code dump screen.

This code dump screen thankfully reloads, and is nowhere near as problematic as a full-on freeze.

einsteinx2 commented 6 years ago

@Hakaisha So it sounds like some earlier memory leak or leaks were fixed, but everything you describe at the end about mucking around for a while and then it crashing sounds exactly like a memory leak. It sounds like as you perform actions, some memory is not being cleaned up and then eventually you have relatively low memory and attempting to start a game fails (though I'd have to see the core dump).

If you reproduce it again, please take a photo of the crash screen. If you send me that and your exact boot.dol file, I can use the debugger to find out what's crashing.

Hakaisha commented 6 years ago

I will certainly do that! Like I said, it very seldomly happens. I always have my phone handy to take a photo though.

I'll try to purposely make it happen and get you a screen capture. I'm pretty confident I can reproduce it.

einsteinx2 commented 6 years ago

That would be great. If you can post that and the boot.dol from your WiiFlow Lite folder, that should be all I need to get started. However, if it's very rare, it'll have to be low priority as it could take a while to track down and I have limited time.

Hakaisha commented 6 years ago

Code dump finally reared its ugly head. Twice in the same day. I took a photo of both instances, copied the boot.dol from my apps and archived it for you:

http://www.mediafire.com/file/145cvvsf104xd18/WFL_Code_Dump.rar/file

It could just be a coincidence, but it seems to happen a lot more often after letting it build WFC files (the old fashioned way, where it discovers new covers and slowly adds them) and changing themes.

einsteinx2 commented 6 years ago

Awesome! That's great info and should be everything I need when I finally get a minute to look at this.

kaisersozeh commented 6 years ago

https://gbatemp.net/threads/wiiflow-lite.422685/page-36#post-8129327 user "aphirst" I've come to believe that wiiflow-lite is very good at corrupting my 64GB Sandisk microSD card in my Wii U, specifically through use of the Covers/Banners feature. If I never scan for covers, I don't seem to have any problems. As soon as I do, all hell breaks loose. All the following can suddenly become corrupted:

  1. Banner data
  2. Cover data
  3. Game data

I had just copied over r1150 for testing, and figured it'd be a good idea to start from a fresh sd:/wiiflow directory, so I deleted the previous one.

I performed a scan for missing banners, and since there were still some missing, I fiddled about with the "from which regions" settings and scanned again. I got a few more, but after still not seeing too many even after choosing "refresh cache", I quit back to the HBC and opened WFL anew.

From here, some of the previously-obtained covers were garbled with coloured noise, which worried me, so I tried loading a game, which worked perfectly fine yesterday, and got the dreaded Exception DSI Error.

When trying to delete my cache directory I got an error from my file manager about LULZ.bnr, at which moment the following appeared in dmesg: [CODE][ 2046.041633] FAT-fs (mmcblk0): error, fat_free_clusters: deleting FAT entry beyond EOF [ 2046.041639] FAT-fs (mmcblk0): Filesystem has been set read-only [/CODE]

When trying to read (md5sum) one of the affected game (.wbfs) files, I get an input/output error, and dmesg is spammed with: [code][ 2141.992698] FAT-fs (mmcblk0): error, fat_bmap_cluster: request beyond EOF (i_pos 1164160003) [ 2141.992702] FAT-fs (mmcblk0): error, fat_bmap_cluster: request beyond EOF (i_pos 1164160003) [ 2141.992706] FAT-fs (mmcblk0): error, fat_bmap_cluster: request beyond EOF (i_pos 1164160003) [ 2141.992712] FAT-fs (mmcblk0): error, fat_bmap_cluster: request beyond EOF (i_pos 1164160003) [/code]

Now, I'm sure you're thinking "your SD card must be screwed". However I ran f3write and then f3read, and got 0 errors! It's only when I use the covers/banners feature that my microSD gets screwed up - if just play games etc., it works fine!

[USER=296093]@fledge68[/USER], How should I best proceed?

P.S. I have actually been having these problems with all the versions of WFL I've ever tried, but I've always chalked it up to having copied something wrong. I'm however now totally convinced that it relates to the Cover/Banner update feature

aphirst commented 6 years ago

Hi there! Yes, that's me there. This issue does smell as if it's related. I actually further updated my post a couple of times with some more minor but potentially important details.

If there's anything I can do to help diagnose this, please feel free to ask. I was in the process of repeating F3 on my card, and was also going to try out using a smaller card (if I have any available), though that would have to wait until morning (obviously because of sleep).

aphirst commented 6 years ago

I've gone into more detail in another post: https://gbatemp.net/threads/wiiflow-lite.422685/page-37#post-8131215

Summary: IMO the culprit is either

(the FAT corruption showed shared sectors between a generated .bnr and a game .wbfs, which itself also needed to be truncated due to an incorrect cluster chain length)

Edit: I've given yet more details in the thread, and am also giving info to fledge68 via GBATemp PM, but it seems the issue is also not nicely reproducible. Of course it isn't.