First Chance Exception Access Violation at reading location

The Exception

In my unreal project I am using an external library (dll) that I have created that has dependencies on [C++ REST SDK][1]. I have imported both dlls (for x64) and lib files and set correctly the include paths modifying the build.cs.

When I try to use the function from my external project (that calls on the C++ REST SDK library) the exception is thrown.

I would really appreciate your help with this because I have deadline on Monday and this dlls need to be included in Unreal by then.

Thanks in advance for your time!

Message

Here is the message:

42522-message.png

Output

Here is the output from the console:

[2015.05.13-13.53.08:351][815]PIE: Info Play in editor start time for /Game/ThirdPerson/Maps/UEDPIE_0_ThirdPersonExampleMap 0.184
[2015.05.13-13.53.09:896][984]LogBlueprintUserMessages: Test Successful!!
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\credssp.dll'. Cannot find or open the PDB file.
[2015.05.13-13.53.10:088][984]LogBlueprintUserMessages: {
  "origin": "122.131.211.193"
}

First-chance exception at 0x000007FEE3E3D194 (nvwgf2umx.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Unhandled exception at 0x000007FEE3E3D194 (nvwgf2umx.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

The logs show that the functions from my classes executed correctly, the IP address is the result of a GET request using the C++ REST SDK library.

Stack

Here is the stack call:

 	nvwgf2umx.dll!000007fee3e3d194()	Unknown
 	nvwgf2umx.dll!000007fee3eb4519()	Unknown
 	[External Code]	
>	UE4Editor-D3D11RHI.dll!FD3D11DynamicRHI::RHILockVertexBuffer(FRHIVertexBuffer * VertexBufferRHI, unsigned int Offset, unsigned int Size, EResourceLockMode LockMode) Line 111	C++
 	UE4Editor-RHI.dll!LockVertexBuffer_Internal(FRHIVertexBuffer * VertexBuffer, unsigned int Offset, unsigned int SizeRHI, EResourceLockMode LockMode) Line 625	C++
 	UE4Editor-Engine.dll!FBoneDataVertexBuffer::UnlockData() Line 189	C++
 	UE4Editor-Engine.dll!FPreviousPerBoneMotionBlur::UnlockData() Line 1174	C++
 	UE4Editor-Renderer.dll!FDeferredShadingSceneRenderer::RenderVelocities(FRHICommandListImmediate & RHICmdList, TRefCountPtr<IPooledRenderTarget> & VelocityRT) Line 678	C++
 	UE4Editor-Renderer.dll!FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate & RHICmdList) Line 993	C++
 	UE4Editor-Renderer.dll!RenderViewFamily_RenderThread(FRHICommandListImmediate & RHICmdList, FSceneRenderer * SceneRenderer) Line 1118	C++
 	UE4Editor-Renderer.dll!TGraphTask<`FRendererModule::BeginRenderingViewFamily'::`12'::EURCMacro_FDrawSceneCommand>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 667	C++
 	UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 428	C++
 	UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 271	C++
 	UE4Editor-RenderCore.dll!RenderingThreadMain(FEvent * TaskGraphBoundSyncEvent) Line 282	C++
 	UE4Editor-RenderCore.dll!FRenderingThread::Run() Line 404	C++
 	UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 73	C++
 	UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 48	C++
 	[External Code]	

Blueprint

From the blueprints this is the point where my function is called:

Code

The code of the function that is called in the blueprint is:

Sensor.h

UCLASS(Blueprintable)
class PROJECT ASensor: public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ASensor();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	//

Called every frame
virtual void Tick( float DeltaSeconds ) override;

UFUNCTION(BlueprintCallable, Category = "Default")
	FText makeHttpRequest();

};

Sensor.cpp

FText AGameSensorPresence::makeHttpRequest(){
	SampleRequest sr = SampleRequest();
	std::string text = sr.doRequest();

	return FText::FromString(text.c_str());
}

From the imported libraries there is:

SampleRequest.h

#include <cpprest\http_client.h>
#include <cpprest\filestream.h>

using namespace utility;
using namespace web;
using namespace web::http;
using namespace web::http::client;
using namespace concurrency::streams;

class __declspec(dllexport) SampleRequest
{
public:
	SampleRequest(){};
	std::string doRequest();
};

The includes and the namespaces are all from C++ REST SDK.

SampleRequest.cpp

std::string SampleRequest::doRequest(){

	pplx::task<string_t> mytask = pplx::create_task([]
		{
			http_client client(L"http://httpbin.org/ip");

			return client.request(methods::GET);
		}).then([](http_response response)
			{
				if (response.status_code() == status_codes::OK)
				{
					return response.extract_string().get();
				}

				return utility::string_t();
			});

	std::string aux = conversions::to_utf8string(mytask.get());

	mytask.wait();

	return aux;
}

Observations

I think the problem comes from here, pplx is a part of the library that is in charge of making asynchronous calls but I have no idea where the conflict with the engine might be.

I built the code in SampleRequest.cpp following [this][4] tutorial. Specifically the part where he creates the function pplx::task GetAll().

Please help! Thank you very much for your time!

The library that I use is using lambda expressions, I believe this is not supported in Unreal Engine and thus this is the reason I get the exception.

I found some related comments here.

Could someone please confirm?

Have you found any solution? I am having the same issue with another 3rd pary library (ifcengine.dll)

The reply comes way too late but better late than never. In the end I gave up on the C++ implementation and moved on to make my project using blueprints only. In other words I never found a solution for this.

Bumped into this today and problem seems in

task.wait()

I’m now trying to make an UWP app with UE4 and if I use wait() the Engine will immediately shutting down…
Hope someone get solution!