Crash in TFastLineSeries.Clear

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
axrDegen
Newbie
Newbie
Posts: 31
Joined: Mon Jan 14, 2019 12:00 am

Crash in TFastLineSeries.Clear

Post by axrDegen » Fri Mar 27, 2020 3:40 pm

Hello,

Since version V2019.28 we see often the following crash (not reproducible in a test project yet)
when freeing a window with a TChart:
callStackCapture.PNG
callStackCapture.PNG (23.08 KiB) Viewed 938 times
The multiple TFastLineSeries are created runtime like that:

Code: Select all

procedure CreateNewSeries(ParentChart: TChart; SeriesTitle: string;
                          SeriesColor: TColor; SeriesLineWidth: Integer;
                          ProfilePoints: TProfilePoints);
var
  i: Integer;
  tmpLineSeries: TFastLineSeries;
begin
  if Length(ProfilePoints) > 0 then
  begin
    tmpLineSeries := TFastLineSeries.Create(ParentChart);
    tmpLineSeries.ParentChart := ParentChart;
    tmpLineSeries.BeginUpdate;
    try
      tmpLineSeries.Color := SeriesColor;
      tmpLineSeries.Title := SeriesTitle;
      tmpLineSeries.LinePen.Width := SeriesLineWidth;
      for i := 0 to High(ProfilePoints) do
        tmpLineSeries.AddXY(ProfilePoints[i].X, ProfilePoints[i].Y);
    finally
      tmpLineSeries.EndUpdate;
      tmpLineSeries.Active := True;
    end;
  end;
end;
When we use older TChert sources or when we use TLineSeries instead of TFastLineSeries no such crashes occur.
Any thoughts about what could happen in TFastLineSeries.Clear or what could be wrong with creation of the TFastLineSeries?

best regards

Yeray
Site Admin
Site Admin
Posts: 8838
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Crash in TFastLineSeries.Clear

Post by Yeray » Fri Mar 27, 2020 4:39 pm

Hello,

I've been trying to reproduce the problem with your code in a simple example without success. The call stack looks like the one you've posted but Clear method ends without errors.
While you can't send us a simple example, if you can tell us in what TeeChart version you weren't reproducing the problem, it may help us to reduce the scope.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

axrDegen
Newbie
Newbie
Posts: 31
Joined: Mon Jan 14, 2019 12:00 am

Re: Crash in TFastLineSeries.Clear

Post by axrDegen » Fri Mar 27, 2020 5:25 pm

Hi Yeray,

we see these crashes and call stacks since version V2019.28.
Before that version, we were using V2018.25.180808 (I update the code November 13th 2018) and I updated TChart sources on
December 10th 2018 (don't know what versions that was) without any crashes.
So from version V2019.28 on we see this call stack, without that something in the rest of the surrounding code changed.
I actually just compared the codes in SVN (VCLTee.Series.pas), it looks like the Clear procedure wasn't present in these earlier code versions?

Yeray
Site Admin
Site Admin
Posts: 8838
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Crash in TFastLineSeries.Clear

Post by Yeray » Mon Mar 30, 2020 6:18 am

Hello,

I see the TFastLineSeries.Clear method was introduced in v2019.28, to fix #2237. However, since I can't reproduce the problem I can't be sure if that is causing the issue you are observing.
Since you own the sources, may I ask you to try and see if removing that method solves the problem for you? Or even better, you could set the "Source\VCL" path in your Library path and debug the sources to see what is exactly crashing.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

axrDegen
Newbie
Newbie
Posts: 31
Joined: Mon Jan 14, 2019 12:00 am

Re: Crash in TFastLineSeries.Clear

Post by axrDegen » Mon Mar 30, 2020 8:35 am

Hi Yeray,

I debugged this already, it seems the clear gets still executed when everything is already destroyed.

Code: Select all

procedure TFastLineSeries.Clear;
begin
  inherited;
  if (ParentChart <> nil) then
    With ParentChart,Canvas do
    begin
        OldX := GetVertAxis.PosAxis; //LeftAxis.PosAxis;
        OldY := GetHorizAxis.PosAxis; //BottomAxis.PosAxis;
        if View3D then MoveTo3D(OldX,OldY,MiddleZ)
                  else MoveTo(OldX,OldY);
    end;
end;
The Crash then happens on line: 11699 => else MoveTo(OldX,OldY);
ParentChart is still <> nil interstingly

When in the code where the TFastLineSeries is filled:

Code: Select all

 if Length(ProfilePoints) > 0 then
  begin
    tmpLineSeries := TFastLineSeries.Create(ParentChart);
    // tmpLineSeries.ParentChart := ParentChart;
    tmpLineSeries.BeginUpdate;
    try
      tmpLineSeries.Color := SeriesColor;
      tmpLineSeries.Title := SeriesTitle;
      tmpLineSeries.LinePen.Width := SeriesLineWidth;
      for i := 0 to High(ProfilePoints) do
        tmpLineSeries.AddXY(ProfilePoints[i].X, ProfilePoints[i].Y);
    finally
      tmpLineSeries.EndUpdate;
      tmpLineSeries.Active := True;
    end;
  end;
I Don't assign "tmpLineSeries.ParentChart" I also can prevent the crash.
Not that the TChart instance is on a Frame that is put on a DockPanel and the DockPanel is on a MDI Childform

axrDegen
Newbie
Newbie
Posts: 31
Joined: Mon Jan 14, 2019 12:00 am

Re: Crash in TFastLineSeries.Clear

Post by axrDegen » Mon Mar 30, 2020 6:05 pm

I had another look with the debugger in "procedure TFastLineSeries.Clear", so ParentChart is Assigned fine in that situation but
ParentChart.Canvas is NIL. So obviously that case needs to be checked too in that code like:

Code: Select all

 if (ParentChart <> nil) and (ParentChart.Canvas <> nil) then
    With ParentChart,Canvas do
not sure how that can happen though

Yeray
Site Admin
Site Admin
Posts: 8838
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Crash in TFastLineSeries.Clear

Post by Yeray » Tue Mar 31, 2020 4:36 am

Hello,

I was going to apply your suggestion and found it was already in our main codebase (so it will be included in the next maintenance release). That could explain why I wasn't able to reproduce the problem.
Then I found it was actually a fix proposed by another customer here.
I'm sorry for the time you lost with this.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply