Is common to have a crash on each hotreload when adding a new UPROPERTY?

Hi, I just want to ask others about this issue that is like normal for me.

I start a new project and things go well until starts with hot-reload crashes
when I add some parameter to an actor.

I’m used to load the editor like 1000 times a day for this.

the common crash:

image

I know is having a nullpointer exception. WHY?!
I mean… I load the editor and is ok again.

Crashes are very common when you change the header file from my experience.

So is this part of anyone workflow to be used of thousand of crashes every time a header file is updated?

From my experience, yes. Thousands might be an exaggeration, though… :rofl:
Try and make your intended header changes all at once, or alternately close editor before making big header changes. I’m also assuming that you mean when it hot-reloads your updated code it crashes, if not, you may have problems with your code.

Why don’t you download the debug symbols and attach the debugger to the editor and figure out what exactly it is that is causing the crash? Then you will know how to fix it or avoid it possibly.

In my experience it is mostly user errors that cause the editor to crash like having circular dependencies, bad management of delegates, doing things in constructors that you shouldn’t or forgetting things that should be done like setting defaults, race conditions and so on.

Hi! Thanks for your reply :slight_smile:
Can you briefly tell how to do that?

Would be great if someone makes some tutorial with possible reasons and how to avoid /fix as I see this is a very common problem mostly for newbies on UE c++

Is important to always setting defaults?

For example

bool myvalue; in the . h without assign true or false could cause crashes like this?

just a test…adding a simple function like this:

	UFUNCTION(BlueprintCallable)
	float testFunction() { float test = 0.0f; return test;}

compiles ok and then crashes the editor. I reopen and everything is good
but it led to the fatal crash

image

There could be a thousand reasons why the Editor crashes so making a tutorial would be pretty much impossible, however learning to debug code is a skill that you should constantly be practicing.

Writing code that compiles successfully is just the beginning. How the code behaves in run-time is what really matters and this is why it is important to learn how to use the VS Debugger.

The easiest way to get started is simply to launch the editor through Visual Studio.

If you have installed Unreal Engine from the Epic Games Launcher you can choose to also install the Debug Symbols for the Editor and Source Code.

If you built the engine from source then you already have what you need.

Installing the UnrealVS extension is also a good idea.

Then pick the “Development Editor” solution configuration and Debug->Start Debugging
This will launch the Editor while attaching the Visual Studio Debugger. When the Editor crashes or hits an assert it will stop execution and you can inspect what is going on.
If this is your first time doing this it is probably going to be very confusing but start by opening the “Call Stack” window and browse through the list. You can click each line to “jump back in time”.
The “Autos” window is also interesting. This will show the Variables currently in scope.

2 Likes

No you don’t need to set the default in the header file but you should set it in the Constructor. If you never set a default variable before using it you are at the mercy of boiler plate code or the compiler to save you so it is always best to set it explicitly.
It is unlikely that the variable itself is causing the crash but a side effect of the variable being set to something you didn’t expect could lead to a null pointer exception.

1 Like

Thanks for the explanation! :slight_smile:

You’re welcome. Like I said don’t be intimidated by the flood of information the debugger is providing if you are new to this but spend some time with it and perhaps provoke a crash and watch the Debugger “catch” it and see how it looks.

1 Like