Jump to content
meg02in

MARS.Rtti.Utils troubles with SetArrayLength

Recommended Posts

Hi,

 

I'm Manuel and I'm working with MARS  using the master branch, under Delphi 10.3 release 3 on Windows 10 1909 64 bit.

 

When build my server under linux 64 bit (Target OS Debian 10 Buster)  either like apache module or like linux daemon, 

i encurred in an Exception of type Range check error when, in my resources, MARS try to inject a body param of type Array of Record.

 

And instead when i buil my server as apache module (win32) or windows service (win32) or ISAPI dll (win32) or FMX Application (win32 or win 64) 

all working fine.

 

After a day of investigation i find that the problem come out in the procedure SetArrayLength of unit MARS.Rtti.Utils, and my workaround is to modify the procedure in that way:

 

//procedure SetArrayLength(var AArray: TValue; const AArrayType: TRttiType; const ANewSize: Integer);
procedure SetArrayLength(var AArray: TValue; const AArrayType: TRttiType; const ANewSize: PNativeInt);
begin
  if AArrayType is TRttiArrayType then
  begin
    raise Exception.Create('Not yet implemented: SetArrayLength TRttiArrayType');
    { TODO -oAndrea : probably not needed }
  end
  else if AArrayType is TRttiDynamicArrayType then
    //DynArraySetLength(PPointer(AArray.GetReferenceToRawData)^, AArrayType.Handle, 1, @ANewSize);
    DynArraySetLength(PPointer(AArray.GetReferenceToRawData)^, AArrayType.Handle, 1, ANewSize);
end;

I change the parameter type from Integer to  PNativeInt that is exactli the type that DynArraySetLength wants, and then i modify accordling the unit MARS.Core.JSON.pas e MARS.Core.MessageBodyReaders.pas.

 

After that i rebuild all my project and all working good both under linux and under wndows in all my server deploy kind.

 

Anyone have had my same problem? My workaround could be a good solutions?

 

I  attached my source of MARS.Rtti.Utils, MARS.Core.JSON.pas e MARS.Core.MessageBodyReaders.pas

 

MARS.Core.JSON.pas

MARS.Core.MessageBodyReaders.pas

MARS.Rtti.Utils.pas

Share this post


Link to post

Wouldn't this be better submitted as an issue on the github repo? That way there's a record of it for other users of the project. 

Share this post


Link to post

Hi, sorry for the late, I am trying to catch up with all messages here and on github.com.

I saw the issue (81) and yesterday I made some work on the develop branch (rebasing it onto master). I attached files with your corrections to the issue, please file a pull request and I will be happy to accept it (and you will show up as a contributor as well).

 

Thanks

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×