When using TJson.JsonToObject
in a multi-thread environment random access violations occur. I was searching a long time for the problem and I could isolate it with
The method TJSONUnMarshal.ObjectInstance
in REST.JsonReflect.pas
has a severe bug:
It calls FreeAndNil on a TRttiType instance. This should never be done because all TRtti*** instances are managed by the TRttiContext.
After I removed the FreeAndNil call I could not reproduce the access violation anymore.
Reported as: https://quality.embarcadero.com/browse/RSP-10035
P.S. I also think that https://quality.embarcadero.com/browse/RSP-9815 will affect your code.