ertank 27 Posted October 5, 2019 Hello, I am using Delphi 10.3.2. There is an app for Android 5.1.1 platform only. It was working good. I do not remember when actually, but it was fine for sure. Problem now is that I get segmentation fault 11 when application is terminating. I cannot find in code reason why. I get following error in debugger after running Application.Terminate() or using Android back button which closes app: First chance exception at $00000000. Exception class Segmentation fault (11). Process Project1.apk (9547) Execution stops in System.pas at following lines: function _InstClear(var Dest: TObject): Pointer; {$IFDEF PUREPASCAL} var P: Pointer; begin Result := @Dest; if Dest <> nil then begin P := Pointer(Dest); Pointer(Dest) := nil; TObject(P).__ObjRelease; // <-- Exactly right here end; end; My call stack at that time is something as following: Lastly, my local variables are as following: I do not have anything complicated in that app. One thing which maybe relevant is that I pass some visual components (TMemo, TLabel) to a unit without form. These components are written text in them in a thread. I am using something like following to modify their values: TThread.Synchronize(nil, procedure begin BalanceLabel.Text := FormatFloat('#,##0.00', LocalBalance / 100); end); I have checked more than once to see if I am missing one visual component. I could not see any. I have googled with no luck. All my tests, debug runs returned no clue to me. Any hints to finding such FMX exceptions is appreciated. Thanks & regards, Ertan Share this post Link to post
Dave Nottage 557 Posted October 6, 2019 (edited) On 10/5/2019 at 11:26 PM, ertank said: One thing which maybe relevant is that I pass some visual components (TMemo, TLabel) to a unit without form I'd be more interested in how these are being created and free'd. Edited October 7, 2019 by Dave Nottage Share this post Link to post
ertank 27 Posted October 7, 2019 17 hours ago, Dave Nottage said: I'd be more interested in how these are being created and free'd. These are visual components placed on form. There is no code to create/free them. non visual units use them just for status update of the running thread. Share this post Link to post
Dave Nottage 557 Posted October 7, 2019 6 hours ago, ertank said: There is no code to create/free them. non visual units use them just for status update of the running thread. Without seeing all the code, it'd be hard to determine what is causing the issue. Share this post Link to post
ertank 27 Posted October 7, 2019 I could re-produce that error simply by running the app and once it is completely settled, closing it. Even for that I have spend several hours and tracked problem down to specific database operation(s). I use UniDAC and suspected that their native DBF (dBase) support might be the problem. I have remarked relevant code lines and continue my development. At some point, I needed these database operations and removed their remarks. It is very strange that after that error is not each time but random. I am not getting that error anymore, now. I do know same lines are called at each time and they are doing exact same things. If it appears again, I am going to directly check these database operations though. Thanks for the help. 1 Share this post Link to post
Remy Lebeau 1394 Posted October 8, 2019 On 10/5/2019 at 6:56 AM, ertank said: Problem now is that I get segmentation fault 11 when application is terminating. I cannot find in code reason why. I get following error in debugger after running Application.Terminate() or using Android back button which closes app: First chance exception at $00000000. Exception class Segmentation fault (11). Process Project1.apk (9547) That implies that a non-nil TObject is being released by ARC, and the TObject itself is likely invalid. On 10/5/2019 at 6:56 AM, ertank said: My call stack at that time is something as following: That call stack shows the global TApplication object being destroyed, which in turn is destroying an internal TDictionary<String, TList<TFormRegistryItem>> object. Looks like perhaps the destruction of one of the stored TFormRegistryItem objects is what is crashing. Share this post Link to post
ertank 27 Posted October 10, 2019 On 10/8/2019 at 10:48 PM, Remy Lebeau said: That call stack shows the global TApplication object being destroyed, which in turn is destroying an internal TDictionary<String, TList<TFormRegistryItem>> object. Looks like perhaps the destruction of one of the stored TFormRegistryItem objects is what is crashing. Does it also mean that I cannot be the source of the problem? I am not sure I used TFormRegistryItem t must be some visual component that I am using like TTabControl, TListView, TPanel, TLabel, TMemo, TImage etc. Share this post Link to post
Remy Lebeau 1394 Posted October 11, 2019 On 10/10/2019 at 2:33 AM, ertank said: I am not sure I used TFormRegistryItem t must be some visual component that I am using like TTabControl, TListView, TPanel, TLabel, TMemo, TImage etc. The TDictionary in question is the FFormRegistry member of the FMX.Forms.TApplication class. It is used internally by TApplication in its CreateForm(), CreateMainForm(), RegisterFormFamily(), and GetDeviceForm() methods. For what reason, I have no idea. Share this post Link to post