C++ Bad Index Crash (Reproducible)

4.7.5

  1. Create a new actor class and use the code snippet below to initialize it with a root box component.
  2. Load the editor and drag the actor onto a new map.
  3. Save the map and create another empty map.
  4. Load in the saved map w/the actor.

Code Snippet

ARoom::ARoom(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = false;

	// Create root component as a box
	auto box = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("Box"));
	box->SetBoxExtent(FVector(50, 50, 50));
	RootComponent = box;
}

Crash Report

MachineId:DCE8D35941A624B76AF82E88BE87A65A

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

Fatal error: [File:D:\UE4\UnrealEngine\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp] [Line: 4014] 
Bad name index -1//39

KERNELBASE + 37901 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:531]
UE4Editor_CoreUObject!ULinkerLoad::operator<<() + 212 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\linkerload.cpp:4014]
UE4Editor_CoreUObject!operator<<() + 36 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\public\uobject\propertytag.h:80]
UE4Editor_CoreUObject!UStruct::SerializeTaggedProperties() + 342 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\class.cpp:793]
UE4Editor_CoreUObject!UObject::SerializeScriptProperties() + 292 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\obj.cpp:903]
UE4Editor_CoreUObject!UObject::Serialize() + 581 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\obj.cpp:845]
UE4Editor_Engine!USceneComponent::Serialize() + 22 bytes [d:\ue4\unrealengine\engine\source\runtime\engine\private\scenecomponent.cpp:1253]
UE4Editor_Engine!UPrimitiveComponent::Serialize() + 21 bytes [d:\ue4\unrealengine\engine\source\runtime\engine\private\primitivecomponent.cpp:495]
UE4Editor_CoreUObject!ULinkerLoad::Preload() + 3148 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\linkerload.cpp:2972]
UE4Editor_CoreUObject!EndLoad() + 974 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1092]
UE4Editor_CoreUObject!LoadPackageInternal() + 2248 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:906]
UE4Editor_CoreUObject!ResolveName() + 1483 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:610]
UE4Editor_CoreUObject!StaticLoadObject() + 655 bytes [d:\ue4\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:697]
UE4Editor_ContentBrowser!FAssetData::GetAsset() + 183 bytes [d:\ue4\unrealengine\engine\source\runtime\assetregistry\public\assetdata.h:178]
UE4Editor_ContentBrowser!SContentBrowser::OnAssetsActivated() + 1179 bytes [d:\ue4\unrealengine\engine\source\editor\contentbrowser\private\scontentbrowser.cpp:1576]
UE4Editor_ContentBrowser!TBaseSPMethodDelegateInstance<0,SContentBrowser,0,TTypeWrapper<void> __cdecl(TArray<FAssetData,FDefaultAllocator> const & __ptr64,enum EAssetTypeActivationMethod::Type)>::Execute() + 87 bytes [d:\ue4\unrealengine\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:282]
UE4Editor_ContentBrowser!TBaseSPMethodDelegateInstance<0,SContentBrowser,0,void __cdecl(TArray<FAssetData,FDefaultAllocator> const & __ptr64,enum EAssetTypeActivationMethod::Type)>::ExecuteIfSafe() + 71 bytes [d:\ue4\unrealengine\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:388]
UE4Editor_ContentBrowser!SAssetView::OnListMouseButtonDoubleClick() + 835 bytes [d:\ue4\unrealengine\engine\source\editor\contentbrowser\private\sassetview.cpp:3207]
UE4Editor_ContentBrowser!TBaseSPMethodDelegateInstance<0,SAssetView,0,TTypeWrapper<void> __cdecl(TSharedPtr<FAssetViewItem,0>)>::Execute() + 97 bytes [d:\ue4\unrealengine\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:282]
UE4Editor_ContentBrowser!TBaseSPMethodDelegateInstance<0,SAssetView,0,void __cdecl(TSharedPtr<FAssetViewItem,0>)>::ExecuteIfSafe() + 90 bytes [d:\ue4\unrealengine\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:388]
UE4Editor_ContentBrowser!TBaseDelegate<void,TSharedPtr<FAssetViewItem,0> >::ExecuteIfBound() + 86 bytes [d:\ue4\unrealengine\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:518]
UE4Editor_ContentBrowser!SListView<TSharedPtr<FAssetViewItem,0> >::Private_OnItemDoubleClicked() + 63 bytes [d:\ue4\unrealengine\engine\source\runtime\slate\public\widgets\views\slistview.h:693]
UE4Editor_ContentBrowser!STableRow<TSharedPtr<FAssetViewItem,0> >::OnMouseButtonDoubleClick() + 223 bytes [d:\ue4\unrealengine\engine\source\runtime\slate\public\widgets\views\stablerow.h:252]
UE4Editor_Slate!<lambda_58ede244782f1e594383d45514e1d7c8>::operator()() + 30 bytes [d:\ue4\unrealengine\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:3918]
UE4Editor_Slate!FEventRouter::Route<FReply,FEventRouter::FBubblePolicy,FPointerEvent,<lambda_58ede244782f1e594383d45514e1d7c8> >() + 189 bytes [d:\ue4\unrealengine\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:202]
UE4Editor_Slate!FSlateApplication::ProcessMouseButtonDoubleClickEvent() + 471 bytes [d:\ue4\unrealengine\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:3919]
UE4Editor_Slate!FSlateApplication::OnMouseDoubleClick() + 315 bytes [d:\ue4\unrealengine\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:3900]
UE4Editor_Core!FWindowsApplication::ProcessDeferredMessage() + 3176 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\windows\windowsapplication.cpp:1315]
UE4Editor_Core!FWindowsApplication::DeferMessage() + 318 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\windows\windowsapplication.cpp:1669]
UE4Editor_Core!FWindowsApplication::ProcessMessage() + 4016 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\windows\windowsapplication.cpp:742]
UE4Editor_Core!FWindowsApplication::AppWndProc() + 114 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\windows\windowsapplication.cpp:604]
user32 + 105425 bytes
user32 + 104666 bytes
UE4Editor_Core!FWindowsPlatformMisc::PumpMessages() + 118 bytes [d:\ue4\unrealengine\engine\source\runtime\core\private\windows\windowsplatformmisc.cpp:774]
UE4Editor!FEngineLoop::Tick() + 3737 bytes [d:\ue4\unrealengine\engine\source\runtime\launch\private\launchengineloop.cpp:2233]
UE4Editor!GuardedMain() + 1404 bytes [d:\ue4\unrealengine\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\ue4\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\ue4\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

Hey -

I added an actor class with the code you provided to a project in 4.7.6 and follows the steps you described and did not crash after creating a new level / loading back into the original level. What is the parent class of where the code snippet is being added so that I can test with the same class type. If it’s possible can you upgrade to the 4.7.6 hotfix and let me know if you still get the crash?

Cheers

Hey ,

It has to do w/an actor spawning another actor into the world and settings its owner. I’m in 4.8 (preview 4) and these are the exact files you can use for your scenario. After you build w/these two classes all you want to do is drop into an empty map the TestActorParent actor which will spawn a TestActorChild actor 1 time. Then save the map and reopen the map. You should get the error.link text

I copied the classes into a project and then added an instance of the parent class itself as well as a blueprint based off of the parent class to the level. After saving I created a new level and then opened the original level again which did not crash. If possible can you send the full crash logs inside the Saved->Logs folder of your project directory as well as the DXDiag for your machine for us to take a look at?

No problem. Here is a zip file that contains the dxdiag, source code, bugged map, and log file. All I did was drag/drop the TestActorParent class onto the map and save it. The drag/drop operation will automatically spawn a child actor. After saving and reopening you get the crash.

4.8.0 (P4)link text

Thanks,

Hey -

Using the classes you provided I had to add an include statement for “Engine.h” inside the parent.cpp in order for the TActorIterator child(GetWorld()); child; ++child) line to compile properly. When I added an instance of the parent class to the level and saved I was able to create a new level and then reopen the first level with no crash. Since the include statement is the only difference other than project name I would suggest trying to add it to your project. If you are still having problem after adding the include statement please send a sample project where the crash occurs so that I can see exactly what you’re seeing.

Cheers

I added the map file that you should be able to open! I’m also not sure how you were not able to compile using the exact c++ files I had. They were taken right out of my 4.8.0 CodeProject solution.

Adding the map to my project I was able to open it and received an error in the message log:

/Game/ThirdPerson/Maps/BuggedMap : Can't find file for asset. /Script/CodePrpoject
Faild to load /Script/CoodeProject.TestActorChild Reference by PersistentLevel

This is likely because the level is referencing something from your project that I don’t have. This message appears after the level opens and can be dismissed without a crash.

As for adding the include file, it’s possible that you have the include statement in one of the other files of your project in a place that I don’t. Please let me know if adding the two classes you sent me cause a crash for you in a new project. If so let me know what steps you took so I can understand what I’ve done differently.

This is not resolved. I just bought a brand new laptop the other day and finished setting it up w/the latest 4.8 preview. Please do the following steps exactly: (do not use some other code base!)

I include all source and content.

Create a new C++ code project called CodeProject
include all source files in the Zip.
Copy over all content files in the Zip. Should only be a Maps & Meshes directory that is new.

Compile and run. You should run into an error if you double click on the Region map. IF you don’t then please Drag the Region actor onto a map and save it, then reload the map.

This is the 3rd machine now that does the same thing. You should not have to do anything other than the steps I provided you with. And again, please make sure you are running the 4.8 PREVIEW 4 from the unreal installer rather than some internal build you may have.

link text

I hope you were able to reproduce it by loading the include map. I’m trying to debug it but can’t figure out what exact class/struct/property that is failing. It has to do with serializing one of my objects I’m assuming:

http://.ms/1KL3wHs

Hey -

You’re correct that the issue has to do with serialization. I was able to reproduce it with the full content you provided however it was not caused by TestActorParent / TestActorChild that you originally sent. From what I can tell so far the serialization issue has to do with the Region class instance creating the Room but I’ve not narrowed it down further yet. You may want to review your Region and Room classes.

I’m glad you could reproduce it now so it can be fixed! I do not know what I’m doing wrong w/the C++ that would cause it! Please let me know when you all have figured it out.

Hey -

For additional hep in debugging this issue your best options would be to try posing your question to the C++ section of the AnswerHub or on the forums (https://forums.unrealengine.com/forumdisplay.php?9-C-Gameplay-Programming). We are unable to debug each individual issue in someone’s code however input from other community members may help you find where the problem exists.

Cheers