Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory corruption due to invalid column position in DFM file #1179

Closed
radioboss opened this issue Mar 9, 2023 · 6 comments
Closed

Memory corruption due to invalid column position in DFM file #1179

radioboss opened this issue Mar 9, 2023 · 6 comments
Labels
Milestone

Comments

@radioboss
Copy link

There appears to be a bug with reading columns. If "Columns" property contains columns with Position = N where, for some of the columns, N is larger than valid column index, there's memory corruption.

Following is the log from FastMM in full debug mode (there were 6 columns, and for column at index 3, Position was set to 7):

Memory Corruption Detected

A memory block footer has been corrupted.

The block size is 36.

The block was allocated by thread 0x3520, and the stack trace (return addresses) at the time was:

00420622 [FastMM5.pas][FastMM5][FastMM_DebugGetMem$qqri][7781]

0040733D [System.pas][System][@ReallocMem$qqrrpvi][5141]

0040E8E7 [System.pas][System][DynArraySetLength$qqrrpvpvipi][36790]

004072EA [System.pas][System][@FreeMEM$qqrpv][4997]

0040EA4E [System.pas][System][@DynArraySetLength$qqrv][36895]

00A3C48C [VirtualTrees.pas][VirtualTrees][TVirtualTreeColumns.InitializePositionArray][8355]

00A3C687 [VirtualTrees.pas][VirtualTrees][TVirtualTreeColumns.EndUpdate][8432]

00545589 [System.Classes.pas][System.Classes][Classes.TReader.ReadCollection][11210]

00A41819 [VirtualTrees.pas][VirtualTrees][TVTHeader.ReadColumns][11049]

00544642 [System.Classes.pas][System.Classes][Classes.TReader.DefineProperty][10608]

00A5159C [VirtualTrees.pas][VirtualTrees][TBaseVirtualTree.DefineProperties][18911]

00A6FFAC [VirtualTrees.pas][VirtualTrees][TCustomVirtualStringTree.DefineProperties][34145]

005463B9 [System.Classes.pas][System.Classes][Classes.TReader.ReadProperty][11627]

00545CDE [System.Classes.pas][System.Classes][Classes.TReader.ReadDataInner][11391]

005EFCF6 [Vcl.Controls.pas][Vcl.Controls][Controls.TWinControl.SetParent][14251]

00545CBE [System.Classes.pas][System.Classes][Classes.TReader.ReadData][11384]

00553702 [System.Classes.pas][System.Classes][Classes.TComponent.ReadState][17354]

005E2878 [Vcl.Controls.pas][Vcl.Controls][Controls.TControl.ReadState][5823]

005E740E [Vcl.Controls.pas][Vcl.Controls][Controls.TWinControl.ReadState][8916]

00545B0A [System.Classes.pas][System.Classes][Classes.TReader.ReadComponent][11345]

@joachimmarder
Copy link
Contributor

Please respect our guidelines on the project homepage for submitting bugs. Please include your version of Virtual TreeView and Delphi, and attach a sample compiling project as ZIP to your report, or instructions how to modify one of the included sample projects to reproduce the problem.

From the call stack it is hard to tell what went wrong.

@joachimmarder joachimmarder added Bug Repro Steps Missing A smple project is needed to reprodcue and analyze the issue. See our guidelines for opening issues! labels Mar 9, 2023
@joachimmarder
Copy link
Contributor

there were 6 columns, and for column at index 3, Position was set to 7

How exactly did that happen?

@radioboss
Copy link
Author

radioboss commented Mar 10, 2023

How exactly did that happen

There were more columns, with custom positions set. Then some of the columns were removed, but invalid positions for the remaining stayed.

@radioboss
Copy link
Author

radioboss commented Mar 10, 2023

I use latest Delphi 11.3, and the latest release version of Virtual Trees. Attached is an example project.
vt_corrupt.zip

joachimmarder added a commit that referenced this issue Mar 11, 2023
@joachimmarder joachimmarder removed the Repro Steps Missing A smple project is needed to reprodcue and analyze the issue. See our guidelines for opening issues! label Mar 11, 2023
@joachimmarder
Copy link
Contributor

joachimmarder commented Mar 11, 2023

I see, the invalid position was written to the DFM file. Was this DFM file created with Virtual TreeView V7.6.3?

Please try if my fix solves the issue in your project. It does for the attached sample project.

@joachimmarder joachimmarder changed the title Memory corruption Memory corruption due to invalid column position in DFM file Mar 11, 2023
@joachimmarder joachimmarder added this to the V7.6.4 milestone Mar 11, 2023
@radioboss
Copy link
Author

Thank you, the fix worked!

joachimmarder added a commit that referenced this issue Mar 12, 2023
joachimmarder added a commit that referenced this issue Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants