#1 2022-10-19 11:27:28

ThepSamart
Member
Registered: 2022-10-19
Posts: 3

Access violations on ToDataset using mORMot2-2.0.4148

I got access violation using latest release mORMot2-2.0.4148.

An exception are in TSqlDBProxyStatementRandomAccess.Create() and TSqlDBStatementWithParamsAndColumns.Create().
TSqlDBProxyStatementRandomAccess.Create() passed aConnection as nil to TSqlDBStatementWithParamsAndColumns.Create(), so testing for aConnection will raise error.

This is not occurred in previous release mORMot2-2.0.3780.

code: Reproducible Example

Offline

#2 2022-10-19 12:21:04

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

Re: Access violations on ToDataset using mORMot2-2.0.4148

(which compiler are you using?)

The whole memory release pattern seems pretty unsafe.
Calling z_conn.Free is too soon for sure.
Perhaps missing i_rows := nil and perhaps also TAutoFree not possible ?
See as reference https://synopse.info/files/html/Synopse … l#TITL_195

Offline

#3 2022-10-19 13:33:31

ThepSamart
Member
Registered: 2022-10-19
Posts: 3

Re: Access violations on ToDataset using mORMot2-2.0.4148

Sorry for the code provided, it's for testing only.

I use Delphi 10.2.3 Tokyo.

Could you examine code in mormot.db.proxy or trace back thru ToDataset() function.

constructor TSqlDBProxyStatementRandomAccess.Create(Data: PByte; DataLen: integer;
  DataRowPosition: PCardinalDynArray; IgnoreColumnDataSize: boolean);
var
  i, f: PtrInt;
  reader: PByte;
begin
  fLastGotoRow := -1;
  inherited Create(nil);
  InternalHeaderProcess(Data, DataLen);

The constructor inherited Create(nil) that passed thru

constructor TSqlDBStatementWithParamsAndColumns.Create(
  aConnection: TSqlDBConnection);

so aConnection was passed as nil. This could be the cause.

Offline

#4 2022-10-21 08:01:03

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

Re: Access violations on ToDataset using mORMot2-2.0.4148

Offline

#5 2022-10-21 13:09:35

ThepSamart
Member
Registered: 2022-10-19
Posts: 3

Re: Access violations on ToDataset using mORMot2-2.0.4148

Hi,

The latest release on GitHub (commit 4222) is working as expected.

Thank You and Regards.

Offline

Board footer

Powered by FluxBB