I have a plugin that defines an Actor (AFirstActor) that I’d like to access from a project C++ Actor (ASecondActor). I have a method to find the FirstActor from the SecondActor:
AFirstActor *ASecondActor::GetFirstActor()
{
UWorld *World = GetWorld();
if(World && FModuleManager::Get().IsModuleLoaded("FirstModule"))
{
for (TActorIterator<AFirstActor> FirstActor(World); FirstActor; ++FirstActor)
{
return *FirstActor;
}
}
return nullptr;
}
This compiles, but when I start the editor it crashes with this stack trace:
[2017.07.27-06.41.27:233][ 0]LogHAL: Linux SourceCodeAccessSettings: NullSourceCodeAccessor
[2017.07.27-06.41.28:188][ 0]LogUdpMessaging: Initializing bridge on interface 0.0.0.0:0 to multicast group 230.0.0.1:6666.
*** Error in `/home/pmelick/.unreal_engine/987fd48b18295d03b57f51e36abb7979/Engine/Binaries/Linux/UE4Editor': free(): invalid size: 0x00007f2027031d90 ***
Signal 6 caught.
Malloc Size=131076 LargeMemoryPoolOffset=131092
CommonLinuxCrashHandler: Signal=6
Malloc Size=65535 LargeMemoryPoolOffset=196655
[2017.07.27-06.41.28:698][ 0]LogLinux: === Critical error: ===
Unhandled Exception: SIGABRT: abort() called
[2017.07.27-06.41.28:698][ 0]LogLinux: Fatal error!
[Callstack] 00 0x00007f208a61767f FLinuxPlatformStackWalk::CaptureStackBackTrace(unsigned long long*, unsigned int, void*)
[Callstack] 01 0x00007f208a4cc5c6 FGenericPlatformStackWalk::StackWalkAndDump(char*, unsigned long, int, void*)
[Callstack] 02 0x00007f208a5cf182 FLinuxCrashContext::CaptureStackTrace()
[Callstack] 03 0x00007f207f417620 CommonLinuxCrashHandler(FGenericCrashContext const&)
[Callstack] 04 0x00007f208a5d445d PlatformCrashHandler(int, siginfo_t*, void*)
[Callstack] 05 0x00007f208b3c6330 /lib/x86_64-linux-gnu/libpthread.so.0(+0x10330) [0x7f208b3c6330]
[Callstack] 06 0x00007f207e964c37 /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f207e964c37]
[Callstack] 07 0x00007f207e968028 /lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f207e968028]
[Callstack] 08 0x00007f207e9a12a4 /lib/x86_64-linux-gnu/libc.so.6(+0x732a4) [0x7f207e9a12a4]
[Callstack] 09 0x00007f207e9ad55e /lib/x86_64-linux-gnu/libc.so.6(+0x7f55e) [0x7f207e9ad55e]
[Callstack] 10 0x00007f2000bee389 google::protobuf::FileDescriptorProto::SharedDtor()
[Callstack] 11 0x00007f2000bee47c google::protobuf::FileDescriptorProto::~FileDescriptorProto()
[Callstack] 12 0x00007f2000c01115 google::protobuf::EncodedDescriptorDatabase::Add(void const*, int)
[Callstack] 13 0x00007f2000bc840a google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int)
[Callstack] 14 0x00007f2000bfa41c google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto()
[Callstack] 15 0x00007f208b5e420a /lib64/ld-linux-x86-64.so.2(+0x1020a) [0x7f208b5e420a]
[Callstack] 16 0x00007f208b5e42f3 /lib64/ld-linux-x86-64.so.2(+0x102f3) [0x7f208b5e42f3]
[Callstack] 17 0x00007f208b5e8fd7 /lib64/ld-linux-x86-64.so.2(+0x14fd7) [0x7f208b5e8fd7]
[Callstack] 18 0x00007f208b5e40c4 /lib64/ld-linux-x86-64.so.2(+0x100c4) [0x7f208b5e40c4]
[Callstack] 19 0x00007f208b5e84db /lib64/ld-linux-x86-64.so.2(+0x144db) [0x7f208b5e84db]
[Callstack] 20 0x00007f207e72b02b /lib/x86_64-linux-gnu/libdl.so.2(+0x102b) [0x7f207e72b02b]
[Callstack] 21 0x00007f208b5e40c4 /lib64/ld-linux-x86-64.so.2(+0x100c4) [0x7f208b5e40c4]
[Callstack] 22 0x00007f207e72b62d /lib/x86_64-linux-gnu/libdl.so.2(+0x162d) [0x7f207e72b62d]
[Callstack] 23 0x00007f207e72b0c1 /lib/x86_64-linux-gnu/libdl.so.2(dlopen+0x31) [0x7f207e72b0c1]
[Callstack] 24 0x00007f208a5e0244 FLinuxPlatformProcess::GetDllHandle(wchar_t const*)
[Callstack] 25 0x00007f208a70c74a FModuleManager::LoadModuleWithFailureReason(FName, EModuleLoadResult&, bool)
[Callstack] 26 0x00007f2084114eda FModuleDescriptor::LoadModulesForPhase(ELoadingPhase::Type, TArray<FModuleDescriptor, FDefaultAllocator> const&, TMap<FName, EModuleLoadResult, FDefaultSetAllocator, TDefaultMapKeyFuncs<FName, EModuleLoadResult, false> >&)
[Callstack] 27 0x00007f2084129553 FProjectManager::LoadModulesForProject(ELoadingPhase::Type)
[Callstack] 28 0x0000000000435b6b FEngineLoop::LoadStartupModules()
[Callstack] 29 0x000000000041c403 FEngineLoop::PreInit(wchar_t const*)
[Callstack] 30 0x000000000042d648 GuardedMain(wchar_t const*)
[Callstack] 31 0x00007f207f41850d CommonLinuxMain(int, char**, int (*)(wchar_t const*))
[Callstack] 32 0x00007f207e94ff45 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f207e94ff45]
[Callstack] 33 0x0000000000417bfe /home/pmelick/.unreal_engine/987fd48b18295d03b57f51e36abb7979/Engine/Binaries/Linux/UE4Editor() [0x417bfe]
[2017.07.27-06.41.28:709][ 0]LogExit: Executing StaticShutdownAfterError
Malloc Size=40855 LargeMemoryPoolOffset=237527
I don’t call this function from anywhere right now. An instance of ASecondActor does not even exist in the scene. The offending statement seems to be TActorIterator FirstActor(World)
. I’ve tried checking the World’s bIsWorldInitialized
, bBegunPlay
, and bStartup
to prevent running that line when it’s invalid to no effect.