#1 2015-06-13 20:20:53

marius maximus
Member
From: Olsztyn
Registered: 2015-06-11
Posts: 30

Wrong length RawUTF8

In code I found few pleces where insted
length(RawUTF8)
is used metod like in "UnCamelCase"
(Sometimes i used this metod too wink)

function UnCamelCase(const S: RawUTF8): RawUTF8; overload;
begin
  result := '';
  if S='' then
    exit;
  SetLength(result,PInteger(PtrInt(S)-sizeof(integer))^*2); // max length
  ...
  ...

This metod works OK in Delphi (64 and 32 bit) but not always in FPC and Lazarus ,
for example
in 64 bit windows version length is on -8 position
in 32 bit windows version length is on -4 position (identical like Delphi)

This problem is in fundamental functions:

Utf8DecodeToRawUnicode
Utf8DecodeToRawUnicodeUI
UrlDecode
UnCamelCase

Is chanse to fix it ?

For example
{$IFDEF FPC}
SetLength(result,PInteger(PtrInt(S)-sizeof(pointer))^*2);
{$ELSE}
SetLength(result,PInteger(PtrInt(S)-sizeof(integer))^*2);
{$ENDIF FPC}

Always exist this difference ? Where read about fpc string ?
I try find "StrRec" definiction in FPC but nothing about this

I read this
http://wiki.freepascal.org/Character_an … AnsiString
On picture is 4B for length and othing about 64 bit  sad



I would like to run 64 bit ,
I will send more comments to this smile
It is ok ?

Last edited by marius maximus (2015-06-13 20:31:17)


Lazarus x64 Linux

Offline

#2 2015-06-13 20:38:37

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

Re: Wrong length RawUTF8

Fpc 64 is not supported yet..

A deeper code review would be necessary...

Offline

#3 2015-06-13 21:38:08

marius maximus
Member
From: Olsztyn
Registered: 2015-06-11
Posts: 30

Re: Wrong length RawUTF8

Step by step and we(I) fix all wink

for example better version

{$IFDEF FPC}
SetLength(result,length(s)*2);
{$ELSE}
SetLength(result,PInteger(PtrInt(S)-sizeof(integer))^*2);
{$ENDIF FPC}

I look in asembler and fpc create better asm like Delphi
version with length(s) is near  "(PtrInt(S)-sizeof(integer)"

Or other version is create for example "CONST _str_length_pos"
and use "(PtrInt(S)-_str_length_pos)"
and add few "ifdef" in Synopse.inc


After this fix , next sample project start works smile
A find this bug when try run  "07 - SynTest"


I need to take a workshop next project wink

Last edited by marius maximus (2015-06-13 22:04:14)


Lazarus x64 Linux

Offline

#4 2015-06-13 23:09:46

miab3
Member
From: Poland
Registered: 2014-10-01
Posts: 188

Re: Wrong length RawUTF8

Arnaud,

Zeos 7.2 cope well with fpc-64bit.
Michael were a little worked hard at it.
You can peek into its functions.
Specifically to ZFastCode.pas and other from directory "core".

Michal

Last edited by miab3 (2015-06-13 23:13:00)

Offline

#5 2015-06-14 08:33:59

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

Re: Wrong length RawUTF8

I made a first pass for FPC 64bit compatibility.

See http://synopse.info/fossil/info/f1bc7c708f
There was A LOT of issues with the string length direct access.

But there is more to fix!

Offline

#6 2015-06-14 09:22:18

marius maximus
Member
From: Olsztyn
Registered: 2015-06-11
Posts: 30

Re: Wrong length RawUTF8

Thx very much ,

I always use svn but try git ,
I improvise wink

I find two bugs (very small)
https://github.com/mariuszekpl/mORMot/c … a20282853c


Lazarus x64 Linux

Offline

#7 2015-06-14 15:39:21

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

Re: Wrong length RawUTF8

Please check http://synopse.info/fossil/info/89aa81e89b

Thanks for the patch!

Offline

#8 2015-06-14 22:55:45

marius maximus
Member
From: Olsztyn
Registered: 2015-06-11
Posts: 30

Re: Wrong length RawUTF8

a step in the right direction,
I will be tested


Lazarus x64 Linux

Offline

#9 2015-06-15 20:28:52

marius maximus
Member
From: Olsztyn
Registered: 2015-06-11
Posts: 30

Re: Wrong length RawUTF8

I was able compile "TestSql3" ("Synopse mORMot Framework Automated tests") in 64bit fpc.

test

a lot of red and a long way yet wink


Lazarus x64 Linux

Offline

#10 2015-06-16 08:00:25

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

Re: Wrong length RawUTF8

Offline

Board footer

Powered by FluxBB