#1 2022-01-23 04:42:08

uian2000
Member
Registered: 2014-05-06
Posts: 68

[Fixed] CallbackReleased in mormot2 causes av.

Hi, ab.

I am trying something similer to restws.longwork, with additional implementation of CallbackReleased procedure.

  IDataService = interface(IInvokable)
    ['{9DDC69FF-5212-4F64-9B98-ABFBF14A27D4}']
    ....
    procedure CallbackReleased(const callback: IInvokable; const interfaceName: RawUTF8);

  TDataService = class(TInjectableObjectRest, IDataService)
  protected
    fClients: TInterfaceDynArray;
    ....

procedure TDataService.CallbackReleased(const callback: IInvokable;  const interfaceName: RawUTF8);
begin
  InterfaceArrayDelete(fClients, callback);
end;

When a client released, this procedure is processed then av occurred in mormot.core.interfaces

procedure TInterfaceMethodExecuteRaw.AfterExecute;
var
  i, a: PtrInt;
  arg: PInterfaceMethodArgument;
begin
  // finalize managed arrays for each call
  Finalize(fRawUtf8s);
  Finalize(fStrings);
  Finalize(fWideStrings);
  if fMethod^.ArgsManagedFirst >= 0 then
  begin
    for i := 0 to fMethod^.ArgsUsedCount[imvvObject] - 1 do
      fObjects[i].Free;
    for i := 0 to fMethod^.ArgsUsedCount[imvvInterface] - 1 do
      IUnknown(fInterfaces[i]) := nil;       <-------------- av here   Line7372

Am I implementing it in a wrong way?
My env: Win10/X64/Delphi XE/git@20220123

Best regards.

Last edited by uian2000 (2022-02-28 14:36:52)

Offline

#2 2022-02-24 00:36:33

uian2000
Member
Registered: 2014-05-06
Posts: 68

Re: [Fixed] CallbackReleased in mormot2 causes av.

Hi ab,I think I may have found the key to the problem. The point is that the same interface is repeatedly released.
When I commented out InterfaceArrayDelete in CallbackReleased, server keeps running without av but callbacks were not released either.

I guess there's something wrong with this point in the framework.
You've mentioned a concept about re-release of interface (weak pointer), is it related here?

regards.
uian

Last edited by uian2000 (2022-02-24 01:43:09)

Offline

#3 2022-02-24 08:24:42

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

Re: [Fixed] CallbackReleased in mormot2 causes av.

How do you add the interface to your fClients array?

Could you try with mORMot 1?

Offline

#4 2022-02-24 09:02:27

uian2000
Member
Registered: 2014-05-06
Posts: 68

Re: [Fixed] CallbackReleased in mormot2 causes av.

Client subscribes a service by calling service.Subscribe(aClientName, aClientInterface).
Then service will do this work by calling methid InterfaceArrayAdd(fClients, aClientInterface) .


I'll try mormot1 later, with the result posted here.

thanks smile

Offline

#5 2022-02-28 03:54:39

uian2000
Member
Registered: 2014-05-06
Posts: 68

Re: [Fixed] CallbackReleased in mormot2 causes av.

Hi, ab
I've made a pull request to demonstrate this issue.
Ex31-chat server/client works well in mormot1, but can go wrong in mormot2.

regards.
uian

Offline

#6 2022-02-28 07:28:09

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

Re: [Fixed] CallbackReleased in mormot2 causes av.

I will look into it and report here.

Thanks for the feedback.

Offline

#7 2022-02-28 14:10:11

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

Re: [Fixed] CallbackReleased in mormot2 causes av.

I guess it will be fixed by https://github.com/synopse/mORMot2/commit/034b23e7

I also took the liberty to refactor the sample (and rename its files for consistency).

Thanks for the input, and sorry for the issue.

Offline

#8 2022-02-28 14:36:30

uian2000
Member
Registered: 2014-05-06
Posts: 68

Re: [Fixed] CallbackReleased in mormot2 causes av.

Thanks, ab. you are amazing.
I've walked pass these lines for many times, but found nothing.
This pr do fix this issue.

Thank you again!

regards.
uian

Offline

Board footer

Powered by FluxBB