#1 2020-05-13 11:21:54

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

@ab,

If you run this small test console project you'll get an EAccessViolation error
https://gist.github.com/edwinyzh/ea75bd … 3d59ee095f

The case is that a freeing a TSQLRecord-derived class which has a published property of type TRawUTF8List, created by CreateCopy, will cause the 'Access Violation' error.

Am I doing something wrong, is it by design, or is it a bug?

I'm using the latest mORMot rev:
https://github.com/synopse/mORMot/commi … 8b1605bf92

And the error also happens with previous versions.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2020-05-13 11:24:06

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

After some debugging I wonder it might has something to do with TSQLPropInfoRTTIObject.CopySameClassProp?

Last edited by edwinsn (2020-05-13 11:24:20)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2020-05-13 12:12:24

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

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

I guess TRawUTF8List copy is not supported.
Use a TRawUTF8DynArray property instead.

Offline

#4 2020-05-13 12:47:46

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

But when being stored in the db, a field of type TRawUTF8DynArray is not in JSON format? Persisting in JSON format is required in my use case.

Last edited by edwinsn (2020-05-14 07:55:24)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#5 2020-05-14 04:39:50

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

@ab,

I'm afraid it's still a bug?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2020-05-14 07:24:41

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

edwinsn wrote:

But when stored in the db, a field of type TRawUTF8DynArray is not in JSON format? Persisting in JSON format is required in my use case.

About a week ago expected the same JSON format of TRawUTF8DynArray field value, but unfortunately didn't get such a result sad Therefore I had to make a quick workaround with the calculated field.

Offline

#7 2020-05-14 07:56:49

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

@Vitaly,
Alternatively you can use TStrings/TStringList as the published property type, you'll get JSON format in the db, and it doesn't have the 'CreateCopy' issue described here.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#8 2020-05-14 08:24:39

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

Oh, that's really good! Will definitely try it, thank you! smile

Offline

#9 2020-05-14 12:29:29

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

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

Or use a variant field in which you put a TDocVariant array.

Offline

#10 2020-05-14 19:18:00

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: Freeing Record created by CreateCopy w/ TRawUTF8List property cause AV

a bit embarrassing but I have to tell that I was avoiding TDocVariant almost always. Just rarely used it for fast getting some value from some JSON.
And now I tried it with several different structures and I must admit that it is useful and rather simple! Of course, so far I'm not sure that I'm using it the best way, but I will get it after some more experience.
I will use it in many places of my projects, thank you for your hints, guys! smile and sorry, @edwinsn, for a kind of offtopic

Offline

Board footer

Powered by FluxBB