Malloc() error from engine

I’m having a crappy time with errors in engine code. While it’s pretty obvious that it’s something I’m doing, it’s difficult to say how or why I’ve caused it.

Output:


Exception thrown at 0x000007FEDE4174DC (UE4Editor-Core.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Call stack:



     UE4Editor-Core.dll!rml::internal::LargeObjectCache::CacheBin::get(rml::internal::ExtMemoryPool * extMemPool, unsigned __int64 size, int idx) Line 102    C++    
     UE4Editor-Core.dll!rml::internal::ExtMemoryPool::mallocLargeObject(unsigned __int64 size, unsigned __int64 alignment) Line 354    C++
     UE4Editor-Core.dll!rml::internal::internalPoolMalloc(rml::internal::MemoryPool * memPool, unsigned __int64 size) Line 2046    C++
     UE4Editor-Core.dll!scalable_malloc(unsigned __int64 size) Line 2380    C++
     UE4Editor-Core.dll!FMallocTBB::Malloc(unsigned __int64 Size, unsigned int Alignment) Line 44    C++
     UE4Editor-Core.dll!operator new<TChunkedArray<FStatMessage,65536>::FChunk,FDefaultAllocator>(unsigned __int64 Size, TIndirectArray<TChunkedArray<FStatMessage,65536>::FChunk,FDefaultAllocator> & Array) Line 3358    C++
     UE4Editor-Core.dll!FStatsThreadState::UpdateStatMessagesMemoryUsage() Line 1032    C++
     UE4Editor-Core.dll!FStatsThread::Tick() Line 877    C++
     UE4Editor-Core.dll!FStatsThread::StatMessage(FStatPacket * Packet) Line 936    C++
     UE4Editor-Core.dll!TGraphTask<FStatMessagesTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 779    C++
     UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 539    C++
     UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 340    C++
     UE4Editor-Core.dll!FStatsThread::Run() Line 839    C++
     UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 74    C++
     UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 23    C++


Is it possible that this is actually just a bug? I’m going to start the arduous process of disabling code in my plugin to help figure it out, but any shortcuts would be appreciated.

The errors are also inconsistent. Here’s another one:

Output:


Exception thrown at 0x000007FEE0C89B46 (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Call stack:



    UE4Editor-CoreUObject.dll!UObjectBase::IsValidLowLevelFast(bool bRecursive) Line 237    C++

     UE4Editor-CoreUObject.dll!FGCCollector::HandleObjectReference(UObject * & Object, const UObject * ReferencingObject, const UProperty * ReferencingProperty) Line 407    C++

     UE4Editor-CoreUObject.dll!UObject::AddReferencedObjects(UObject * This, FReferenceCollector & Collector) Line 1464    C++

     UE4Editor-CoreUObject.dll!FArchiveRealtimeGC::ProcessObjectArray(TArray<UObject *,FDefaultAllocator> & InObjectsToSerializeArray, TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 862    C++
     UE4Editor-CoreUObject.dll!TGraphTask<FArchiveRealtimeGC::FGCTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 779    C++
     UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 539    C++
     UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 340    C++
     UE4Editor-Core.dll!FTaskThread::Run() Line 690    C++
     UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 74    C++
     UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 23    C++


The bizarre thing is, this is the line that’s throwing an error:


if (*(void**)this == NULL)

…and if I add a watch for “this” it’s defined, but a lot of values in it are null:

How is that particular line causing an exception?

Uninitialized memory by the looks of the watch window.

There are too many pointers in that snippet for me to understand what’s going on :smiley:

I seem to have solved it. I was calling a function in my DLL twice by mistake that should only be called once. Obviously not a safe activity if that causes it to mess with UE’s memory. :slight_smile: