Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonDataObjects failing on ARM64 #18

Closed
kstrophus opened this issue Nov 12, 2015 · 1 comment
Closed

JsonDataObjects failing on ARM64 #18

kstrophus opened this issue Nov 12, 2015 · 1 comment
Labels

Comments

@kstrophus
Copy link

Hi Andy,

This library is not functioning correctly on iOS 64 bit targets (ARM64). All other targets seem to work fine. I have some sample code at the end of this post.

I have dug a bit and found this so far:

class procedure TJsonBaseObject.StrToJSONStr(const AppendMethod: TWriterAppendMethod; const S: string);
2266: //EndP := P + Length(S);
2267: EndP := P + PLongInt(@PByte(S)[-4])^;

Line 2267 is calculating huge EndP values in ARM64 and causing the while loops to crash. However, if I comment out line 2267 and use line 2266 then EndP correctly points to the line end.

Next:

procedure TJsonOutputWriter.TJsonStringBuilder.DoneConvertToString(var S: string);
6803: Pointer(S) := P; // keep the RefCnt=1

In ARM64 after line 6803 executes S is not updated and still points to the blank text it was initialized to earlier in this method. Line 6803 seems to have no effect when investigated in the debugger.

Sample code:

procedure TForm1.Button1Click(Sender: TObject);
var
jo: TJSONObject;
begin
jo := TJSONObject.Create;

jo.I['ACCOUNTID'] := 225;
jo.B['BOOLVAL'] := False;
jo.S['VERSION'] := '1.0';
jo.S['LOCATION'] := 'RVK';
jo.S['USERID'] := 'S.TESTER';
jo.S['GARBAGE#####'] := 'Ooga\booga';
jo.S['SUBTOCALL'] := 'G2.WEB.CONNECT.SUB';
jo.D['DT'] := Now;
jo.S['ACTION'] := 'CONNECT';

Memo1.Text := jo.ToJSON(true);
// Crash if line 2267 is active, no crash if line 2266 is active.
// When no crash then this always returns an empty string.

jo.Free;
end;

@ahausladen
Copy link
Owner

I don't have any Apple device so I can't test it. I can only make assumptions. So fixing those bugs may take some time and commits.
Embarcadero made LongWord and LongInt for ARM64 incompatible to Win32, ARM32 and Win64. In my opinion they broke it. On ARM64 SizeOf(LongInt) is 8, for all other platforms including Win64 it is 4.

@ahausladen ahausladen added the bug label Nov 13, 2015
ahausladen added a commit that referenced this issue Nov 14, 2015
New CPU64BITS for XE8+ and CPUX64 for XE2-XE7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants