View Issue Details

IDProjectCategoryView StatusLast Update
0038376LazarusOtherpublic2021-01-22 06:17
ReporterUwe Schächterle Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformAll 
Product Version2.0.10 
Summary0038376: Lazbuild crashes when loading a invalid environment (patch in uploaded files)
DescriptionWhen Loading a not supported Environment the typecast

OldActiveDesktop := TDesktopOpt(FDesktops.Find(OldActiveDesktopName));

crashes

this could be fixed by the patch i attached.
Steps To Reproduceon my system everytime i run lazbuild this happens
Additional Informationat first i installed Lazarus
then i deleted everything expect the fpc folder
then i did a checkout into the lazarus folder and hit make

=> maybe this left some strange / invalid environment settings, that leed lazbuid to crash
TagsNo tags attached.
Fixed in Revisionr64414
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Uwe Schächterle

2021-01-20 12:29

reporter  

environmentopts.pp.patch (1,087 bytes)   
Index: environmentopts.pp
===================================================================
--- environmentopts.pp	(Revision 64405)
+++ environmentopts.pp	(Arbeitskopie)
@@ -3678,7 +3678,7 @@
   end;
 
 var
-  OldActiveDesktop: TDesktopOpt;
+  OldActiveDesktop: TCustomDesktopOpt;
   OldActiveDesktopName: string;
   lDskTpOpt: TCustomDesktopOpt;
 
@@ -3711,7 +3711,8 @@
   Result.Assign(FDesktop);
   if Assigned(IDEDockMaster) then
     Result.FDockedOpt.LoadDefaults;
-  OldActiveDesktop := TDesktopOpt(FDesktops.Find(OldActiveDesktopName));
+  OldActiveDesktop := FDesktops.Find(OldActiveDesktopName);
+  if not (OldActiveDesktop is TDesktopOpt) then OldActiveDesktop :=  nil;
   if not Assigned(OldActiveDesktop) then
   begin
     lDskTpOpt := FDesktops.Find('default');
@@ -3721,7 +3722,7 @@
       OldActiveDesktop := nil;
   end;
   if Assigned(OldActiveDesktop) then
-    Result.Assign(OldActiveDesktop, False, False);
+    Result.Assign(TDesktopOpt(OldActiveDesktop), False, False);
 end;
 
 procedure TEnvironmentOptions.SetTestBuildDirectory(const AValue: string);
environmentopts.pp.patch (1,087 bytes)   

Juha Manninen

2021-01-20 14:26

developer   ~0128449

Last edited: 2021-01-20 14:46

View 3 revisions

Actually this is not related to 0038377.
The code your patch changes has been there for some time and nobody complained. I could not reproduce the crash in my test now.
We need exact steps to reproduce.
It is also possible your configuration is corrupt for some reason. Please try with a fresh default config.

Another issue is that LazBuild is a command line program and should not depend on LCL nor should it read Desktop settings from EnvironmentOptions.
I have refactored code little by little to reduce dependencies. Getting rid of LCL and IdeIntf is still far away. There are so many complex dependencies.

Uwe Schächterle

2021-01-21 06:39

reporter   ~0128457

With related i meant, that i needed both patches to get lazbuild to work on my system, sorry for that misspelling.

As you can see in EnvironmentOps.pas on Line 1819

<quote>
procedure TDesktopOptList.AddFromCfg(Path: String);
var
  dsk: TCustomDesktopOpt;
  dskClass: TDesktopOptClass;
  dskName, dskDockMaster: String;
begin
  dskName := FXMLCfg.GetValue(Path+'Name', 'default');
  dskDockMaster := FXMLCfg.GetValue(Path+'DockMaster', '');

  if IndexOf(dskname) >=0 then
    exit;

  if TEnvironmentOptions.DesktopCanBeLoaded(dskDockMaster) then
     dskClass := TDesktopOpt
   else
     dskClass := TUnsupportedDesktopOpt; // <--- here it is

  dsk := dskClass.Create(dskName, dskDockMaster<>'');
  dsk.SetConfig(FXMLCfg, FConfigStore);
  dsk.Load(Path);
  Add(dsk);
end;
<\quote>

it is absolutely possible for the list to store a "TUnsupportedDesktopOpt" this was the case in my situation. My patch is detecting this and therefore skip the desktop.

Juha Manninen

2021-01-21 16:52

developer   ~0128464

Last edited: 2021-01-21 16:53

View 2 revisions

I applied a little simplified version, thanks. Please test.
Indeed the code was wrong although I could not reproduce a crash.
There has been some mysterious problems reported. This could be a potential cause.

Uwe Schächterle

2021-01-22 06:17

reporter   ~0128479

tested, works for me, thank you

Issue History

Date Modified Username Field Change
2021-01-20 12:29 Uwe Schächterle New Issue
2021-01-20 12:29 Uwe Schächterle File Added: environmentopts.pp.patch
2021-01-20 14:04 Juha Manninen Relationship added related to 0038377
2021-01-20 14:22 Juha Manninen Relationship deleted related to 0038377
2021-01-20 14:26 Juha Manninen Note Added: 0128449
2021-01-20 14:26 Juha Manninen Note Edited: 0128449 View Revisions
2021-01-20 14:46 Juha Manninen Note Edited: 0128449 View Revisions
2021-01-21 06:39 Uwe Schächterle Note Added: 0128457
2021-01-21 10:25 Juha Manninen Assigned To => Juha Manninen
2021-01-21 10:25 Juha Manninen Status new => assigned
2021-01-21 16:52 Juha Manninen Status assigned => resolved
2021-01-21 16:52 Juha Manninen Resolution open => fixed
2021-01-21 16:52 Juha Manninen Fixed in Revision => r64414
2021-01-21 16:52 Juha Manninen LazTarget => -
2021-01-21 16:52 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2021-01-21 16:52 Juha Manninen Note Added: 0128464
2021-01-21 16:53 Juha Manninen Note Edited: 0128464 View Revisions
2021-01-22 06:17 Uwe Schächterle Note Added: 0128479