# Strange null pointer exception

**URL:** <https://forums.unrealengine.com/t/strange-null-pointer-exception/396054>\
**Category:** UI\
**Tags:** asset-pointer, unreal-engine, crash, Widget, UE4, question, CPP\
**Created:** [June 12, 2017, 12:38pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054 "2017-06-12T12:38:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holiska](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Holiska](https://forums.unrealengine.com/u/Holiska)\
**Post date:** [June 12, 2017, 12:38pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054/1 "2017-06-12T12:38:32Z")

</div>

Hello everyone,  
i post this because it’s been 3 hours i’m trying to resolve this strange error.  
This causes my editor to crash, so i now launch my editor with visual studio on debug mode.

```
ULPLAYERCONTROLLER.H:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
	TSubclassOf<class UUserWidget> wMainMenu;

	UUserWidget* wMainMenuRef;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
	TSubclassOf<class UUserWidget> wPlayMenu;

	UUserWidget* wPlayMenuRef;

```

so here are my references to my widgets

i initialize them here:

```
ULPLAYERCONTROLLER.CPP:

void AULPlayerControllerBase::SetupMenuWidgets()
{
	if (IsLocalPlayerController())
	{
		if (wPlayMenu)
		{
			wPlayMenuRef = CreateWidget<UUserWidget>(this, wPlayMenu);
		}
		if (wMainMenu)
		{
			wMainMenuRef = CreateWidget<UUserWidget>(this, wMainMenu);
		}
	
	}
	
}

```

and then i show them here:

```
ULPLAYERCONTROLLER.CPP
void AULPlayerControllerBase::BeginPlayMenuState()
{
	if (wPlayMenu)
	{
		if (wPlayMenuRef)
		{
			if (!wPlayMenuRef->IsInViewport())
			{
				wPlayMenuRef->AddToViewport();
			}
				wPlayMenuRef->SetVisibility(ESlateVisibility::Visible);
			
		}
		bShowMouseCursor = true;
	}
	
}
void AULPlayerControllerBase::BeginMainMenuState()
{
	if (wMainMenuRef)
	{
		if (!wMainMenuRef->IsInViewport())
		{
			wMainMenuRef->AddToViewport();
		}

		wMainMenuRef->SetVisibility(ESlateVisibility::Visible);
		bShowMouseCursor = true;
	}
	

}

```

the thing i dont understand is that the project launch well, the main menu is showed and then when i naviguate to my Play Menu, i have an exception :

```
Exception thrown at 0x00007FF9641289F6 (UE4Editor-UMG.dll) in UE4Editor.exe: 0xC0000005: Read access violation of location 0xFFFFFFFFFFFFFFFF.

```

the exception is thrown at this line:

```
if (!wPlayMenuRef->IsInViewport())

```

the thing is that i checked this variable and this code should not be accessed if the wplaymenuref is a null pointer.  
Thank you for helping me, i’m confused !

---

<div class="post-metadata">

**Author:** ![NoobsDeSroobs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoobsDeSroobs](https://forums.unrealengine.com/u/NoobsDeSroobs)\
**Post date:** [June 12, 2017, 12:58pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054/2 "2017-06-12T12:58:00Z")

</div>

You are checking if it is NULL, that is 0x00000000. The variable is instead 0xFFFFFFFF. Thus it passes your test and it does not crash.

It is not a nullpointer exception, it is an access violation error because you try to access RAM outside of what you have. Something before it failed and windows returned 0xFFFFFFFFFF which is the invalid handle error.

HTH

---

<div class="post-metadata">

**Author:** ![Holiska](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Holiska](https://forums.unrealengine.com/u/Holiska)\
**Post date:** [June 12, 2017, 1:09pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054/3 "2017-06-12T13:09:01Z")

</div>

So i don’t have enough ram ? is there a way to avoid that ?

---

<div class="post-metadata">

**Author:** ![NoobsDeSroobs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoobsDeSroobs](https://forums.unrealengine.com/u/NoobsDeSroobs)\
**Post date:** [June 12, 2017, 1:32pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054/4 "2017-06-12T13:32:14Z")

</div>

No, the problem is that the pointer returned is an error code. It failed to create the object requested, for example a window or open a file, and to tell you that it returns 0xFFFFFFFF. It is not a matter of having enough RAM.

---

<div class="post-metadata">

**Author:** ![Holiska](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Holiska](https://forums.unrealengine.com/u/Holiska)\
**Post date:** [June 12, 2017, 3:39pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054/5 "2017-06-12T15:39:14Z")

</div>

For those who have the same error, i finally figured it out.  
I just had to add “UPROPERTY()” to all my UUserWidget references.

---

<div class="post-metadata">

**Author:** ![Zarrar2802](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zarrar2802/32/710746_2.png) [@Zarrar2802](https://forums.unrealengine.com/u/Zarrar2802)\
**Post date:** [October 11, 2025, 1:32pm UTC](https://forums.unrealengine.com/t/strange-null-pointer-exception/396054/6 "2025-10-11T13:32:59Z")

</div>

UE5 has more null pointers than the entire town of Nowhere.
