Memory error when closing constructor (C++)

I’m new to the unreal engine, but have quite a bit of experience with c++. I’m currently dealing with a real head-scratcher, though, as I’ve got a memory allocation CTD in the constructor for a planet actor. The constructor uses a third party library to get the planetary data, and (as such) borrows from std::future and std::shared_ptr to get the data. These elements are passed into proper UE4 storage containers, however, and the issue seems to be releasing memory used during construction, not in the creation of these containers. Any help would be greatly appreciated, thanks!

Here’s the code:

APlanetActor::APlanetActor()
{	
	Vertices.Empty();
	Triangles.Empty();
	Normals.Empty();
	UV0.Empty();
	VertexColors.Empty();
	Tangents.Empty();
	bool bValid;
	if (UCoreGameStateLibrary::GetCoreGameState(bValid) != NULL)
	{
		PlanetParams newparams = PlanetParams();
		//Right now gets zero - eventually we'll get the chosen planet type from a global variable.
		FPlanetParams params = UCoreGameStateLibrary::GetCoreGameState(bValid)->GetPlanet(0);

		//Let's copy the data over...
		newparams.axialTilt = params.axialTilt;
		newparams.gridLevel = params.gridLevel;
		newparams.heightRange = params.heightRange;
		newparams.humidityincreaselowest = params.humidityincreaselowest;
		newparams.humidityreductionelevation = params.humidityreductionelevation;
		newparams.maxTemp = params.maxTemp;
		newparams.minTemp = params.minTemp;
		newparams.noiseOctaves = params.noiseOctaves;
		newparams.noisePersistence = params.noisePersistence;
		newparams.noiseScale = params.noiseScale;
		newparams.rainAmount = params.rainAmount;
		newparams.rainThreshold = params.rainThreshold;
		newparams.riverCutoffNavigable = params.riverCutoffNavigable;
		newparams.riverCutoffSignificant = params.riverCutoffSignificant;
		newparams.riverMaxErosion = params.riverMaxErosion;
		newparams.seed = TCHAR_TO_UTF8(*params.seed);
		newparams.simulateClimate = params.simulateClimate;
		newparams.stormcells = params.stormcells;
		newparams.tempfactorelevation = params.tempfactorelevation;
		newparams.waterRatio = params.waterRatio;
		newparams.watertempbase = params.watertempbase;
		newparams.windspeedfactor = params.windspeedfactor;

		const PlanetParams& constparams = newparams;

		//Let's make a planet!
		mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("PlanetMesh"));
		RootComponent = mesh;

// thirdparty

		std::future<std::shared_ptr<IPlanet>> nextPlanet;
		std::shared_ptr<IPlanet> planet;

		nextPlanet = createPlanet(constparams);
		nextPlanet.wait();

		planet = nextPlanet.get();

//end thirdparty

		std::vector<Vector3Index>origvertex = planet->vertexData3d();
		for (int32 Index = 0; Index != origvertex.size(); ++Index)
		{
			float x = origvertex[Index].array()[0];
			float y = origvertex[Index].array()[1];
			float z = origvertex[Index].array()[2];
			FVector vector(x, y, z);
			Vertices.Add(vector);
		}
		std::vector<uint32_t> origindex = planet->indexData();
		for (int32 Index = 0; Index != origindex.size(); ++Index)
		{
			Triangles.Add(origindex[Index]);
		}

		std::vector<Vector3Index>orignormals = planet->normalData3d();
		for (int32 Index = 0; Index != orignormals.size(); ++Index)
		{
			float x = orignormals[Index].array()[0];
			float y = orignormals[Index].array()[1];
			float z = orignormals[Index].array()[2];
			FVector vector(x, y, z);
			Normals.Add(vector);
		}
			
		int32 vertexsize = Vertices.Num();
		for (int32 Index = 0; Index != vertexsize; ++Index)
		{
			UV0.Add(FVector2D(0, 0));
		}

		for (int32 Index = 0; Index != vertexsize; ++Index)
		{
			VertexColors.Add(FColor(0.75, 0.75, 0.75, 1.0));
		}

		for (int32 Index = 0; Index != vertexsize; ++Index)
		{
			Tangents.Add(FProcMeshTangent(0, 1, 0));
		}
	}
}

The part separated out in the middle is the thirdparty element. As I said, the constructor crashes in FMalloc::Free, thus my assumption is that the two thirdparty pointers are not being cleaned up properly (even though, theoretically, smart pointers are supposed to clean themselves up). Any ideas?

Thanks!

Solved this problem - accessing the third party library and pulling data from it was adding vector information to the memory heap that unreal did not know what to do with. Generating the vector data in unreal by using references to, but not pointers from, the third party library solved it.