Project can't be opened without crashing after this video's particular changes

The solution compiles just fine, but I can’t open the unreal project anymore. I’m getting a strange error too. I’ll post the log, but when I try to re-open the project, I crash then I get

UObject() constructor called but it's not the object that's currently being constructed with NewObject. Maybe you are trying to construct it on the stack, which is not supported.

Log          LogTcpMessaging      Initializing TcpMessaging bridge
Log          LogUdpMessaging      Initializing bridge on interface 0.0.0.0:0 to multicast group 230.0.0.1:6666.
Log          LogWindows           Windows GetLastError: The operation completed successfully. (0)
Error        LogWindows           === Critical error: ===
Error        LogWindows           
Error        LogWindows           Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 2572]
Error        LogWindows           UObject() constructor called but it's not the object that's currently being constructed with NewObject. Maybe you are trying to construct it on the stack, which is not supported.
Error        LogWindows           
Error        LogWindows           
Error        LogWindows           [Callstack] 0x00007fffb2714b59 KERNELBASE.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff4134d066 UE4Editor-Core.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff413507a8 UE4Editor-Core.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff4105e8cd UE4Editor-Core.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff41f975f3 UE4Editor-CoreUObject.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff2bdbf428 UE4Editor-Engine.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff0868243f UE4Editor-Escape.dll!UItemGrabber::UItemGrabber() [M:\Unreal Content\Projects\Courses\Escape\Escape\Source\Escape\ItemGrabber.h:47]
Error        LogWindows           [Callstack] 0x00007fff41cbc203 UE4Editor-CoreUObject.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff41f7fabf UE4Editor-CoreUObject.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff41f6287f UE4Editor-CoreUObject.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff41e92305 UE4Editor-CoreUObject.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff410999ea UE4Editor-Core.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff410c12a8 UE4Editor-Core.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff4580e7d3 UE4Editor-Projects.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fff4580eaea UE4Editor-Projects.dll!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007ff6e3d653a2 UE4Editor.exe!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007ff6e3d68a62 UE4Editor.exe!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007ff6e3d60eec UE4Editor.exe!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007ff6e3d6125a UE4Editor.exe!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007ff6e3d752bd UE4Editor.exe!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007ff6e3d77fea UE4Editor.exe!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fffb4727034 KERNEL32.DLL!UnknownFunction []
Error        LogWindows           [Callstack] 0x00007fffb4f42651 ntdll.dll!UnknownFunction []
Error        LogWindows           
Log          LogExit              Executing StaticShutdownAfterError
Log          LogWindows           FPlatformMisc::RequestExit(1)
Log          LogCore              Engine exit requested (reason: Win RequestExit)

Here’s the full log:

ItemGrabber.h line 47 is just the float declaration for our reach.
image

Here’s the scripts.

Google searches suggested adding UPROPERTY() to pointers like PhysicsHandle, and Rider is also warning me “Object member ‘PhysicsHandle’ can be garbage collected at any time”, but either way that didn’t solve the crash nor change the error.

I also think this error started happening once I added the check for PhysicsHandle for logging, but I’m not sure… I can’t remember.

I’ve tried commenting out all of those lines and changes added during this video, as well as completely deleting ItemGrabber.cpp and ItemGrabber.h and I still get the same exact error referencing the same ItemGrabber.h file. So far it’s impossible to open the uproject regardless of what the default map is.

Edit: Also asking here. Project no longer opens without crashing after adding UPhysicsHandleComponent logic.. - UE4 AnswerHub

Cleaned and rebuilt entire solution. Some #includes needed to be rearranged, but after a successful rebuild, I still get the same error and crash with the same line number mentioned.

Something I noted is you should avoid having additional includes in your header as it slows the build process. Use class UPhysicsHandleComponent* PhysicsHandle; instead.

This won’t solve the issues you are seeing however. I would recommend commenting out the new code and add it back in bit-by-bit. I checked my project and the code is the same and yet it works.

The only difference I can see from the code is the sequence. In the code I have, getting the physics handle is done first.

I wrapped the getting of the handle in its own method which actually makes it easier to disable. Add a call to something like this in your BeginPlay:

void UItemGrabber::GetPhysicsHandle()
{
  //  get the physics handle component
  PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>();
  if ( PhysicsHandle == nullptr )
  {
    UE_LOG( LogTemp, Error, TEXT( "%s: Cannot find Physics Handle" ), *( GetOwner()->GetName() ) )
  }
}

Unfortunately commenting the newly added code does not prevent the same error/crash when attempting to open the uproject.

In fact, even completely deleting the entire ItemGrabber header file and cpp file still results in the same crash, and still references the same “ItemGrabber.h:47” in the same file path even though it no longer exists.

I completely deleted both scripts, cleaned and rebuilt the solution with those scripts completely removed, and I still get the following crash when trying to open the project:

Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 2572] UObject() constructor called but it's not the object that's currently being constructed with NewObject. Maybe you are trying to construct it on the stack, which is not supported.

UE4Editor_CoreUObject
UE4Editor_Engine
UE4Editor_Escape!UItemGrabber::UItemGrabber() [M:\Unreal Content\Projects\Courses\Escape\Escape\Source\Escape\backup\ItemGrabber.h:47]  <-- (this file doesn't exist)
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Core
UE4Editor_Core
UE4Editor_Projects
UE4Editor_Projects
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll

Completely deleting the blueprints created (defaultpawn and gamemode), and completely deleting the level file does not prevent the error when trying to open the uproject.

Deleting the entire Source folder still results in an identical crash when opening the Unreal project, referencing the same header file and lines in the log.

Is the uproject file itself corrupt? Or is there some cache I need to delete that is unique to this Unreal project and separate from any C++ compiling I’d do within Rider/Visual Studio?

This sucks because I can’t progress any further in this course.

Someone on the answerhub figured it out! I got the project to open again. :sweat_smile:

It was because of this line in the header file:

AActor GrabbableActor; // Probably missing *

I’m also curious what the course creators think of this feedback:

As for UPROPERTY with

UPhysicsHandleComponent* PhysicsHandle = nullptr;

from what I see the Physics handle is created somewhere else, but in here you are simply storing a pointer to it, it would be better to use TSoftObjectPtr than raw C++ pointer. Long story short, TSoftObjectPtr is a weak pointer that will get “invalidated” once the object it points to is destroyed.

In your example, if the actual object gets deleted, you are left with a dangling pointer to a memory that is no longer occupied by the object and dereferencing it will cause undefined behavior.

You could also use UPROPERTY with the c++ raw pointer, which is going to do the same thing (more or less) but in that case, the object is reference counted additional time, that means it won’t get automatically deleted if it goes “out of scope”.

Either way, now I really want to know why this would still crash the unreal editor with the same exact error logs on loading the project, despite me completely removing the entire C++ source folder, removing these cpp and header files, etc.

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

Privacy & Terms