Menu

#2 EAccessViolation in FastMM.GetMemoryManagerState

open
nobody
None
5
2011-01-28
2011-01-28
No

If I run a very simple test in GUI mode it work okay. If I run the same test in the console mode it works okay in IDE but it fails when it is run from the command prompt.

program dunit2memleak;
{$APPTYPE CONSOLE}
uses
FastMM4,
SysUtils,
TestFramework,
{$IFDEF CONSOLE_TESTRUNNER}
TextTestRunner
{$ELSE}
Forms,
GUITestRunner
{$ENDIF}
;

type
TMemLeakTest=class(TTestCase)
published
procedure TestMemLeak;
end;

{ TMemLeakTest }

procedure TMemLeakTest.TestMemLeak;
var
P:Pointer;
begin
GetMem(P, 1000);
Check(P<>nil);
end;

begin
{$IFNDEF CONSOLE_TESTRUNNER}
Application.Initialize;
{$ENDIF}

RegisterTest(TMemLeakTest.Suite);

{$IFDEF CONSOLE_TESTRUNNER}
try
TextTestRunner.RunRegisteredTests;
except
on E: Exception do
Writeln(ErrOutput, E.ClassName, ': ', E.Message);
end;
{$ELSE}
GUITestRunner.RunRegisteredTests;
{$ENDIF}
end.

I have another complex test project which fails under the same circumstances. I was able to get error stack information via JclDebugHandler. The error stack is below:

C:\Dev\lib_pp\generic\Test\bin\Debug\Win32>GenericTestsRunner.exe
28.01.2011 17:49:21 Exception EAccessViolation occured in FastMM4.GetMemoryManagerState at 0 in file
Message: Access violation at address 00411D85 in module 'GenericTestsRunner.exe'. Read of address 0000000C
Call stack:
[00411D85] FastMM4.GetMemoryManagerState
[0049677D] TestFramework.TMemoryLeakMonitor.Create (Line 895, "TestFramework.pas")
[00496F85] TestFramework.TMemUseComparator.Create (Line 1097, "TestFramework.pas")
[0049A3EE] TestFramework.TTestCase.Run (Line 2942, "TestFramework.pas")
[0049D33B] TestFramework.TTestProject.Run (Line 4031, "TestFramework.pas")
[004A04BD] TestFrameworkProxy.TTestProxy.Run (Line 948, "TestFrameworkProxy.pas")
[0049F332] TestFrameworkProxy.RunTest (Line 343, "TestFrameworkProxy.pas")
[0052560A] TextTestRunner.RunTest (Line 422, "TextTestRunner.pas")
[005257C6] TextTestRunner.RunRegisteredTests (Line 463, "TextTestRunner.pas")
[00590206] GenericTestsRunner.GenericTestsRunner (Line 70, "")

28.01.2011 17:49:21 Exception EAccessViolation occured in FastMM4.GetMemoryManagerState at 0 in file
Message: Access violation at address 00411D85 in module 'GenericTestsRunner.exe'. Read of address 0000000C
Call stack:
[00411D85] FastMM4.GetMemoryManagerState
[0049677D] TestFramework.TMemoryLeakMonitor.Create (Line 895, "TestFramework.pas")
[00496F85] TestFramework.TMemUseComparator.Create (Line 1097, "TestFramework.pas")
[0049A3EE] TestFramework.TTestCase.Run (Line 2942, "TestFramework.pas")
[0049D33B] TestFramework.TTestProject.Run (Line 4031, "TestFramework.pas")
[004A04BD] TestFrameworkProxy.TTestProxy.Run (Line 948, "TestFrameworkProxy.pas")
[0049F332] TestFrameworkProxy.RunTest (Line 343, "TestFrameworkProxy.pas")
[0052560A] TextTestRunner.RunTest (Line 422, "TextTestRunner.pas")
[005257C6] TextTestRunner.RunRegisteredTests (Line 463, "TextTestRunner.pas")
[00590206] GenericTestsRunner.GenericTestsRunner (Line 70, "")
28.01.2011 17:49:21 Exception EAccessViolation occured in FastMM4.GetMemoryManagerState at 0 in file
Message: Access violation at address 00411D85 in module 'GenericTestsRunner.exe'. Read of address 0000000C
Call stack:
[00411D85] FastMM4.GetMemoryManagerState
EAccessViolation Access violation at address 00411D85 in module 'GenericTestsRunner.exe'. Read of address 0000000C

Discussion

  • Andrew Fionik

    Andrew Fionik - 2011-01-28

    A simple test project

     
  • Jarrod Hollingworth

    I could not reproduce this with the current HEAD revision of DUnit2 with included jcl and fastmm externals using your attached project.

    I tried all 32 combinations of D2010 (14.0.3593.25826) and DXE (15.0.3890.34076), debug and release mode, console and GUI test runner, run from IDE and command prompt, with and without dunit fail on memory leak. They all worked as expected.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.