#1 2017-12-17 22:03:52

gothbert
Member
Registered: 2017-11-08
Posts: 12

[Solved] TSQLModel.GetTableIndex: Props is garbage under fpc 3.0.4

Hi,

I made a trimmed-down version of the 26 - RESTful ORM example with Lazarus 1.8.0/Free Pascal Compiler 3.0.4 under Windows 10 64bit (target windows x86_64).

The server component runs fine. The client component creates a SIGSEV when doing Client.Add(). It looks like the pointer magic

Props := PPointer(PtrInt(aTable)+vmtAutoTable)^;

in mORMot.TSQLModel.GetTableIndex() returns a pointer into Nirvana: Props is filled with random content.

Delphi 10.1 creates a working executable, though.

SynCommons.VarRecToTempUTF8() seems to produce a similar issue in the vtClass branch of the case statement.

Is there a compiler switch to make the pointer magic work with Free Pascal or any other solution for this issue?

Best regards,
Boris

Last edited by gothbert (2017-12-18 11:01:21)

Offline

#2 2017-12-18 07:28:15

AOG
Member
Registered: 2014-02-24
Posts: 447

Re: [Solved] TSQLModel.GetTableIndex: Props is garbage under fpc 3.0.4

@gothbert

I just checked with FPC 3.0.4/Laz 1.8.0 on win64 with win64 executables, and they run perfect !
I do not know how you used the dpr files to build the projects with Lazarus, but here's is how I make it work:

In Lazarus, select open project and open the dpr-file. Select "simple project" when Lazarus asks you to create a project.
In project options (compiler options / parsing), set mode to Delphi.

Offline

#3 2017-12-18 11:01:08

gothbert
Member
Registered: 2017-11-08
Posts: 12

Re: [Solved] TSQLModel.GetTableIndex: Props is garbage under fpc 3.0.4

Thank you, AOG, for the quick reply!

Using your guidance, I made the sample program run. With the same settings, mine didn't. Comparison showed that I used the AutoFree pattern for adding records and that fails under FPC. I had better studied the fine manual more thoroughly because the issue is described there. Using the try/finally pattern or assign the result of the AutoFree() call to a variable does the job.

Offline

Board footer

Powered by FluxBB