# LandscapeSplineComponent Crashing on dereference (C++)

**URL:** <https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451>\
**Category:** C++\
**Tags:** landscape-splines, unreal-engine, Landscape, Splines, question, CPP\
**Created:** [February 14, 2024, 3:35pm UTC](https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451 "2024-02-14T15:35:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mrjamesgaming](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mrjamesgaming](https://forums.unrealengine.com/u/Mrjamesgaming)\
**Post date:** [February 14, 2024, 3:35pm UTC](https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451/1 "2024-02-14T15:35:20Z")

</div>

Hello all,  
I am fairly new to Unreal Engine and C++ in general. I am making a racing game and using the vehicle template as a jumping point for my project, I wanted to get a reference to the landscape spline that the editor used to construct the track but I have been having some trouble. After a lot of sleuthing, I found a solution through [this Pastebin](https://switchbackstudio.org/2022/02/07/tutorial-how-to-access-landscape-splines-in-unreal-for-pathing/) scrolling down to the bottom of the comment section you find the 2 lines of code here,  
ULandscapeSplinesComponent\* LandscapeSplineComponent = Landscape-\>SplineComponent;  
LandscapeSplineComponent-\>CopyToSplineComponent(SplineComponent);

I implemented that in a custom wrapper class to grab the spline for me but everytime I initalize it and attempt to dereference the ULandscapeSplineComponent that is initialized here I end up with a crash.  
Here is my .cpp file

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/3/9435a8fbeb5cfa710678d7abd542613f11f26ceb.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/1/3211e055ebe2349201b9c082b694c0ed69791645.png)  
here is my .h file

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/5/6a5bfb727670341e25fbcae8afea85eeadcecfff.png)  
the top line is just a #pragma once line

anyways the crash occurs on line 53 in the .cpp file. the program runs stable if I have that line commented, this is the output log when I run it with the line commented out

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/e/53ee87c456e4815036a9cb130548c76639c89690.png)  
however, upon running with the line uncommented I am immediately met with this crash message on play  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/9/069cd27575be17f0693f6722cdaacb3dbe7d6cb1.png)  
I’m aware that it is accessing an illegal location in memory, I dont know if there is an explicit way to mitigate that with cpp, I know some other forums I read mentioned something about GPU drivers being out of date but that was when the memory address was pointing to 0x000000000000000 which I assumed was a nullspace and based on the memory address I am pretty sure my issue is different(?). I have tried restarting my computer, but that did nothing, updated my OS (since I was running an old version of Windows 11).

Additional specs:  
Engine: Unreal Engine 5.3.2  
CPU: AMD Ryzen 9 7945HX  
GPU: RTX 4060 Laptop GPU  
OS: Windows 11 Home  
Ram: Crucial 32GB DDR5-5600 SODIMM (not factory ram but compatible)  
Laptop Model: ASUS ROG Strix G17 G713PV-DS94

Any other additional information id be happy to provide. Thanks in advance  
-James

---

<div class="post-metadata">

**Author:** ![Ari\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ari_epic/32/1225266_2.png) [@Ari\_Epic](https://forums.unrealengine.com/u/Ari_Epic)\
**Post date:** [February 15, 2024, 3:49pm UTC](https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451/2 "2024-02-15T15:49:40Z")

</div>

There’s a null reference there somewhere, it has nothing to do with your GPU drivers or when the last time you restarted. Unreal’s Landscape code is getting something it’s not expecting and crashing. Maybe the Landscape Spline component doesn’t have any spline points in it or something?

We can’t tell exactly what’s happening since you don’t have the symbols. So the first step you should do it install the Editor’s symbols, then when it crashes you’ll see which line and function it’s crashing in which might give you a better hint of what’s going wrong, which data it’s expecting. You’ll then be able to just read Unreal’s source code for more info.

See [this post](https://forums.unrealengine.com/t/how-to-debug-engine-code-get-symbols/382399/6) for instructions on downloading the debugging symbols:

> [@How to debug engine code / get symbols](https://forums.unrealengine.com/t/how-to-debug-engine-code-get-symbols/382399/6):
>
> This is a supporting answer for artists who need more of a “hold my hand” walkthrough smiley

---

<div class="post-metadata">

**Author:** ![Mrjamesgaming](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mrjamesgaming](https://forums.unrealengine.com/u/Mrjamesgaming)\
**Post date:** [February 16, 2024, 2:43pm UTC](https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451/3 "2024-02-16T14:43:44Z")

</div>

Hello,  
Thanks for getting back to me, I have done alot and managed to resolve my issue, for anyone who runs into something similar here is what I ended up doing  
-Installed unreal’s editor symbols for debugging (as you suggested)  
-Switched IDE’s from VSCode to VSCommunity  
-made a new project with a fresh .sln file and after all the requisite setup for VS was done  
-After doing that and implementing the same code I found some illegal access exceptions due to an access modifier I had edited, my guess was VSCode was not building my modifications to the UE5.3 project into the main project I was working in (BtB\_Alpha) thus causing UE to throw an illegalaccessexception, I fixed this by using the recently added GetSplinesComponent() method of the Landscape actor.  
I have been liking the workflow VS offers significantly more so im gonna keep using it over VSCode and I highly recommend to others even if the setup looks daunting. Good luck to anyone who needs this in the future and feel free to reach out for further questions  
-James

---

<div class="post-metadata">

**Author:** ![Ari\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ari_epic/32/1225266_2.png) [@Ari\_Epic](https://forums.unrealengine.com/u/Ari_Epic)\
**Post date:** [February 19, 2024, 8:58am UTC](https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451/4 "2024-02-19T08:58:43Z")

</div>

Fantastic that you managed to fix it! Remember to mark this question as “Resolved” so future answer seekers know they can check the thread for a solution, just mark your comment with your solution as the “answer” 👍

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [March 20, 2024, 8:59am UTC](https://forums.unrealengine.com/t/landscapesplinecomponent-crashing-on-dereference-c/1688451/5 "2024-03-20T08:59:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
