Menu

#31 Program crashing (AV) when I use FastMM but working without.

open
None
6
2008-12-02
2008-12-02
No

Program crashing (AV) when I use FastMM but working (for years) without FastMM.

Line leading to the AV:

procedure TMyGrid.SizeChanged(OldColCount, OldRowCount: Longint);
begin
SetLength(CelArray, ColCount, RowCount); <- Here
...
end;

AV appears on line 4036:
mov TMediumFreeBlock[edx].PreviousFreeBlock, edi
in FastMM4.pas (latest version - 25 Nov 2008) in function FastGetMem(ASize: Integer);

I have replaced all my ".free" calls with "freeAndNil" and I know for sure that I don't try to access an object that was accidentally freed.

If you need details please contact me at: "cubic design at g mail dot com".

I also ran the program step by step until the error line and have found no possible problems that could cause the AV.

---------------------------
Debugger Exception Notification
---------------------------
Project Runner.exe raised exception class C0000005 with message 'access violation at 0x00409bd7: write of address 0x00014718'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------

Discussion

  • manilu georian

    manilu georian - 2008-12-02
    • priority: 5 --> 6
    • assigned_to: nobody --> pierre_le_riche
     
  • Pierre le Riche

    Pierre le Riche - 2008-12-02

    Hi Manilu,

    Have you tried running your application with FullDebugMode enabled? That should help you find the cause of the problem.

    Best regards,
    Pierre

     
  • manilu georian

    manilu georian - 2008-12-02

    (Additional note: the program crashes (AV) ONLY it is run from inside the IDE. If it is run outside the IDE it just freezes.)

    -------------------------------------------------------

    In this case the application is not crashing anymore. Strange. I know!

    However, I get this leak report:

    ---------------------------
    Runner.exe: Memory Leak Detected
    ---------------------------
    This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):
    21 - 36 bytes: TCriticalSection x 1
    The sizes of leaked medium and large blocks are (excluding expected leaks registered by pointer): 12964

    The leak appears ONLY if I run the program under the IDE. If I run it from Explorer I have no leaks.

     
  • manilu georian

    manilu georian - 2008-12-03

    Update:

    A leak was detected here:
    This block was allocated by thread 0x8E0, and the stack trace (return addresses) at the time was:
    402ED1 [System][@ReallocMem]
    406A54 [System][DynArraySetLength]
    406B36 [System][@DynArraySetLength]
    542676 [ReadAFile.pas][ReadA][TAObj.LoadFromFile][436]
    The block is currently used for an object of class: Unknown
    The allocation number is: 24348
    Current memory dump of 256 bytes starting at pointer address 7FCAADE0:…

    Line 436 is like this:
    SetLength(Trc4.Points, Trc4.NumberOf +1);

    Trc4 is declared like this:

    TAObj = class(TObject)
    public { STRUCTURE}
    Trc1 : TATrc;
    Trc2 : TATrc;
    Trc3 : TATrc;
    Trc4 : TATrc;
    ...
    end;

    It is absolutely impossible to have a leak there, because I ran/followed the code line by line and the TAObj is freed properly. I have a nice NIL value assigned to that object after I done with it. I see no reason why the Trc4 array should not be free also. Also, why only Trc4 is leaking and not Trc1-3? All 4 arrays are going through exactly the same processing.

     
  • Pierre le Riche

    Pierre le Riche - 2008-12-04

    You could have a memory overwrite bug somewhere that is writing 0 to the dword at the same address as the Trc4 field. That would prevent the memory of the array from being freed.

     
  • manilu georian

    manilu georian - 2008-12-05

    Right after I dont't need Trc4.Points, I manually set it to NIL, but FastMM still complains that it is leaking.

     
  • Nobody/Anonymous

    FASTMM does not initialize object variable to nil, so you may be accessing/releasing an object that has not been created.

     
  • Nobody/Anonymous

    Yes of course.
    I have tried also that option (I don't know its name) that fills the memory with zeros.

     
  • Nobody/Anonymous

    Sourceforge.. Nifty :)

     
  • Nobody/Anonymous

    Sourceforge.. Bully :)

     
  • Nobody/Anonymous

    Sourceforge.. Ho-o-o-o-t :)

     

Log in to post a comment.

MongoDB Logo MongoDB