There is lots of info on the web, but everything is useless and doesn't even mention what should be done for detection of the code that corrupted the stack.
So, my questions is: what should be done to actually fix stack corruption? I use latest r8d NDK and I don't have any good debugging tools for android (and I obviously not going waste a day of my life trying to build valgrind for android), my main dev platformt is windows/VS2008.... so, please advise how do u fix that kind of problems in the stone age of the NDK development ;)
Now that's really smart, why "waste" a day with valgrind (which is rather a few hours) which not only will allow to locate this kind of bug in no time but will also help you debug other problems. Anyway if you decide to "waste" a day I can provide a few pointers since I recently setup valgrind for android (and I also mainly develop in vs).
First of all you need linux box, personally I've used virtualbox to install ubuntu, current valgrind version already has support for android so there is no hacking required. I used virtualized x86 system image as test machine (so I build x86 version of valgrind).
Few issues wort mentioning: first of all make sure that valgrind has +x attribute, also there are several tutorials on web that suggest using shell script to wrap application process - I've never were able to setup that that's why I use valgrind directly in setprop, last thing: remember to kill your application process after setting wrap.* property.
Getting exact location of detected error is also a bit tricky, since binaries in APK are stripped valgrind will report only symbols (function names) and addresses, no line numbers, you can of course use addr2line but you need base address of your .so extracted from /proc/<pid>/smaps.
BTW if someone know how to disable stripping in ndk-build (if possible) that'd great, I tried to do so but ndk-build system is far too complicated for my lowly make skills.
--
Bart