Although there are plenty of topics about PascalScript, they're either zombies, or refering to x86-Code (or both), so I'm starting a new one. Hopefully I found the right Forum..
Has anyone successfully used PascalScript with Lazarus Classes (e.g. TForm, TButton) on Win x64?
I can compile the downloadable latest stable version from their website (the one with the EXE-Installer) as well as the latest development version from
https://github.com/remobjects/pascalscript - no Problem there. Running the script works, adding user defined funktions is ok, too.
But as soon as I try to Create forms and objects, like the following script, the Program (not the Script) crashes with a SIGSEGV.
program Script;
var
f:TForm;
b:TButton;
begin
f:=TForm.CreateNew(nil); //<- Works
b:=TButton.Create(f); //<- crash
b.Parent:=f;
f.Show;
end.
Crash in the Program is here:
CLASSES_TCOMPONENT_$__INSERTCOMPONENT$TCOMPONENT
000000000044F900 4883ec38 sub $0x38,%rsp
000000000044F904 48895c2420 mov %rbx,0x20(%rsp)
000000000044F909 4889742428 mov %rsi,0x28(%rsp)
000000000044F90E 4889cb mov %rcx,%rbx
000000000044F911 4889d6 mov %rdx,%rsi
000000000044F914 4889da mov %rbx,%rdx
000000000044F917 4889f1 mov %rsi,%rcx
000000000044F91A 4889f0 mov %rsi,%rax
000000000044F91D 488b00 mov (%rax),%rax
000000000044F920 ff9068010000 callq *0x168(%rax) <-- crash
Am I doing anything wrong? The same Script runs fine when the Application was compiled with x86 Lazarus RC1.
By the way: creating a TObject with e.g. o:=TObject.Create doesn't break at al.
Interestingly, when I start debuging <SomeClass>.Create(aOwner:TComponent)-Type of Constructors, there is some difference in the Register values, depending on whether the Constructor was called from "pure" FPC-Code or the Script (at least so it seems):
o Called from FPC: rcx: 0 (nil), rdx: Class Reference, r8: Value of aOwner
o Called from Script: rcx: Class Reference, rdx: 1 (!?), r8: Value of aOwner (at least so it seems)
Is there any difference in the calling convention on x64-Systems between Delphi and Lazarus? I could only find the "standard" information on Windows x64 calling conventions, without special care of constructors, if there is any...
Did anybody else stumble about that problem bevore?