#1 2026-06-09 09:52:31

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 532

'Invalid variant type'. finalizatron error

After commit e6bf459b17a676bd052d09ccab21ea76413cb876 I am getting record finalization error with the following stack:
Project pc.exe raised exception class EVariantBadVarTypeError with message 'Invalid variant type'.
https://gist.github.com/dkounal/99361a1 … bb4296bfa2

Offline

#2 2026-06-09 19:30:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,506
Website

Re: 'Invalid variant type'. finalizatron error

Is it still the case?

It sounds like if the variant is identified as a varArray, which should not be possible with pure mORMot code.
We would need some minimum reproducible example, please.

Offline

#3 2026-06-11 08:49:01

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 532

Re: 'Invalid variant type'. finalizatron error

please change in mormot.core.rtti.pas line 6877 to the following:

    if (ElemInfo <> nil) and
       (p^.length > 0) then 
          FastFinalizeArray(Value^, ElemInfo, p^.length);

It seems to work ok with the above

Offline

#4 2026-06-11 13:17:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,506
Website

Re: 'Invalid variant type'. finalizatron error

It is really unexpected to have p^.Length = 0 here.
A void dynamic array is expected to be stored as a nil pointer, not something with Length=0 in its headers.
I suspect there is something wrong elsewhere.

At least I have hardened FastFinalizeArray() usage:
https://github.com/synopse/mORMot2/commit/aad4c731a

Offline

#5 2026-06-12 15:39:48

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 532

Re: 'Invalid variant type'. finalizatron error

I can send you a unit that produced this error to check it and tell me. But it happens in my code when an empty json result is returned with just the fields.
thank you a lot for the fix

Offline

#6 2026-06-12 19:21:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,506
Website

Re: 'Invalid variant type'. finalizatron error

How does "an empty json result is returned with just the fields" look like?
For which type associated with RTTI?

Offline

Board footer

Powered by FluxBB