Crash when printing inside function


void FMsg::Logf_InternalImpl(const ANSICHAR* File, int32 Line, const FName& Category, ELogVerbosity::Type Verbosity, const TCHAR* Fmt, ...)
{
#if !NO_LOGGING
    QUICK_SCOPE_CYCLE_COUNTER(STAT_FMsgLogf);
    CSV_CUSTOM_STAT(FMsgLogf, FMsgLogfCount, 1, ECsvCustomStatOp::Accumulate);

    if (Verbosity != ELogVerbosity::Fatal)
    {
        // SetColour is routed to GWarn just like the other verbosities and handled in the
        // device that does the actual printing.
        FOutputDevice* LogDevice = NULL;
        switch (Verbosity)
        {
        case ELogVerbosity::Error:
        case ELogVerbosity::Warning:
        case ELogVerbosity::Display:
        case ELogVerbosity::SetColor:
            if (GWarn)
            {
                LogDevice = GWarn;
                break;
            }
        default:
        {
            LogDevice = GLog;
        }
        break;
        }
        GROWABLE_LOGF(LogDevice->Log(Category, Verbosity, Buffer)) // <--------------------------------------------Our culprit
    }
    else
    {
        // Keep Message buffer small, in some cases, this code is executed with 16KB stack.
        TCHAR Message[4096];
        {
            // Simulate Sprintf_s
            // @todo: implement platform independent sprintf_S
            // We're using one big shared static buffer here, so guard against re-entry
            FScopeLock MsgLock(&MsgLogfStaticBufferGuard);
            // Print to a large static buffer so we can keep the stack allocation below 16K
            GET_VARARGS(MsgLogfStaticBuffer, ARRAY_COUNT(MsgLogfStaticBuffer), ARRAY_COUNT(MsgLogfStaticBuffer) - 1, Fmt, Fmt);
            // Copy the message to the stack-allocated buffer)
            FCString::Strncpy(Message, MsgLogfStaticBuffer, ARRAY_COUNT(Message) - 1);
            Message[ARRAY_COUNT(Message) - 1] = '\0';
        }

        const int32 NumStackFramesToIgnore = 1;
        StaticFailDebug(TEXT("Fatal error:"), File, Line, Message, false, NumStackFramesToIgnore);
    }
#endif
}