TurboPack / MustangpeakVirtualshellTools

Delphi and CBuilder Components to create Explorer type programs
Other
49 stars 24 forks source link

FastMM4 detects block been modified after being freed #16

Closed luebbe closed 3 years ago

luebbe commented 3 years ago

The error occurs with the following set of MP components (should be the latest):

Just drop a TVirtualExplorerTree or any of its siblings onto an empty form. No need to configure anything. Add FastMM (in my case Version 4) to the project, compile with FullDebugMode and start/stop the application.

The following error is shown upon termination, once for each TVirtual(Explorer|Combobox|...). No error with a standard TVirtualTreeview, so I guess the error is triggered by, but not necessarily in TVirtualExplorerTree.

--------------------------------2020/11/26 15:26:07--------------------------------
FastMM has detected an error during a free block scan operation. FastMM detected that a block has been modified after being freed. 

Modified byte offsets (and lengths): 4(4)

The previous block size was: 36

This block was previously allocated by thread 0x2FF8, and the stack trace (return addresses) at the time was:
4070A2 [System.pas][System][@GetMem$qqri][4830]
408087 [System.pas][System][TObject.NewInstance][17514]
408856 [System.pas][System][@ClassCreate$qqrpvzc][18867]
5DE59A [Vcl.ImgList.pas][Vcl.ImgList][Imglist.TChangeLink.Create][1610]
646698 [VirtualTrees.pas][VirtualTrees][TBaseVirtualTree.Create][12069]
672BB4 [VirtualTrees.pas][VirtualTrees][TCustomVirtualStringTree.Create][33395]
6CB864 [VirtualExplorerTree.pas][VirtualExplorerTree][TCustomVirtualExplorerTree.Create][3609]
477898 [System.Classes.pas][System.Classes][CreateComponent][10859]
477AC5 [System.Classes.pas][System.Classes][Classes.TReader.ReadComponent][10905]
4070BE [System.pas][System][@FreeMem$qqrpv][4878]
40A095 [System.pas][System][@UStrClr$qqrpv][25505]

The block was previously used for an object of class: Vcl.ImgList.TChangeLink

The allocation number was: 1150

The block was previously freed by thread 0x2FF8, and the stack trace (return addresses) at the time was:
4070BE [System.pas][System][@FreeMem$qqrpv][4878]
4080A5 [System.pas][System][TObject.FreeInstance][17523]
4088A1 [System.pas][System][@ClassDestroy$qqrxp14System.TObject][18910]
531567 [System.ImageList.pas][System.ImageList][Imagelist.TImageLink.Destroy][228]
40819B [System.pas][System][TObject.Free][17586]
6469BE [VirtualTrees.pas][VirtualTrees][TBaseVirtualTree.Destroy][12148]
408E47 [System.pas][System][TMonitor.Exit][19334]
674229 [VirtualTrees.pas][VirtualTrees][TCustomVirtualStringTree.Destroy][33955]
6CC37B [VirtualExplorerTree.pas][VirtualExplorerTree][TCustomVirtualExplorerTree.Destroy][3872]
4088A1 [System.pas][System][@ClassDestroy$qqrxp14System.TObject][18910]
5F33F4 [Vcl.Forms.pas][Vcl.Forms][Forms.TScrollingWinControl.Destroy][3122]

The current thread ID is 0x2FF8, and the stack trace (return addresses) leading to this error is:
419F40 [FastMM4.pas][FastMM4][CheckBlocksOnShutdown$qqro][11459]
41AD2E [FastMM4.pas][FastMM4][FinalizeMemoryManager$qqrv][13003]
41AD90 [FastMM4.pas][FastMM4][Finalization$qqrv][13102]
4099C8 [System.pas][System][FinalizeUnits$qqrv][23331]
409E19 [System.pas][System][@Halt0$qqrv][24818]
6F1013 
75A1FA29 [BaseThreadInitThunk]
774F75F4 [RtlGetAppContainerNamedObjectPath]
774F75C4 [RtlGetAppContainerNamedObjectPath]

Current memory dump of 256 bytes starting at pointer address 7F8A5070:
84 FC 6F 00 00 00 00 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 40 27 42 79 00 00 00 00 F1 4F 8A 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
7F 04 00 00 A2 70 40 00 87 80 40 00 56 88 40 00 9A E5 5D 00 C3 66 64 00 B4 2B 67 00 64 B8 6C 00
98 78 47 00 C5 7A 47 00 BE 70 40 00 95 A0 40 00 F8 2F 00 00 F8 2F 00 00 BE 70 40 00 A5 80 40 00
A1 88 40 00 67 15 53 00 9B 81 40 00 CC 69 64 00 47 8E 40 00 29 42 67 00 7B C3 6C 00 A1 88 40 00
F4 33 5F 00 24 00 00 00 80 AA 5D 00 A9 D9 BD 86 84 FC 6F 00 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 56 26 42 79 00 00 00 00 A1 50 8A 7F
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 04 00 00 A2 70 40 00 87 80 40 00 56 88 40 00
�  �  o  .  .  .  .  .  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �
�  �  �  �  @  '  B  y  .  .  .  .  �  O  �    .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
  .  .  .  �  p  @  .  �  �  @  .  V  �  @  .  �  �  ]  .  �  f  d  .  �  +  g  .  d  �  l  .
�  x  G  .  �  z  G  .  �  p  @  .  �  �  @  .  �  /  .  .  �  /  .  .  �  p  @  .  �  �  @  .
�  �  @  .  g  .  S  .  �  �  @  .  �  i  d  .  G  �  @  .  )  B  g  .  {  �  l  .  �  �  @  .
�  3  _  .  $  .  .  .  �  �  ]  .  �  �  �  �  �  �  o  .  �  �  �  �  �  �  �  �  �  �  �  �
�  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  V  &  B  y  .  .  .  .  �  P  �  
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  �  .  .  .  �  p  @  .  �  �  @  .  V  �  @  .
pyscripter commented 3 years ago

Thanks, I will have a look.

pyscripter commented 3 years ago

Does adding

Images := nil

as the first statement in TCustomVirtualExplorerTree.Destroy;

resolve this?

luebbe commented 3 years ago

I'll check on Monday. No Delphi on my PC at home.

luebbe commented 3 years ago

Yes it does, thank you very much.

pyscripter commented 3 years ago

This should really be done in the base class. I will create an issue at Virtualtree.

pyscripter commented 3 years ago

Issue created https://github.com/JAM-Software/Virtual-TreeView/issues/1002