LandscapeSplineComponent Crashing on dereference (C++)

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 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



here is my .h file


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


however, upon running with the line uncommented I am immediately met with this crash message on play

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

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 for instructions on downloading the debugging symbols:

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

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” :+1:

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