Overflows the stack

Unhandled exception at 0x00007FFD5AA4DB45 (UnrealEditor-Sanes.dll) in UnrealEditor.exe: The stack cookie instrumentation code encountered a stack-related buffer overflow. 

According to this reported error, it definitively looks like to be a stack buffer overflow (Stack buffer overflow - Wikipedia), where basically some code is writing in the stack (or worse, memory) where it should not. This is generally caused by improper index usage in arrays allocated in the stack (hence my proposal to look on that side).

This is very different from a stack overflow (ie. without the “buffer” word: Stack overflow - Wikipedia => compare and contrast the two wikipedia articles), where indeed, the issue is that there is too many things on the stack. This generally happens when there is some uncontrolled recursive call getting too deep. To be sure, check if you have some recursive process in your code.

So according to the error reported, my intuition says to me that the former case is more probable than the latter. I could be wrong of course, but just a hint to help you.

The fact it works with a few objects and not with many objects is not a symptom for which the cause is to be taken for granted. At the moment there is a buffer overflow somewhere, you enter in the “undefined behavior” (UB) world: stuff may or may not work, but the more occurences UB cases happens, the more chance something bad occurs. So the more objects, the more chance for a serious problem to happen.

I wish you good luck with these hard-to-find bugs :slight_smile: but I’m sure you’ll manage to find the issue.