Skip to content

Dynamic Method Not Support? AV occured. #275

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

Open
cnpack opened this issue Mar 19, 2025 · 1 comment
Open

Dynamic Method Not Support? AV occured. #275

cnpack opened this issue Mar 19, 2025 · 1 comment

Comments

@cnpack
Copy link

cnpack commented Mar 19, 2025

We run this pascal script engine under x64 and register:

  with CL.AddClass(CL.FindClass('TObject'), TPersistent) do
  begin
    RegisterMethod('Procedure Assign( Source : TPersistent)');
    RegisterMethod('Function GetNamePath : string');  // this one
  end;

and

  with CL.Add(TPersistent) do
  begin
    RegisterVirtualMethod(@TPersistent.Assign, 'Assign');
    RegisterVirtualMethod(@TPersistent.GetNamePath, 'GetNamePath');
  end;

Then run a script like below:

program ScriptTest;

var
  P: TPersistent;
begin
  P := TPersistent.Create;
  Writeln(P.GetNamePath);
  P.Free;
end.

We'll get an AV:

Exception: Access violation at address 0000000000D8DECB in module 'ScriptTest.exe' (offset DECB). Read of address FFFFFFFFFFFFFF78

if under 32bit, AV also comes out .

Seems the reason is function GetNamePath: string; dynamic;

For dynamic functions, seems Pascal Script engine can not get it's correct entry address.

@cnpack cnpack changed the title AV occured if Registered Method returns string under x64 for a hidden parameter Dynamic Method Not Support? AV occured. Mar 21, 2025
@cnpack
Copy link
Author

cnpack commented Mar 21, 2025

And, for class TPSRuntimeClass, there's no RegisterDynamicMethod to call for TPersistent.GetNamePath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant