Print Page | Close Window

FNCSearchEdit and FastMM problem

Printed From: TMS Software
Category: FNC Components
Forum Name: FNC UI Pack
Forum Discription:
Printed Date: 21 Jan 2020 at 6:34pm

Topic: FNCSearchEdit and FastMM problem
Posted By: King Susan
Subject: FNCSearchEdit and FastMM problem
Date Posted: 20 May 2019 at 7:50am

I use FastMM  4.991 downloaded from github.

I add a SearchEdit to a new form, and select an item from the default list and then close the program.

FastMM is reporting

FastMM has detected an attempt to use an interface of a freed object. An access violation will now be raised in order to abort the current operation.

The current thread ID is 0x2288, and the stack trace (return addresses) leading to this error is:
40E93F [System.pas][System][@IntfCopy$qqrr44System.%DelphiInterface$17System.IInterface%x44System.%DelphiInterface$17System.IInterface%][38227]
A11EFB [FMX.TMSFNCStyles.pas][FMX.TMSFNCStyles][Tmsfncstyles.TTMSFNCStyles.SetActiveScene][1742]
A1A498 [FMX.TMSFNCCustomControl.pas][FMX.TMSFNCCustomControl][Tmsfnccustomcontrol.TTMSFNCCustomControlBase.Destroy][1210]
A1AEC1 [FMX.TMSFNCCustomControl.pas][FMX.TMSFNCCustomControl][Tmsfnccustomcontrol.TTMSFNCCustomControl.Destroy][2041]
BE4BAF [FMX.TMSFNCToolBar.pas][FMX.TMSFNCToolBar][Tmsfnctoolbar.TTMSFNCCustomToolBarElement.Destroy][6434]
BDF7B1 [FMX.TMSFNCToolBar.pas][FMX.TMSFNCToolBar][Tmsfnctoolbar.TTMSFNCDefaultToolBarButton.Destroy][4339]
4084C3 [System.pas][System][TObject.Free][17466]
BC205B [FMX.TMSFNCEdit.pas][FMX.TMSFNCEdit][Tmsfncedit.TTMSFNCEditButton.Destroy][2317]
C12CA9 [FMX.TMSFNCSearchEdit.pas][FMX.TMSFNCSearchEdit][Tmsfncsearchedit.TTMSFNCSearchDropDown.Destroy][770]
4084C3 [System.pas][System][TObject.Free][17466]
C11DED [FMX.TMSFNCSearchEdit.pas][FMX.TMSFNCSearchEdit][Tmsfncsearchedit.TTMSFNCSearchEdit.Destroy][403]

Is this something that can be fixed ? It doesn't happen with the version of FastMM shipped with Delphi.

I do have $defineCatchUseOfFreedInterfaces.  With this turned off, there is an error : 'Project SearchEditTest.exe raised exception class $C0000005 with message 'access violation at 0x0040e758: read address of 0x80808080'.


Posted By: Pieter Scheldeman
Date Posted: 20 May 2019 at 11:49am

I can only assume that this is a false positive marked by FastMM, we haven't received other reports. The SetActiveScene call is a class procedure that clears a global variable FScene: IScene in the destroy sequence of the component. This call is necessary to avoid invalid pointer issues. I suggest to raise this question with the developers of FastMM or use the default FastMM version in Delphi, where this issue does not occur.

Posted By: King Susan
Date Posted: 21 May 2019 at 3:07am
I have had a bit more of a look at this, and the problem that is showing appears to relate to destroying the popup after it has been displayed.  If the list of items is not displayed, the error does not occur.  SearchList is fine.

I have been using the fuller FastMM4 for many years now, and it is one of the first things I include in new projects.  It has saved me heaps of time in finding memory issues. They show up as soon as they are created.  The code is very stable and hasn't changed for a few years.  I need to continue to use it. 

Unfortunately this means it is impractical to use the component for now as it makes debugging difficult.

It may well be a false positive, but then again, maybe it isn't.

I will ask in forums about the false positive issue. The FastMM4 FAQ has an entry relating to the AV that is shown in my original post.
Q: My program used to work fine, but if I enable "FullDebugMode" and run it I get an access violation at address $8080xxxx. Why?
A: You are attempting to access properties of a freed object. When you free a block in "FullDebugMode", FastMM fills the freed memory area with a pattern of $80 bytes. If there were any pointers, long strings or object references inside the freed object they will now point to $80808080 which is in a reserved address space.


Posted By: King Susan
Date Posted: 21 May 2019 at 8:22am
I have posted a query on Delphi Praxis EN in the Delphi Questions and Answers, General Help, in case you are interested in the comments.

Posted By: Pieter Scheldeman
Date Posted: 21 May 2019 at 8:33am

We'll follow up and see if we can improve the code to avoid this issue, yet it would be very helpful if we would have a sample that demonstrates this issue. Can you reproduce this with a TTMSFNCPopup on the form hooked up on a button.

Posted By: King Susan
Date Posted: 22 May 2019 at 1:02am
This error does not occur with TTMSFNCPopup linked to a button.  The comment about popups was related to memory leaks reported when the check to CatchUseOfFreedInterfaces is turned off.  It might be a side effect or a different problem.

A file with the project and FastMM4 files included is being emailed to support.

Thanks for having another look at this.


Posted By: Allsopp Dennis
Date Posted: 17 Sep 2019 at 4:48am
I am experiencing the same issue resulting in the message 'raised exception class $C0000005 with message 'c0000005 ACCESS_VIOLATION'. Using FastMM shipped with Delphi 10.3.2 and a break always stops at the class procedure TTMSFNCStyles.SetActiveScene(AScene: IScene);
This issue seems to only occur once a selection is made from the popup.

Posted By: Pieter Scheldeman
Date Posted: 17 Sep 2019 at 10:26am
Hi, we have investigated this here but it's a false positive. The reference is cleaned properly, we can only assume that FastMM is detecting this as a memory leak, but it actually isn't a memory leak.

Posted By: King Susan
Date Posted: 19 Sep 2019 at 2:03am
Thanks for looking at this.  As you have the FastMM code but FastMM doesn't have your code, is there any way that your code could be tweaked to keep FastMM happy ?  As FastMM is used extensively without generating false positives, perhaps it is something specific to the sequence of steps in the SearchEdit component that is causing the issue. 
Or can you set up a small test program that demonstrates the false positive so FastMM can be changed ?
It is a shame that they can't be used together.  I find FastMM in full debug mode to be indispensable.

Posted By: Allsopp Dennis
Date Posted: 19 Sep 2019 at 2:55pm
Further to this issue it seems as though it may be specific to FMX platform. I just recompiled a VCL application where I use the SearchEdit without any problem.  Under FMX application errors consistently. Same machine, same environment.

Posted By: Bruno Fierens
Date Posted: 19 Sep 2019 at 9:56pm
We do not have contact with someone working on FastMM.
I'd suggest to bring this to private email to see if you can bring us in touch with a developer working on FastMM.

Posted By: Allsopp Dennis
Date Posted: 20 Sep 2019 at 12:24am
I am using a standard installation of Rad Studio Enterprise, with FastMM as installed by default. I enabled Euraka Log on the FMX project to capture the exception and it the call stack report provided the following. I can send the ful report if required.

Call Stack Information:
|Methods |Details|Stack           |Address         |Module      |Offset          |Source                                |Unit                    |Class                   |Procedure/Method                 |Line                             |
|*Exception Thread: ID=18136; Parent=0; Priority=0                                                                                                                                                                                            |
|Class=; Name=MAIN                                                                                                                                                                                                                            |
|DeadLock=0; Wait Chain=                                                                                                                                                                                                                      |
|Comment=                                                                                                                                                                                                                                     |
|7FFFFFFE|03     |0000000000000000|0000000000418C8A|Gendia.exe  |0000000000018C8A|System.pas                            |System                  |                        |_IntfCopy                        |                                 |
|00000060|04     |000000000014EB28|0000000000F153E5|Gendia.exe  |0000000000B153E5|FMX.TMSFNCStyles.pas                  |FMX.TMSFNCStyles        |TTMSFNCStyles           |SetActiveScene                   |1742[1]                          |
|00000060|04     |000000000014EB58|0000000000F21ED1|Gendia.exe  |0000000000B21ED1|FMX.TMSFNCCustomControl.pas           |FMX.TMSFNCCustomControl |TTMSFNCCustomControlBase|Destroy                          |1243[3]                          |
|00000060|04     |000000000014EB98|0000000000F22D03|Gendia.exe  |0000000000B22D03|FMX.TMSFNCCustomControl.pas           |FMX.TMSFNCCustomControl |TTMSFNCCustomControl    |Destroy                          |2078[114]                        |
|00000060|04     |000000000014EBC8|0000000000F2CDE9|Gendia.exe  |0000000000B2CDE9|FMX.TMSFNCScrollBar.pas               |FMX.TMSFNCScrollBar     |TTMSFNCCustomScrollBar  |Destroy                          |768[3]                           |
|00000060|03     |000000000014EBF8|000000000040E920|Gendia.exe  |000000000000E920|System.pas                            |System                  |TObject                 |Free                             |                                 |
|00000060|04     |000000000014EC38|00000000011C8578|Gendia.exe  |0000000000DC8578|FMX.TMSFNCTreeViewBase.pas            |FMX.TMSFNCTreeViewBase  |TTMSFNCTreeViewBase     |Destroy                          |407[3]                           |
|00000060|04     |000000000014EC68|00000000011E25C9|Gendia.exe  |0000000000DE25C9|FMX.TMSFNCTreeViewData.pas            |FMX.TMSFNCTreeViewData  |TTMSFNCTreeViewData     |Destroy                          |1727[8]                          |
|00000060|04     |000000000014EC98|00000000012669D6|Gendia.exe  |0000000000E669D6|FMX.TMSFNCCustomTreeView.pas          |FMX.TMSFNCCustomTreeView|TTMSFNCCustomTreeView   |Destroy                          |5497[32]                         |
|00000060|03     |000000000014ECC8|000000000040E920|Gendia.exe  |000000000000E920|System.pas                            |System                  |TObject                 |Free                             |                                 |
|00000060|04     |000000000014ED08|0000000001286398|Gendia.exe  |0000000000E86398|FMX.TMSFNCListBox.pas                 |FMX.TMSFNCListBox       |TTMSFNCCustomListBox    |Destroy                          |889[7]                           |
|00008020|03     |000000000014F108|0000000000A102B6|a           |00000000006102B6|{38E0C963-48A9-4649-A681-F4F0B4371047}|recursive               |area                    |removed                          |12[0]                            |
|00000060|03     |000000000014F1D8|000000000040E920|Gendia.exe  |000000000000E920|System.pas                            |System                  |TObject 

Posted By: Bruno Fierens
Date Posted: 20 Sep 2019 at 8:58am
Can this discussion be continued with email please as this way, you can send the full exception report as attachment to the email.

Posted By: King Susan
Date Posted: 20 Sep 2019 at 9:08am
I am trying to get a name and will email you privately.

Print Page | Close Window