Android memory corruption

馋奶兔 提交于 2020-12-15 06:08:35

问题


I have a very strange bug on Android that I can't explain. Most of the time, my app (made in Delphi with FireMonkey) ends with External exception xx or Access violation at address xxx, accessing address 0000000x and I can't explain why. The exceptions appear in different places of my software, and at very unexpected times. For example, the last error log I receive just now is this one:

libapp.so $0000007D91A61548 Grijjy.Errorreporting.TgoExceptionReporter.GlobalGetExceptionStackInfo(TExceptionRecord*) + 128
libapp.so $0000007D911E5220 Sysutils.Exception.RaisingException(TExceptionRecord*) + 52
libapp.so $0000007D9120F814 Sysutils.RaiseExceptObject(TExceptionRecord*) + 64
libapp.so $0000007D911C57A0 _RaiseAtExcept(TObject*, Pointer) + 100
libapp.so $0000007D911E42EC Internal.Excutils.SignalConverter(NativeUInt, NativeUInt, NativeUInt) + 56
libapp.so $0000007D911C3B2C _IntfClear(IInterface&) + 68
libapp.so $0000007D91256C90 Rtti.TRttiContext.Free() + 20
libapp.so $0000007D91349AB8 Androidapi.Jnibridge.dispatchToNative(JNINativeInterface**, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Int64) + 980

But as I say, most of the time those bugs appear in completely different places, like for example:

libapp.so $0000007C76C0AC50 Grijjy.Errorreporting.TgoExceptionReporter.GlobalGetExceptionStackInfo(TExceptionRecord*) + 128
libapp.so $0000007C7638FC80 Sysutils.Exception.RaisingException(TExceptionRecord*) + 52
libapp.so $0000007C763BA274 Sysutils.RaiseExceptObject(TExceptionRecord*) + 64
libapp.so $0000007C76370200 _RaiseAtExcept(TObject*, Pointer) + 100
libapp.so $0000007C7638ED4C Internal.Excutils.SignalConverter(NativeUInt, NativeUInt, NativeUInt) + 56
libapp.so $0000007C769D9FE8 Fmx.Types.ArrangeControl(Fmx.Types.IAlignableObject, Fmx.Types.TAlignLayout, Single, Single, Single, Single, var Types.TRectF) + 112
libapp.so $0000007C769DA824 Fmx.Types.AlignObjects(Fmx.Types.TFmxObject*, Fmx.Types.TBounds*, Single, Single, var Single, var Single, var Boolean).DoAlign(Pointer, Fmx.Types.TAlignLayout) + 556
libapp.so $0000007C769DAABC Fmx.Types.AlignObjects(Fmx.Types.TFmxObject*, Fmx.Types.TBounds*, Single, Single, var Single, var Single, var Boolean) + 508
libapp.so $0000007C76A4DC60 Fmx.Forms.TCustomForm.Realign() + 168
libapp.so $0000007C76A49A84 Fmx.Forms.TCommonCustomForm.Updated() + 36
libapp.so $0000007C76A499D0 Fmx.Forms.TCommonCustomForm.EndUpdate() + 252
libapp.so $0000007C76A4EA94 Fmx.Forms.TCustomForm.EndUpdate() + 20
libapp.so $0000007C76E06564 main.TMainForm.ShowFrame(base.TBaseFrame*, Boolean, definition.TShowFrameTransition) + 3528
libapp.so $0000007C76E06F28 main.TMainForm.ShowPreviousFrame() + 1820
libapp.so $0000007C76DFFDD4 main.TMainForm.FormKeyUp(TObject*, var Word, var Char, set of Classes.System_Classes__1) + 500
libapp.so $0000007C76A48E74 Fmx.Forms.TCommonCustomForm.KeyUp(var Word, var Char, set of Classes.System_Classes__1) + 104
libapp.so $0000007C7698BAE0 Fmx.Platform.Ui.Android.TAndroidTextInputManager.KeyUp(var Word, var Char, set of Classes.System_Classes__1, Boolean) + 72
libapp.so $0000007C76987618 Fmx.Platform.Ui.Android.TAndroidTextInputManager.HandleAndroidKeyEvent(AInputEvent*) + 976
libapp.so $0000007C769AF36C Fmx.Platform.Android.TPlatformAndroid.HandleAndroidInputEvent(Androidapi.Appglue.TAndroidApplicationGlue*, AInputEvent*) + 64
libapp.so $0000007C76648D90 Androidapi.Appglue.TAndroidApplicationGlue.InputEventHandler(Integer, Integer, Pointer) + 184
libutils.so $0000007D6F73AD90 android::Looper::pollInner(int) + 860
libutils.so $0000007D6F73A998 android::Looper::pollOnce(int, int*, int*, void**) + 60

It's very rare (around 1 time every 500 launches), always at different places. I doubt it's an error in my code. I start to think that maybe memory is becoming corrupted?

For example, my app sends some JSON to my server, and this is via a Java library (so no Delphi code involved here) and sometimes I receive this JSON:

positions=[{"latitude":8.620783,"longitude":1.4476126,"accuracy":13.26200008392334},"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"]}

This \u0000\u0000\u0000...\u0000\u0000 makes me think that something starts to be a total mess in my app, so maybe the memory?

The code that generate this JSON is quite simple:

JSONObject newNode = new JSONObject();
newNode.put("latitude", location.getLatitude()); // double 
newNode.put("longitude", location.getLongitude()); // double 
newNode.put("accuracy", location.getAccuracy()); // double 

Note: it appears on many different devices (Huawai, Samsung, etc).

So, is their something that can explain this behavior? Is it possible that the memory used by my app is lost or wiped out? Most important, how can I find out where the problem is exactly?

来源:https://stackoverflow.com/questions/64829275/android-memory-corruption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!