View Issue Details

IDProjectCategoryView StatusLast Update
0036910LazarusIDEpublic2020-05-19 18:56
ReporterMartin Friebe Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionreopened 
Platform64bit IntelOSwin 10 
Product Version2.1 (SVN) 
Summary0036910: Crash when closing project options
Description- Open IDE
- Open Project Options
- Hit Escape to cancel

gives an access violation.

It depends on accessing a free'd object. So it may not always be reproducible.
It should happen with -gh / Maybe needs env HEAPTRC="keepreleased"


ide\ideoptionsdlg.pas line385
procedure TIDEOptionsDialog.WriteAll(Restore: boolean);

In the last stage (sfAfter)

        Instance := Rec^.GroupClass.GetInstance;
will get the CompilerOptions
            Instance.DoAfterWrite(Restore);
calls
  procedure TAbstractIDEOptions.DoAfterWrite(Restore: boolean);
      FOnAfterWrite(Self,Restore);
calls
procedure TProjectCompilerOptions.AfterWriteExec(Sender:TObject;Restore:boolean);
begin
 if Restore and (LazProject<>nil) then
   LazProject.RestoreBuildModes;
end;

and RestoreBuildModes frees the instance of CompileOptions.
The calling code still uses that instance....
TagsNo tags attached.
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Relationships

duplicate of 0036782 closedJuha Manninen IDE crash 

Activities

Juha Manninen

2020-04-17 20:40

developer   ~0122213

Fixed together with 0036782.

Martin Friebe

2020-05-19 03:14

manager   ~0122920

Not fixed.

Not sure how copying the handlers should help

While in DoAfterWrite the instance "self" gets freed by one of the Handlers.
DoAfterWrite keeps running and accessig self.fhandlers. Only self now points to invalid memory, and if that memory was reused => boom

Juha Manninen

2020-05-19 18:16

developer   ~0122935

Oh boy ...
I was sure it got fixed in r63009.

> While in DoAfterWrite the instance "self" gets freed by one of the Handlers.
By which handler?

Martin Friebe

2020-05-19 18:50

manager   ~0122937

Last edited: 2020-05-19 18:56

View 2 revisions

As described: "and RestoreBuildModes frees the instance of CompileOptions" => See the call description in orig report

      Access violation
        Stack trace:
        $0000000100117851 line 194 of lazmethodlist.pas
        $0000000100058025 line 404 of ideoptionsintf.pas
        $00000001008023F8 line 411 of ideoptionsdlg.pas
        $0000000100076A36 line 5032 of main.pp
        $0000000100073B30 line 4434 of main.pp
        $0000000100073C9E line 4446 of main.pp
        $0000000100502D9D line 1521 of idecommands.pas
        $000000010006F5E3 line 3659 of main.pp
        $00000001007003F1 line 8781 of sourceeditor.pp
        $00000001006E8E1F line 4123 of sourceeditor.pp
        $00000001004B87CC line 7463 of synedit.pp
        $00000001004B38DF line 6653 of synedit.pp
        $00000001004A1C5F line 3014 of synedit.pp
        $00000001001FB791 line 5702 of include/wincontrol.inc
        $00000001001FBB90 line 5833 of include/wincontrol.inc
        $00000001001FFBB7 line 7222 of include/wincontrol.inc

procedure TAbstractIDEOptions.DoAfterWrite(Restore: boolean);
var
  i: LongInt;
begin
  if Assigned(FOnAfterWrite) then
    FOnAfterWrite(Self,Restore); // <<<<<<<<<<<<<<<<<<<<<<<< this causes the current SELF object to be destroyed
  i:=fHandlers[iohAfterWrite].Count; // <<<<<<<<<<<<<<<<<<<<<<<< line 404 of ideoptionsintf.pas
  while fHandlers[iohAfterWrite].NextDownIndex(i) do
    TIDEOptionsWriteEvent(fHandlers[iohAfterWrite][i])(Self,Restore);
end;

In line 404 self does not exist / self is a dangling pointer . ( -gh should have DEADBEAF'ed the memory). So the field "fhandlers" is deadbeaf, and accessing Count crashes.

Martin Friebe

2020-05-19 18:55

manager   ~0122938

>> quote
- Open IDE
- Open Project Options
- Hit Escape to cancel
<<

Maybe also make sure to go to a page of the "Compiler Options" part.

Issue History

Date Modified Username Field Change
2020-04-13 16:17 Martin Friebe New Issue
2020-04-13 18:29 Juha Manninen Relationship added duplicate of 0036782
2020-04-17 20:36 Juha Manninen Assigned To => Juha Manninen
2020-04-17 20:36 Juha Manninen Status new => assigned
2020-04-17 20:40 Juha Manninen Status assigned => resolved
2020-04-17 20:40 Juha Manninen Resolution open => duplicate
2020-04-17 20:40 Juha Manninen LazTarget => -
2020-04-17 20:40 Juha Manninen Note Added: 0122213
2020-05-19 03:14 Martin Friebe Status resolved => assigned
2020-05-19 03:14 Martin Friebe Resolution duplicate => reopened
2020-05-19 03:14 Martin Friebe Note Added: 0122920
2020-05-19 18:16 Juha Manninen Note Added: 0122935
2020-05-19 18:50 Martin Friebe Note Added: 0122937
2020-05-19 18:55 Martin Friebe Note Added: 0122938
2020-05-19 18:56 Martin Friebe Note Edited: 0122937 View Revisions