#1 2023-08-02 21:01:18

mrbar2000
Member
From: Brazil
Registered: 2016-10-26
Posts: 90

I found a bug during register service

i have created this record

  TUsuarioRecuperaSenha = packed record
    UserPass: RawByteString;
  end;
...
TUsuarioService = class(TServiceBase, IUsuarioService)
    function TrocaSenha(const pUsuario: TUsuarioTrocaSenha) : TServiceCustomAnswer;
...
GetApp.RegisterService(TUsuarioService, [TypeInfo(IUsuarioService)]);
GetApp.Put('/usuariotrocasenha', 'usuarioService/trocasenha');

I got erro on this part of mormot

constructor TInterfaceFactory.Create(aInterface: PRttiInfo);
...
        imvRecord:
          if ArgRtti.Size <= POINTERBYTES then     <<<<<<<<<<<<<<<<<<< shouldnt be "if ArgRtti.Size < POINTERBYTES then"  ??????????
            raise EInterfaceFactory.CreateUtf8(
              '%.Create: % record too small in %.% method % parameter: it ' +
              'should be at least % bytes (i.e. a pointer) to be on stack',
              [self, ArgTypeName^, fInterfaceName, URI, ParamName^, POINTERBYTES]);

If i put more fields on record it works

Offline

#2 2023-08-03 06:42:49

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

Re: I found a bug during register service

In fact, the comparison is correct, but the error message is misleading/incorrect.
The value is expected to be on the stack, so it is required to be MORE than SizeOf(pointer).
This is an ABI limitation.

I have corrected the error message:
https://github.com/synopse/mORMot2/commit/847051f1

Offline

Board footer

Powered by FluxBB