Serializing Json causes crash

Serializing a Json to FString sometimes seams to crash my game. It can happen randomly on many occasions, I suspect it having something to do with framerate drops or when something is spawned:

FString UArin_GameSave::GetTextToSave(
	TSharedPtr<FJsonObject> pJsonObject)
	FString ReturnedValue = "";

	//Validate JsonObject
	if (!pJsonObject.IsValid())
		UE_LOG(LogTemp, Log, TEXT("UArin_GameSave::GetTextToSave: LoadedDataslotData is invalid"));
		return "";

	//Prepare Serializing
	TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&ReturnedValue);

		pJsonObject.ToSharedRef(),	//Data that gets serialized
		Writer);					//The writer which outputs it to the ReturnedValue

	return ReturnedValue;	// <-- The crash report always reports this line

Does anyone have an idea what could be the cause?

The error message:
Access violation - code c0000005 (first/second chance not available)

An other theory of mine would be that the code somewhere somehow executes a SetField at the exact same time as the FJsonObject is serializing?


We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.