# Async Task crashes due to Acces violation

**URL:** <https://forums.unrealengine.com/t/async-task-crashes-due-to-acces-violation/462564>\
**Category:** C++\
**Tags:** async, task, unreal-engine, pointer, Scripting, CPP, question\
**Created:** [March 18, 2020, 2:02am UTC](https://forums.unrealengine.com/t/async-task-crashes-due-to-acces-violation/462564 "2020-03-18T02:02:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LordStuff](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LordStuff](https://forums.unrealengine.com/u/LordStuff)\
**Post date:** [March 18, 2020, 2:02am UTC](https://forums.unrealengine.com/t/async-task-crashes-due-to-acces-violation/462564/1 "2020-03-18T02:02:55Z")

</div>

Hi there!

I followed this tutorial here: [A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Multi-Threading:_Task_Graph_System)

And made Tasks that receive a Pointer to a HierarchicalInstancedStaticMeshComponent and a Pointer to a custom Actor Component and when the Task is executed and comes to this line:

```
// Task properties set through constructor
UHierarchicalInstancedStaticMeshComponent * HISM;
UDataComponent * Data;
// and in DoTask
HISM->AddInstance(FTransform(Data->GetLocation(idx)));

```

it crashes with an “Access violation writing location” message.

I am checking both for != nullptr.

I’ve read that it could be caused by the fact that I’m not using virtual method stubs but I tried making GetLocation virtual and it didn’t fix it.

Any ideas?

UPDATE:  
I split the line up into this:

```
// DoTask
FVector location = Data->GetLocation(idx);
FTransform transform = FTransform(location);
HISM->AddInstance(transform); // <--- Access violation writing location

```

And it only crashes in the last line.

EDIT:  
See my forum post for further info:

[https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1734112-problem-with-async-graph-tasks-and-hierarchical-instanced-static-mesh-components](https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1734112-problem-with-async-graph-tasks-and-hierarchical-instanced-static-mesh-components)
