Plugin reload crash

Hi,

I’m currently exploring the making of plugins and I found a annoying crash when trying to change my plugin runtime.

Reproduction steps:

 Create a new c++ project from scratch
 Open Edit > Plugins
 Press New Plugin and select "Toolbar Button"
 Exit editor and recompile
 Open editor
 Change implementation of PluginButtonClicked, by adding a log or anything
 Open Window > Developer > Modules
 Click recompile of your toolbar button
 After recompile, press your toolbar button, notice that your added logic doesn't happen
 Open Window and the editor crashes with callstack

Unknown exception - code 00000001 (first/second chance not available)

"Assertion failed: IsValid() [File:C:\Program Files\Epic Games\4.10\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 728]
"

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\misc\outputdevice.cpp:374]
UE4Editor_MyToolbarButton_4667!TCommands<FMyToolbarButtonCommands>::Get() [c:\program files\epic games\4.10\engine\source\runtime\slate\public\framework\commands\commands.h:61]
UE4Editor_MyToolbarButton_4667!FMyToolbarButtonModule::AddMenuExtension() [c:\users\rannarem\documents\unreal projects\coolgameee\plugins\mytoolbarbutton\source\mytoolbarbutton\private\mytoolbarbutton.cpp:75]
UE4Editor_MyToolbarButton_4667!TBaseRawMethodDelegateInstance<0,FMyToolbarButtonModule,void __cdecl(FMenuBuilder & __ptr64)>::ExecuteIfSafe() [c:\program files\epic games\4.10\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:582]
UE4Editor_Slate!FExtender::Apply() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\multibox\multiboxextender.cpp:191]
UE4Editor_Slate!FMenuBuilder::ApplyHook() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\multibox\multiboxbuilder.cpp:289]
UE4Editor_Slate!FMenuBuilder::EndSection() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\multibox\multiboxbuilder.cpp:195]
UE4Editor_MainFrame!FMainMenu::FillWindowMenu() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\mainframe\private\menus\mainmenu.cpp:284]
UE4Editor_MainFrame!TBaseStaticDelegateInstance<TTypeWrapper<void> __cdecl(FMenuBuilder & __ptr64),TSharedRef<FExtender,0>,TSharedPtr<FTabManager,0> >::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:854]
UE4Editor_Slate!SMenuEntryBlock::MakeNewMenuWidget() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\multibox\smenuentryblock.cpp:1294]
UE4Editor_Slate!TMemberFunctionCaller<SMenuEntryBlock,TSharedRef<SWidget,0> (__cdecl SMenuEntryBlock::*)(void)const __ptr64>::operator()<>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstanceinterface_variadics.h:161]
UE4Editor_Slate!TTupleImpl<TIntegerSequence<> >::ApplyAfter_ExplicitReturnType<TSharedRef<SWidget,0>,TMemberFunctionCaller<SMenuEntryBlock,TSharedRef<SWidget,0> (__cdecl SMenuEntryBlock::*)(void)const __ptr64> >() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\tuple.h:113]
UE4Editor_Slate!TBaseSPMethodDelegateInstance<1,SMenuEntryBlock,0,TSharedRef<SWidget,0> __cdecl(void)>::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:282]
UE4Editor_Slate!TBaseDelegate<TSharedRef<SWidget,0> >::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:440]
UE4Editor_Slate!SMenuAnchor::SetIsOpen() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\widgets\input\smenuanchor.cpp:294]
UE4Editor_Slate!SMenuEntryBlock::OnClicked() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\multibox\smenuentryblock.cpp:996]
UE4Editor_Slate!SMenuEntryBlock::OnMenuItemButtonClicked() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\multibox\smenuentryblock.cpp:927]
UE4Editor_Slate!TMemberFunctionCaller<SMenuEntryBlock,FReply (__cdecl SMenuEntryBlock::*)(void) __ptr64>::operator()<>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstanceinterface_variadics.h:161]
UE4Editor_Slate!TTupleImpl<TIntegerSequence<> >::ApplyAfter_ExplicitReturnType<FReply,TMemberFunctionCaller<SMenuEntryBlock,FReply (__cdecl SMenuEntryBlock::*)(void) __ptr64> >() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\tuple.h:113]
UE4Editor_Slate!TBaseSPMethodDelegateInstance<0,SMenuEntryBlock,0,FReply __cdecl(void)>::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:282]
UE4Editor_Slate!TBaseDelegate<FReply>::Execute() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:440]
UE4Editor_Slate!SButton::OnMouseButtonDown() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\widgets\input\sbutton.cpp:180]
UE4Editor_Slate!<lambda_fe59d5648f2f8779b5db8a4c6c6e3cfd>::operator()() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4196]
UE4Editor_Slate!FEventRouter::Route<FReply,FEventRouter::FBubblePolicy,FPointerEvent,<lambda_fe59d5648f2f8779b5db8a4c6c6e3cfd> >() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:214]
UE4Editor_Slate!FSlateApplication::RoutePointerDownEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4185]
UE4Editor_Slate!FSlateApplication::ProcessMouseButtonDownEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4143]
UE4Editor_Slate!FSlateApplication::OnMouseDown() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:4079]
UE4Editor_Core!FWindowsApplication::ProcessDeferredMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\windows\windowsapplication.cpp:1354]
UE4Editor_Core!FWindowsApplication::DeferMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\windows\windowsapplication.cpp:1721]
UE4Editor_Core!FWindowsApplication::ProcessMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\windows\windowsapplication.cpp:719]
UE4Editor_Core!FWindowsApplication::AppWndProc() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\windows\windowsapplication.cpp:641]
user32
user32
UE4Editor_Core!FWindowsPlatformMisc::PumpMessages() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\windows\windowsplatformmisc.cpp:884]
UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:2391]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

This is tested in 4.10.2 and 4.11.0 preview 3

Cheers,

Hey MarkusRannare-

I followed the steps listed but did not receive a crash when clicking the button. Are you using the engine from source code or the binary version from the Launcher? Can you post the log files from your crash as well?

Cheers

Hi ,

I’m running from Launcher version.

And to clarify, by “Window” I mean the Window dropdown menu right beside “Edit”
( this is where the toolbar adds a menu extension )

This is also verified now on my computer at home running 4.10.2 with exact same crash.

The log from 4.11 prev 3 is here:

PS: Important to actually change anything in a file before recompile (adding a newline is enough)

Edit:
I also noted now that I have developed another plugin in 4.10 where I register a hook on the right click menu using: GetAllLevelViewportContextMenuExtenders, it seems to crash when I open up the right click menu and showing the button after a recompile of the module

After further testing I am still unable to reproduce the crash. Here are the steps I used to test:

  1. Create a new project based on the Basic Code template
  2. Edit->Plugins
  3. Click the “New plugin” button and select Toolbar Button with a name of MyPlugin
  4. Close the editor
  5. In Visual Studio, Build the project to compile it.
  6. Reopen the editor
  7. In MyPlugin.cpp in Visual Studio- I added UE_LOG(LogTemp, Warning, TEXT("Your message")); at the beginning of void FMyPluginModule::PluginButtonClicked()
  8. In the editor go to Windows->Developer Tools->Modules
  9. Find MyPlugin and press the Recompile button
  10. When the compile finishes, press teh toolbar button for MyPlugin

When I click the toolbar button there is a prompt to add code to PluginButtonClicked() however the editor does not crash. If I restart the project at this point then clicking the toolbar button gives the same prompt and will show the “Your Message” text as a warning in the output log.

I’m sorry, I guess my reproduction steps was not detailed enough.

Step 10 should be:
Open the “Window” dropdown, that is, the menu to the right of the “Edit” dropdown. See attached image for what dropdown menu I mean.

76183-editorcrash.png

Thanks for keeping up with me here Daug.

Hey -

I missed that accessing the Window menu bar was part of the reproduction steps. I was able to reproduce the crash and have entered a bug report (UE-26081) for investigation.

Cheers

This issue still exists in 4.22.1 (launcher version) but the bug report was closed. The issue can also be reproduced by reloading the module and not only when recompiling. I’ve added some code to my Shutdown() function to remove the MenuExtender but it doesn’t resolve the issue.

Issue

  1. Create plugin that uses a MenuExtender (e.g. default plugin example for nomad tab)

  2. In Window -> Developer Tools -> Modules either reload, unload or recompile the plugin

  3. Click the Window menu option from the main menu bar
    Expected:

  4. Menu loads as normal (or in the case of unload without the plugin menu entry
    Actual:

  5. Editor crashes

Fix attempts:

  • Remove MenuExtender on shutdown Crash
  • Remove MenuExtensions from MenuExtender on shutdown Crash
  • Remove usage of MenuExtender entirely No crash

Furthermore, this doesn’t seem to be an issue with ToolbarExtensions but there is still some unexpected behavior when removing a ToolbarExtension on Shutdown(). The icon is removed but the extension and button persist. I suspect this might be related to the issue (I.E. on unloading these plugin modules the toolbars/menus don’t get cleaned up properly). See attached image.

287975-toolbarpluginreload.png

UE bug reports

Attachments