Recent

Author Topic: Help tracing a sigsev fault on applicatin exit.  (Read 9203 times)

creaothceann

  • Full Member
  • ***
  • Posts: 117
Re: Help tracing a sigsev fault on applicatin exit.
« Reply #15 on: March 06, 2017, 04:42:14 pm »
It should never contain garbage if you set it to NIL after deallocating stuff...

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: Help tracing a sigsev fault on applicatin exit.
« Reply #16 on: March 06, 2017, 06:01:28 pm »
http://freepascal.org/docs-html/current/prog/progsu8.html#x15-140001.2.8
That approach will have extra code to check if a pointer is valid. It is ONLY for debugging and it should be defined in your project file. (*.lpr, program)

You can also set -gclh as compile option. Afaik this is not yet available directly from the project Options|Debug settings in Lazarus.
« Last Edit: March 06, 2017, 06:10:40 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: Help tracing a sigsev fault on applicatin exit.
« Reply #17 on: March 11, 2017, 02:27:01 am »
Hi

Sorry for delay in replying weekends is my normal time to develops apps.

This issue is getting very strange, I have managed to stop any errors on exit on OSX (changed richmemo component for a standard tmemo) and that solved the issue on OSX.
The same code however is not working the same on Windows.
After trying all kinds of debug stuff, eventually I used lazlogger in the close event of the form and then I noticed that the issue is after the close event has finished; it runs through all the lines of the close event and then now I have managed to get some further most odd debug info.
Where it is giving the sigsev is actually in the form.destroy.

If I hover over the Name variable it shows the name of my Application Form as the problem.

Code: [Select]
destructor TControl.Destroy;
var
  HandlerType: TControlHandlerType;
  Side: TAnchorKind;
  i: Integer;
  CurAnchorSide: TAnchorSide;
begin
  //DebugLn('[TControl.Destroy] A ',Name,':',ClassName);    <---- Holding cursor over the name I get the name of my Application Form
  // make sure the capture is released
  MouseCapture := False;
  // explicit notification about component destruction. this can be a drag target
  DragManager.Notification(Self, opRemove);
  Application.ControlDestroyed(Self);
  if (FHostDockSite <> nil) and not (csDestroying in FHostDockSite.ComponentState) then
  begin
    FHostDockSite.DoUndockClientMsg(nil, Self);
    SetParent(nil);
    Dock(nil, BoundsRect);
    FHostDockSite := nil;
  end else
  begin
    if Assigned(FHostDockSite) and Assigned(FHostDockSite.FDockClients) then
    begin
      FHostDockSite.FDockClients.Remove(Self);
      FHostDockSite := nil;
    end;
    SetParent(nil);
  end;
  if FAnchoredControls <> nil then
  begin
    for i := 0 to FAnchoredControls.Count - 1 do
      for Side := Low(TAnchorKind) to High(TAnchorKind) do
      begin
        CurAnchorSide := AnchoredControls[i].AnchorSide[Side];
        if (CurAnchorSide<>nil) and (CurAnchorSide.FControl = Self) then
          CurAnchorSide.FControl := nil;
      end;
    FreeThenNil(FAnchoredControls);
  end;
  FreeThenNil(FActionLink);
  for Side := Low(FAnchorSides) to High(FAnchorSides) do
    FreeThenNil(FAnchorSides[Side]);
  FreeThenNil(FBorderSpacing);
  FreeThenNil(FConstraints);
  FreeThenNil(FFont);
  FreeThenNil(FAccessibleObject);
  //DebugLn('[TControl.Destroy] B ',DbgSName(Self));
  inherited Destroy;                      <-------- Here it is showing the problem.
  //DebugLn('[TControl.Destroy] END ',DbgSName(Self));
  for HandlerType := Low(TControlHandlerType) to High(TControlHandlerType) do
    FreeThenNil(FControlHandlers[HandlerType]);
  {$IFDEF DebugDisableAutoSizing}
  FreeAndNil(FAutoSizingLockReasons);
  {$ENDIF}
end;                             
« Last Edit: March 11, 2017, 02:47:20 am by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: Help tracing a sigsev fault on applicatin exit.
« Reply #18 on: March 12, 2017, 03:29:40 am »
Addition.

GDb Backtrace is displaying this
Code: [Select]
(gdb) run
Starting program: C:\My_Projects_and_Components\My_Projects\VK\vk.exe
[New Thread 1160.0x1d64]
[New Thread 1160.0x15c4]
[New Thread 1160.0x1520]
Create :  <--- Added to debugln when entering form create
Activate : <--- Added to debugln when entering form activate
[New Thread 1160.0x1eac]
[New Thread 1160.0x1f58]
Query Close <--- Added to debugln when entering form QUeryClose
First Line of FOrm CLose  <--- Added to debugln when on first line of form close
[Thread 1160.0x1f58 exited with code 0]
[Thread 1160.0x1eac exited with code 0]
Last Line of Form Close <--- Added to debugln when on last line line of form close

Program received signal SIGSEGV, Segmentation fault.
0x0040dfaf in SYSTEM$_$TOBJECT_$__$$_FREE ()
(gdb)

(gdb) bt
#0  0x0040dfaf in SYSTEM$_$TOBJECT_$__$$_FREE ()
#1  0x0064decc in BCTYPES$_$TBCBACKGROUND_$__$$_DESTROY ()
#2  0x0040dfb2 in SYSTEM$_$TOBJECT_$__$$_FREE ()
#3  0x00620ffc in BCBUTTON$_$TBCBUTTONSTATE_$__$$_DESTROY ()
#4  0x0040dfb2 in SYSTEM$_$TOBJECT_$__$$_FREE ()
#5  0x0062343a in BCBUTTON$_$TCUSTOMBCBUTTON_$__$$_DESTROY ()
#6  0x0045cc47 in CLASSES$_$TCOMPONENT_$__$$_DESTROYCOMPONENTS ()
#7  0x0045cbc2 in CLASSES$_$TCOMPONENT_$__$$_DESTROY ()
#8  0x02249a40 in ?? ()
#9  0x00546d97 in DESTROY (this=0x2249a40, vmt=0x0) at include/control.inc:4991
#10 0x00536490 in DESTROY (this=0x2249a40, vmt=0x0) at include/wincontrol.inc:6600
#11 0x00548c3b in DESTROY (this=0x2249a40, vmt=0x0) at include/customcontrol.inc:54
#12 0x0041dec8 in DESTROY (this=0x2249a40, vmt=0x0) at include/scrollingwincontrol.inc:316
#13 0x0041f516 in DESTROY (this=0x2249a40, vmt=0x1) at include/customform.inc:212
#14 0x0040dfb2 in SYSTEM$_$TOBJECT_$__$$_FREE ()
#15 0x0042b9bb in DOBEFOREFINALIZATION (this=0x223f550) at include/application.inc:1085
#16 0x0041b0fd in BEFOREFINALIZATION () at forms.pp:1901
#17 0x00410641 in SYSTEM_$$_SYSFLUSHSTDIO ()
#18 0x020cfe74 in ?? ()
#19 0x00415986 in SYSTEM_$$_EXE_ENTRY$TENTRYINFORMATION ()

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Help tracing a sigsev fault on applicatin exit.
« Reply #19 on: March 13, 2017, 09:33:41 am »
Addition.

GDb Backtrace is displaying this
Code: [Select]
(gdb) run
Starting program: C:\My_Projects_and_Components\My_Projects\VK\vk.exe
[New Thread 1160.0x1d64]
[New Thread 1160.0x15c4]
[New Thread 1160.0x1520]
Create :  <--- Added to debugln when entering form create
Activate : <--- Added to debugln when entering form activate
[New Thread 1160.0x1eac]
[New Thread 1160.0x1f58]
Query Close <--- Added to debugln when entering form QUeryClose
First Line of FOrm CLose  <--- Added to debugln when on first line of form close
[Thread 1160.0x1f58 exited with code 0]
[Thread 1160.0x1eac exited with code 0]
Last Line of Form Close <--- Added to debugln when on last line line of form close

Program received signal SIGSEGV, Segmentation fault.
0x0040dfaf in SYSTEM$_$TOBJECT_$__$$_FREE ()
(gdb)

(gdb) bt
#0  0x0040dfaf in SYSTEM$_$TOBJECT_$__$$_FREE ()
#1  0x0064decc in BCTYPES$_$TBCBACKGROUND_$__$$_DESTROY ()
#2  0x0040dfb2 in SYSTEM$_$TOBJECT_$__$$_FREE ()
#3  0x00620ffc in BCBUTTON$_$TBCBUTTONSTATE_$__$$_DESTROY ()
#4  0x0040dfb2 in SYSTEM$_$TOBJECT_$__$$_FREE ()
#5  0x0062343a in BCBUTTON$_$TCUSTOMBCBUTTON_$__$$_DESTROY ()
#6  0x0045cc47 in CLASSES$_$TCOMPONENT_$__$$_DESTROYCOMPONENTS ()
#7  0x0045cbc2 in CLASSES$_$TCOMPONENT_$__$$_DESTROY ()
#8  0x02249a40 in ?? ()
#9  0x00546d97 in DESTROY (this=0x2249a40, vmt=0x0) at include/control.inc:4991
#10 0x00536490 in DESTROY (this=0x2249a40, vmt=0x0) at include/wincontrol.inc:6600
#11 0x00548c3b in DESTROY (this=0x2249a40, vmt=0x0) at include/customcontrol.inc:54
#12 0x0041dec8 in DESTROY (this=0x2249a40, vmt=0x0) at include/scrollingwincontrol.inc:316
#13 0x0041f516 in DESTROY (this=0x2249a40, vmt=0x1) at include/customform.inc:212
#14 0x0040dfb2 in SYSTEM$_$TOBJECT_$__$$_FREE ()
#15 0x0042b9bb in DOBEFOREFINALIZATION (this=0x223f550) at include/application.inc:1085
#16 0x0041b0fd in BEFOREFINALIZATION () at forms.pp:1901
#17 0x00410641 in SYSTEM_$$_SYSFLUSHSTDIO ()
#18 0x020cfe74 in ?? ()
#19 0x00415986 in SYSTEM_$$_EXE_ENTRY$TENTRYINFORMATION ()

Finally! Stack trace! Problem is with TBCButton control from BGRAControls package. Looks like Background property of TBCButtonState is corrupted. This class is used for StateNormal, StateHover and StateClicked properties of TCustomBCButton.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

 

TinyPortal © 2005-2018