#1 2020-04-08 17:03:48

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Access Violation (FastMM4 recorded)

Hi,

not sure how easy it is to reproduce, but with the current release (GitHub), following code will, when run in the debugger, produce an error, shown by FastMM4, at the end of the process.

Delphi 10.3.3

program mORMot.bug;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  FastMM4,
  System.SysUtils,
  mORMot,
  mORMotDDD,
  mORMotSQLite3,
  SynCommons,
  SynSQLite3Static;

type
  TSQLTest = class(TSQLRecord)
  private
    FPassword: RawUTF8;
    FLogin: RawUTF8;
    FSalt: RawUTF8;
  published
    property Login: RawUTF8 read FLogin write FLogin;
    property Password: RawUTF8 read FPassword write FPassword;
    property Salt: RawUTF8 read FSalt write FSalt;
  end;

var
  Model: TSQLModel;
  Rest: TSQLRestServerDB;
  Test: TSQLTest;
  Success: Boolean;
begin
  ReportMemoryLeaksOnShutdown := True;

  try
    Model := TSQLModel.Create([TSQLTest]);
    Rest := TSQLRestServerDB.Create(Model, 'test.db');
    Rest.CreateMissingTables;

    Test := TSQLTest.Create();
    try
      Success := Rest.Retrieve('Login = ?', [], ['youOrMe'], Test);

      Writeln('Success: ', Success);
    finally
      Test.Free;
    end;

    Rest.Free;
    Model.Free;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

  Write('Done ');
  Readln;
end.
---------------------------
Debugger Exception Notification
---------------------------
Project mORMot.bug.exe raised exception class $C0000005 with message 'access violation at 0x01539099: read of address 0x767d75db'.
---------------------------
Break   Continue   Help   
---------------------------

Regards,
Daniel

Offline

#2 2020-04-08 17:10:50

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Re: Access Violation (FastMM4 recorded)

Actually, even simpler, is enough to get FastMM4 to blow up:

program mORMot.bug;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  FastMM4,
  System.SysUtils,
  mORMot,
  mORMotDDD,
  mORMotSQLite3,
  SynCommons,
  SynSQLite3Static;

var
  Model: TSQLModel;
  Rest: TSQLRestServerDB;
begin
  ReportMemoryLeaksOnShutdown := True;

  try
    Model := TSQLModel.Create([]);
    Rest := TSQLRestServerDB.Create(Model, '1.db');

    Rest.Free;
    Model.Free;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

  Write('Done ');
  Readln;
end.

Offline

#3 2020-04-08 23:12:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Access Violation (FastMM4 recorded)

1) Please follow the forum rules and don't post extensive code in the threads.
Use a gist/pastebin instead.

2) I am not able to reproduce with the default MM, setting:
  ReportMemoryLeaksOnShutdown := True;
I have no problem on Delphi 7 either (no memory leak reported by FastMM4 in FullDebugMode).
I have no problem with FPC in HeapTRC mode (memory leak report tool).
But when I use FastMM4, I have an access violation in the MM.
I don't know where it comes from.

Offline

Board footer

Powered by FluxBB