#1 2020-02-13 16:12:11

urhen
Member
Registered: 2020-02-13
Posts: 36

FLOAT_OVERFLOW in TSQLRequest.Execute

Hello,
I've a very strange issue which appears after some days/weeks where my code was running fine but then suddenly it stops working because it creates a deadlock by LockJSON due to a thrown exception.

My TSQLFileStatRec class inherits from TSQLRecord and has the members declared as TSQLSitesRecord. The member classes inherit from TSQLRecordNoCase and only have following types: RawUTF8, Int64 and TDateTime.

Example class definition:

  TSQLSrcRec = class(TSQLRecordNoCase)
  private
    FName: RawUTF8;
  published
    property Name: RawUTF8 read FName write FName stored AS_UNIQUE;
  end;

Stacktrace when exception is thrown:

SynSQLite3.TSQLRequest.Execute(???,???,???,???)
:0000000003B03B57 ; c:\lib\sqlite3-64.dll
:0000000003B0FF16 ; c:\lib\sqlite3-64.dll
:0000000003BFB9CF ; c:\lib\sqlite3-64.dll
:0000000003C053F8 ; c:\lib\sqlite3-64.dll
:0000000003C055A8 ; c:\lib\sqlite3-64.dll
:000000000082273B TSQLRequest.Step + $4B
SynSQLite3.TSQLRequest.Step
mORMotSQLite3.TSQLRestServerDB.MainEngineList('SELECT ID FROM FileStatRec WHERE SrcRec = :(''000000000000000C''): AND DstRec = :(''000000000000000A''): AND SectRec = :(''0000000000000014''): AND FileRec = :(''000000000001E313''):',False,nil)
mORMot.TSQLRestServerURIContext.ExecuteORMGet
mORMot.TSQLRestServerURIContext.ExecuteCommand
mORMot.TSQLRestServer.URI($B3DF2E0)
mORMotSQLite3.TSQLRestClientDB.InternalURI($B3DF2E0)
mORMot.TSQLRestClientURI.OnBackgroundProcess(nil,$B3DF2E0)
mORMot.CallInternalURI
mORMot.TSQLRestClientURI.URI('root','GET',$B3DF3B8 {''},nil {''},$B3DF3E8 {'SELECT ID FROM FileStatRec WHERE SrcRec = :(''000000000000000C''): AND DstRec = :(''000000000000000A''): AND SectRec = :(''0000000000000014''): AND FileRec = :(''000000000001E313''):'})
mORMot.TSQLRestClientURI.ExecuteList((...),'SELECT ID FROM FileStatRec WHERE SrcRec = :(''000000000000000C''): AND DstRec = :(''000000000000000A''): AND SectRec = :(''0000000000000014''): AND FileRec = :(''000000000001E313''):')
mORMot.TSQLRest.MultiFieldValues(TSQLRecordClass($B96558),'ID','SrcRec = :(''000000000000000C''): AND DstRec = :(''000000000000000A''): AND SectRec = :(''0000000000000014''): AND FileRec = :(''000000000001E313''):')
mORMot.TSQLRecord.CreateAndFillPrepare($7FF4FDD4BBF0,'SrcRec = :(''000000000000000C''): AND DstRec = :(''000000000000000A''): AND SectRec = :(''0000000000000014''): AND FileRec = :(''000000000001E313''):','ID')
mORMot.TSQLRecord.CreateAndFillPrepare($7FF4FDD4BBF0,'SrcRec = ? AND DstRec = ? AND SectRec = ? AND FileRec = ?',(...),'ID')
MyFile.AddFile('SrcName','DstName','SectName','foldername','filename',size)

The code for the query is made with CreateAndFillPrepare (using TSQLRestClientDB) and the SrcRec parameter is filled with the previous created SrcRec and added as SrcRec.AsTSQLRecord. All my queries only fetch the ID value. The thrown exception is FLOAT_OVERFLOW. When I change the SrcRec.AsTSQLRecord to SrcRec.ID it doesn't throw the exception.
For me it seems it's related to SrcRec.AsTSQLRecord?

Thanks in advance and regards!

Offline

#2 2020-02-17 13:37:51

urhen
Member
Registered: 2020-02-13
Posts: 36

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

Nobody?

Offline

#3 2020-02-17 14:24:02

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

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

Did you try with static linking of SQLite3?

Offline

#4 2020-02-17 14:43:57

urhen
Member
Registered: 2020-02-13
Posts: 36

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

No because its also running on Linux where static linking isn't supported but the same issue with deadlock occur.

Offline

#5 2020-02-17 14:49:06

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

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

Static linking works very well on Linux with FPC... Or are you using Kylix?

Offline

#6 2020-02-17 14:52:05

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

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

AsTSQLRecord can be quite buggy on Linux - especially if heap address randomization is enabled.
Just as TSQLRecord.ID/GetID may be too.

So using PtrInt(strRec) directly - if you know it is not an instance, but a pointer - is certainly the safest option.

Offline

#7 2020-02-17 17:02:38

urhen
Member
Registered: 2020-02-13
Posts: 36

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

ab wrote:

Static linking works very well on Linux with FPC... Or are you using Kylix?

No, using FPC. I think I've read somewhere that static linking doesn't work with FPC.
But however, why should it make a difference?
I'm using the SQLite precompiled Binaries from https://www.sqlite.org/ on Windows and for Linux we compile them.

Offline

#8 2020-02-17 17:07:04

urhen
Member
Registered: 2020-02-13
Posts: 36

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

ab wrote:

AsTSQLRecord can be quite buggy on Linux - especially if heap address randomization is enabled.
Just as TSQLRecord.ID/GetID may be too.

So using PtrInt(strRec) directly - if you know it is not an instance, but a pointer - is certainly the safest option.

So you mean the call to

mORMot.TSQLRecord.CreateAndFillPrepare($7FF4FDD4BBF0,'SrcRec = ? AND DstRec = ? AND SectRec = ? AND FileRec = ?',(...),'ID')

should be made with PtrInt(SrcRec) instead of SrcRec.AsTSQLRecord?

Could you please explain how it finds the ID inside the DB through the address pointer of a variable?

Last edited by urhen (2020-02-17 17:08:43)

Offline

#9 2020-02-17 22:44:45

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

Re: FLOAT_OVERFLOW in TSQLRequest.Execute

Please read the documentation about how TSQLRecord published fields are stored.

Offline

Board footer

Powered by FluxBB