C++ Crash Error

Hello

I have been following the Battery Collector Tutorials which were going well. After updating to Unreal 4.15.2, I compiled
my project which resulted in a crash. After a bit of research I checked the option “Editor Symbols for Debugging” in the Epic Games Launcher. But when I try to open my project another crash occurs, Here is the Crash Information:

LoginId:165ead6b4f32ec4f9f9f189caf5274fa
EpicAccountId:965de9d3b04a433b8d73fcd68a658fe7

Access violation - code c0000005 (first/second chance not available)

UE4Editor_BatteryCollector_397!ABatteryPickup::__DefaultConstructor() [c:\users\documents\unreal projects\batterycollector\source\batterycollector\batterypickup.h:14]
UE4Editor_BatteryCollector_397!InternalConstructor()
UE4Editor_CoreUObject!UClass::CreateDefaultObject() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\class.cpp:2722]
UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:777]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:853]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance::ExecuteIfSafe() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:1027]
UE4Editor_Core!TBaseMulticastDelegate::Broadcast() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:937]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\core\private\modules\modulemanager.cpp:471]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\projects\private\moduledescriptor.cpp:412]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\projects\private\projectmanager.cpp:60]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2395]
UE4Editor!FEngineLoop::PreInit() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:1832]
UE4Editor!GuardedMain() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\launch.cpp:127]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
UE4Editor!WinMain() [d:\build\++ue4+release-4.15+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

I’ve had no such problems when opening my non C++ projects

Any idea what this could be and how to fix it?

Thanks in advance

What is the line of code in batterypickup.h at line 14?

Standard Generated_Body() here’s the header code:

#pragma once

#include "Pickup.h"
#include "BatteryPickup.generated.h"

/**
 * 
 */
UCLASS()
class BATTERYCOLLECTOR_API ABatteryPickup : public APickup
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	ABatteryPickup();
	
};

Does the class “APickup” exist?

It Does: Here’s the associated code:

#include "GameFramework/Actor.h"
#include "Pickup.generated.h"

UCLASS()
class BATTERYCOLLECTOR_API APickup : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	APickup();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Return the Mesh for the Pickup
	FORCEINLINE class UStaticMeshComponent* GetMesh() const { return PickupMesh; }

	// Return Whether or not the Pickup is Active
	UFUNCTION(BlueprintPure, Category = Pickup)
	bool IsActive();

	// Allows other Classes to Safely Change Wheteher or not Pickup is Active
	UFUNCTION(BlueprintCallable, Category = Pickup)
	void SetActive(bool NewPickupState);

protected:
	// True when the Pickup can be Used and False when the Pickup is Deactivated
	bool bIsActive;

	/** Simple colision primitive to use as the root component */
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Pickup)
		USphereComponent* BaseCollisionComponent;

	/** StaticMeshComponent to represent the pickup in the level */
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Pickup)
		UStaticMeshComponent* PickupMesh;
};

In terms of where I am in the Battery Collector tutorial I was in the middle of video 5 in the series(some lines were updated due to unreal version differences). if you would like the code for the other header and cpp files, let me know

Kyle, Just to add I just did a build of the Battery Collector. The Build Failed showing the following errors:

Severity Code Description Project File Line Suppression State
Error System.UnauthorizedAccessException: Access to the path ‘C:\Users\Documents\Unreal Projects\BatteryCollector\Binaries\Win64\UE4Editor-BatteryCollector.dll’ is denied. BatteryCollector C:\Users\Documents\Unreal Projects\BatteryCollector\Intermediate\ProjectFiles\EXEC 1

Severity Code Description Project File Line Suppression State
Error Exhausted all retries! BatteryCollector C:\Users\Documents\Unreal Projects\BatteryCollector\Intermediate\ProjectFiles\EXEC 1

Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file ‘C:\Users\Documents\Unreal Projects\BatteryCollector\Binaries\Win64\UE4Editor-BatteryCollector.dll’ BatteryCollector C:\Users\Documents\Unreal Projects\BatteryCollector\Intermediate\ProjectFiles\LINK 1

Severity Code Description Project File Line Suppression State
Error MSB3073 The command ““C:\Program Files\Epic Games\UE_4.15\Engine\Build\BatchFiles\Rebuild.bat” BatteryCollectorEditor Win64 Development “C:\Users\Documents\Unreal Projects\BatteryCollector\BatteryCollector.uproject” -waitmutex” exited with code -1. BatteryCollector C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets 42

I recently updated to unreal version 4.15.3. I wonder if this is a case of deleting the project and starting from scratch.

How are you building the project?

Are you using the “Compile” button in the editor? Or, are you building the project through Visual Studio?

If you are trying to build the project through Visual Studio while the editor is running, I can see you getting the “Path is denied” error because that DLL is loaded by the editor but Visual Studio is trying to access it. If this is the case, either close the editor or use the “Compile” button in the editor.

The problem lies in my original question. I cannot open my battery collector project because it crashes before it fully loads(crash log details on top of page).
The only way I can change or attempt to change the code is through visual studio and as you describe in your comment there are problems with this method. Therefore is it best to just delete the project and start again from Scratch?

Have you tried running the project from Visual Studio instead of the .uproject? This way you can run the program and edit it through Visual Studio in order to fix it.

Open the project through the .sln in your project folder:

137771-debugging_00.png

Run the program with “Local Windows Debugger” in Visual Studio:

If/when this fails, look at the errors and fix them, then try again.

There is never a instance in which you need to completely start a project over from scratch.

Have to see more of your code, I guess. Something is probably illegally referenced and crashes, because you have say, an actor in editor using that code. You’ll have to delete the erroneous code then recompile.

What happens if you bypass the code in ABatteryPickup?

I tried the Local Windows Debugger method and after the diagnostics is run an exception appears. It points to the GENERATED_BODY() method in the battery pickup, Here’s the BatteryPickup.h file:

#pragma once

#include “Pickup.h”
#include “BatteryPickup.generated.h”

/**
*
*/
UCLASS()
class BATTERYCOLLECTOR_API ABatteryPickup : public APickup
{
GENERATED_BODY()

public:
// Sets default values for this actor’s properties
ABatteryPickup();
};

Is this function call obsolete in 4.15? When I comment it out it says I need it and when I uncomment it the exception appears there.

After commenting out the line in AbatteryPickup, The build succeeded and the project opened in unreal, this is the line I commented out:

//GetMesh()->SetSimulatePhysics(true);

Do you happen to know why this line causes the project crash?

After a bit more testing. I found a workaround. In my Battery blueprint mesh I
checked Simulate Physics and left the SetSimulatePhysics() method in the BatteryPickup.cpp file commented. Here is an image of how I did it:

Did you ever create the PickupMesh in your BatteryPickup.cpp class?

Something like:

PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
PickupMesh->SetupAttachment();

I ask because if you didn’t do this and tried to use GetMesh( ), it would be a nullptr, causing a crash.

I have that in my pickup.cpp(As instructed in the Battery Collector tutorials). Though I did update the code to the newer version of unreal. Here’s the lines:

BaseCollisionComponent = CreateDefaultSubobject(TEXT(“BaseSphereComponent”));

= BaseCollisionComponent;