Any C++ error causes editor to crash

Any error made in c++ crash the editor all the time and it keeps crashing on startup until I fix the error and recompile the code outside the editor
The first time I encountered crashed is when I had called InputComponent->BindAction in the component’s ctor and it had thrown an error and the editor crashed until I moved it in SetupPlayerInputComponent
The second time is when I dereferenced pointer type that had null value

I’m new to UE4 and it is ok to miss something editor-specific in C++ API (like InputComponent->BindAction inside a specific method) but it is weird that the entire editor crashes.
Previously, I used Unity and it shows runtime errors without crashing and I thought UE4 does the same.
Is everyone really develop with that accuracy that their code never fails on the first try?

1 Like

If you are c++ code writer, you need to check 3 stuff always,

  • Is your code easy to understand?
  • Can you test your code?
  • Can you handle all errors?

The only reason editor crash is nullptr please check if you handle null pointer errors. Always keep track your pointers. To solve that, you can always read error stack, it will show line and file…

Hi! From my experience the most often case - just nullptr pointer. Just check out that all pointers are set and are ok.

I agree that we can check all the time the code of ours but even good programmers aren’t gods and make errors
I hoped the community has a much more convenient way to deal with it. It is sad

1 Like

The thing is Unreal always blows up when nullptr :slight_smile: At the crash report you will see the proper place where you have nullptr. So great programmers also need to good read on their logs and dont misunderstand advices :slight_smile: Its just an advice, dont get offended.

Edit: ■■■■, I guess I just responded to year old question, because it was on the top

As Kehal18 said, it’s most likely either nullptr or dangling ptr. It’s not really UE4 fault that it crashes, it just how C++ is, it is less hand holding/forgiving than other languages (if you want to shoot yourself in the foot, do it, it won’t forbid it, but who know what will really happen), dereferencing nullptr is an undefined behaviour that can either “work” and do unexpected stuff, but most likely (hopefully) crash.

If you were using blueprints, nullptr check would be handled by the engine, you would get an error message just like in unity, but in raw C++, it’s not the case.

The best way is to simply check for nullptr or use check in case you are 100% sure that it’s not null (that is shouldn’t be null), but rule of a thumb, if there is a pointer, it can be null or dangling (comparing to references “&” (glorified pointers underneath) that theoretically* cannot be null, but still can be dangling)

The easiest way to debug is to attach a debugger and once it crashes, you can check the state of the variables along callstack (or use breakpoint, especially conditional breakpoint instead of waiting for crash)

@mahoukyou it is really UE4’s fault because its developers decided to build an editor on top of game runtime and when that runtime experiences an error the editor crashes along with it as well. Editor in UE4 is kind of extension to the game which is completely stipped when building a release game

1 Like