Description

The engine crashes when trying to initialize a native UserWidget within another widget. This happens because UUserWidget::GetSlotNames gets called before the widget tree is initialized, and we don't check validity of the widget tree before iterating through it to locate named slots. We should investigate whether it's sufficient to wrap this in a null check, or if initialization should be reordered so that the tree is valid by the time this is called.

Steps to Reproduce
  1. Create a native UUserWidget in C++
  2. Create a UserWidget blueprint with a Canvas Panel. In PreConstruct, create your native widget and add it to the panel
  3. Engine will crash upon recompiling
Callstack

UE4Editor_UMG!UWidgetTree::ForEachWidget() [d:\ue4deveditor\engine\source\runtime\umg\private\widgettree.cpp:176]
UE4Editor_UMG!UUserWidget::GetSlotNames() [d:\ue4deveditor\engine\source\runtime\umg\private\userwidget.cpp:975]
UE4Editor_UMG!INamedSlotInterface::SetNamedSlotDesignerFlags() [d:\ue4deveditor\engine\source\runtime\umg\private\components\namedslotinterface.cpp:51]
UE4Editor_UMG!UUserWidget::SetDesignerFlags() [d:\ue4deveditor\engine\source\runtime\umg\private\userwidget.cpp:1339]
UE4Editor_UMG!UUserWidget::Initialize() [d:\ue4deveditor\engine\source\runtime\umg\private\userwidget.cpp:332]
UE4Editor_UMG!UUserWidget::CreateInstanceInternal() [d:\ue4deveditor\engine\source\runtime\umg\private\userwidget.cpp:2232]
UE4Editor_UMG!UUserWidget::CreateWidgetInstance() [d:\ue4deveditor\engine\source\runtime\umg\private\userwidget.cpp:2083]
UE4Editor_UMG!CreateWidget<UUserWidget,UUserWidget>() [d:\ue4deveditor\engine\source\runtime\umg\public\blueprint\userwidget.h:1432]
UE4Editor_UMG!UWidgetBlueprintLibrary::Create() [d:\ue4deveditor\engine\source\runtime\umg\private\widgetblueprintlibrary.cpp:62]
UE4Editor_UMG!UWidgetBlueprintLibrary::execCreate() [d:\ue4deveditor\engine\source\runtime\umg\public\blueprint\widgetblueprintlibrary.h:29]
UE4Editor_CoreUObject!UFunction::Invoke() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\class.cpp:4874]
UE4Editor_CoreUObject!UObject::CallFunction() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:927]
UE4Editor_CoreUObject!UObject::ProcessContextOpcode() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:2792]
UE4Editor_CoreUObject!UObject::execLetObj() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:2613]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:997]
UE4Editor_CoreUObject!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:828]
UE4Editor_CoreUObject!ProcessLocalFunction() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1056]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:997]
UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1081]
UE4Editor_CoreUObject!UFunction::Invoke() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\class.cpp:4874]
UE4Editor_CoreUObject!UObject::ProcessEvent() [d:\ue4deveditor\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1912]
UE4Editor_UMG!UUserWidget::PreConstruct() [d:\ue4deveditor\engine\intermediate\build\win64\ue4editor\inc\umg\userwidget.gen.cpp:1030]
UE4Editor_UMG!UUserWidget::OnWidgetRebuilt() [d:\ue4deveditor\engine\source\runtime\umg\private\userwidget.cpp:940]
UE4Editor_UMG!UWidget::TakeWidget_Private() [d:\ue4deveditor\engine\source\runtime\umg\private\components\widget.cpp:853]
UE4Editor_UMG!UWidget::TakeWidget() [d:\ue4deveditor\engine\source\runtime\umg\private\components\widget.cpp:770]
UE4Editor_UMGEditor!SDesignerView::UpdatePreviewWidget() [d:\ue4deveditor\engine\source\editor\umgeditor\private\designer\sdesignerview.cpp:2326]
UE4Editor_UMGEditor!SDesignerView::Tick() [d:\ue4deveditor\engine\source\editor\umgeditor\private\designer\sdesignerview.cpp:2414]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1234]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_Slate!SBorder::OnPaint() [d:\ue4deveditor\engine\source\runtime\slate\private\widgets\layout\sborder.cpp:120]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SOverlay::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\soverlay.cpp:96]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_SlateCore!SPanel::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:12]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_Slate!SSplitter::OnPaint() [d:\ue4deveditor\engine\source\runtime\slate\private\widgets\layout\ssplitter.cpp:164]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_Slate!SSplitter::OnPaint() [d:\ue4deveditor\engine\source\runtime\slate\private\widgets\layout\ssplitter.cpp:164]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SOverlay::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\soverlay.cpp:96]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_SlateCore!SPanel::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:12]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_Slate!SBorder::OnPaint() [d:\ue4deveditor\engine\source\runtime\slate\private\widgets\layout\sborder.cpp:120]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SOverlay::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\soverlay.cpp:96]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_SlateCore!SPanel::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:12]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_Slate!SSplitter::OnPaint() [d:\ue4deveditor\engine\source\runtime\slate\private\widgets\layout\ssplitter.cpp:164]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SOverlay::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\soverlay.cpp:96]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_SlateCore!SPanel::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:12]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SPanel::PaintArrangedChildren() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:31]
UE4Editor_SlateCore!SPanel::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\spanel.cpp:12]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SOverlay::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\soverlay.cpp:96]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SCompoundWidget::OnPaint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\scompoundwidget.cpp:35]
UE4Editor_SlateCore!SWidget::Paint() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swidget.cpp:1337]
UE4Editor_SlateCore!SWindow::PaintSlowPath() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swindow.cpp:2023]
UE4Editor_SlateCore!FSlateInvalidationRoot::PaintInvalidationRoot() [d:\ue4deveditor\engine\source\runtime\slatecore\private\fastupdate\slateinvalidationroot.cpp:212]
UE4Editor_SlateCore!SWindow::PaintWindow() [d:\ue4deveditor\engine\source\runtime\slatecore\private\widgets\swindow.cpp:2055]
UE4Editor_Slate!FSlateApplication::DrawWindowAndChildren() [d:\ue4deveditor\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1005]
UE4Editor_Slate!FSlateApplication::DrawWindowAndChildren() [d:\ue4deveditor\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1057]
UE4Editor_Slate!FSlateApplication::PrivateDrawWindows() [d:\ue4deveditor\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1224]
UE4Editor_Slate!FSlateApplication::DrawWindows() [d:\ue4deveditor\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:966]
UE4Editor_Slate!FSlateApplication::TickApplication() [d:\ue4deveditor\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1475]
UE4Editor_Slate!FSlateApplication::Tick() [d:\ue4deveditor\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1338]
UE4Editor!FEngineLoop::Tick() [d:\ue4deveditor\engine\source\runtime\launch\private\launchengineloop.cpp:4463]
UE4Editor!GuardedMain() [d:\ue4deveditor\engine\source\runtime\launch\private\launch.cpp:173]
UE4Editor!GuardedMainWrapper() [d:\ue4deveditor\engine\source\runtime\launch\private\windows\launchwindows.cpp:147]
UE4Editor!WinMain() [d:\ue4deveditor\engine\source\runtime\launch\private\windows\launchwindows.cpp:279]
UE4Editor!__scrt_common_main_seh() [d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-81457 in the post.

0
Login to Vote

Fixed
ComponentTools - UMG
Affects Versions4.234.24
Target Fix4.24
Fix Commit9731551
Main Commit9731563
Release Commit9731551
CreatedOct 7, 2019
ResolvedOct 21, 2019
UpdatedOct 24, 2019