#1 2019-01-02 15:25:06

lele9
Member
Registered: 2011-10-28
Posts: 170

rtti dynarray debug and release mode

Hi,
first of all happy new year smile
i have update mormot framework from 01/2017 to last nightly build and i have a problem with RTTI in a unit where i use TDynArray.
The problem (Access Violation) appear only in Release mode, not in Debug mode.

i think is something about this in mormot.pas

{.$define USETYPEINFO} // define for debugg, not on production

but i don't understand why and how resolve.

anyone can help me?
thanks
Emanuele.

Offline

#2 2019-01-07 09:05:44

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: rtti dynarray debug and release mode

Ab have any idea?

sad

Offline

#3 2019-01-07 11:01:20

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,297
Website

Re: rtti dynarray debug and release mode

Please, provide more information. What compiler FPC or Delphi? What  version of FPC/Delphi? What arch - x32 or x64? Small sample to reproduce

Offline

#4 2019-01-07 11:22:01

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: rtti dynarray debug and release mode

you're right mvp

i work on delphi 10.1 berlin 32bit

array declaration

TRigaDocumento = record
   IDArticolo: TID;
   Tipo: TTipoRigaDocumento;
   Codice: RawUTF8;
   Descrizione: RawUTF8;
   Quantita: Double;
   UnitaMisura: RawUTF8;
   PrezzoUnitario: Double;
   TipoPrezzo: TTipoPrezzo;
   Aliquota: Double;
   PercentualeScontoMaggiorazione1: Double;
   PercentualeScontoMaggiorazione2: Double;
   PercentualeScontoMaggiorazione3: Double;
   Lotto: RawUTF8;
   Reparto: RawUTF8;
   function getPrezzoNetto: Double;
   function getPrezzoLordo: Double;
   function getImponibile: Double;
   function getImposta: Double;
   function getTotale: Double;
   function getPercentualeScontoMaggiorazioneTotale: Double;
   function getImportoScontoMaggiorazioneTotale: Double;
   property PrezzoNetto: Double read getPrezzoNetto;
   property PrezzoLordo: Double read getPrezzoLordo;
   property Imponibile: Double read getImponibile;
   property Imposta: Double read getImposta;
   property Totale: Double read getTotale;
   property PercentualeScontoMaggiorazioneTotale: Double read getPercentualeScontoMaggiorazioneTotale;
   property ImportoScontoMaggiorazioneTotale: Double read getImportoScontoMaggiorazioneTotale;
end;
TRigheDocumento = array of TRigaDocumento;

DynArray init (where self.DARigheDocumento is TDynArray variable and aRigheDocumento is TRigheDocumento variable)

self.DARigheDocumento.Init(System.Typeinfo(TRigheDocumento), aRigheDocumento);

example operation with AV

self.DARigheDocumento.ElemCopyAt(aIndex, aRigaDocumento);

There is problem after the update of mORMot framework version '1.18.3372' to version '1.18.4932'
the Access Violation there is only in Release mode. In Debug mode all work fine.

if you need other information ask me obviously.
thanks a lot

Offline

#5 2019-01-07 13:58:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,167
Website

Re: rtti dynarray debug and release mode

Your record should be packed I guess.

But I don't see why it shouldn't work any more.
Try first to find out why there is a problem, debugging your code.
Please provide a simple reproducible sample, not as copy & paste in this forum, but as github or pastebin.

Offline

#6 2019-01-07 17:14:26

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: rtti dynarray debug and release mode

hi ab,
the problem in the problem is often that in debug mode all work like a charm! so i cant debug!

Offline

#7 2019-01-09 07:38:30

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: rtti dynarray debug and release mode

hi ab,
enabling debug information on release mode i can step by step into the line of code that cause the access violation

in SynCommons.pas

procedure CopyArray(dest, source, typeInfo: Pointer; cnt: PtrUInt);
asm
{$ifdef CPU64}
        .NOFRAME
        jmp     System.@CopyArray
{$else} push    dword ptr[EBP + 8]
        call    System.@CopyArray // RTL is fast enough for this           <------ACCESS VIOLATION
{$endif}
end;

the same operation in debug mode work well. yikes
i create a new option (call production) copy from Release and disable optimization flag and ALL WORK FINE.
this can help?
Thanks

Last edited by lele9 (2019-01-09 08:05:54)

Offline

#8 2019-01-09 14:10:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,167
Website

Re: rtti dynarray debug and release mode

I am not able to reproduce anything like what you report with Delphi 10.3 CE in Win32 Release mode.

I just run the regression tests with no problem.

See https://gist.github.com/synopse/219b4d7 … 270a18019a

Offline

Board footer

Powered by FluxBB