Skip to content

Game crashing a lot since +1 month #4635

@toxiicdev

Description

@toxiicdev

Describe the bug

A lot of mta players playing on DM servers (deathmatch races), most of those crashes are invalid access exceptions, or random crashes

Steps to reproduce

Just play for a bit on servers with a lot of mods (infernus, draw distance, etc)...

Version

Any after november 2025

Additional context

I wonder if you could add something like a VectoredExceptionHandler in the injected dll's to prevent crashes, and automatically report them to mta devs

example of a code i did time ago on a x86 game that was having similar issues:

LONG WINAPI CustomExceptionHandler(PEXCEPTION_POINTERS p)
{
if (p->ExceptionRecord->ExceptionCode != STATUS_ACCESS_VIOLATION)
return EXCEPTION_CONTINUE_SEARCH;

CONTEXT* ctx = p->ContextRecord;
DWORD eip = (DWORD)p->ExceptionRecord->ExceptionAddress;

char buf[1024];

wsprintfA(buf,
    "Access violation at %08X\n"
    "EAX=%08X EBX=%08X ECX=%08X EDX=%08X\n"
    "ESI=%08X EDI=%08X EBP=%08X ESP=%08X\n"
    "EIP=%08X\n",
    eip,
    ctx->Eax, ctx->Ebx, ctx->Ecx, ctx->Edx,
    ctx->Esi, ctx->Edi, ctx->Ebp, ctx->Esp,
    ctx->Eip);

Log::Write(buf);

// ================= STACK DUMP =================
Log::Write("Stack dump\n");

DWORD esp = ctx->Esp;

for (int i = 0; i < 256; i++)
{
    DWORD addr = esp + (i * 4);

    MEMORY_BASIC_INFORMATION mbi;
    if (!VirtualQuery((void*)addr, &mbi, sizeof(mbi)))
        break;

    if (mbi.State != MEM_COMMIT || (mbi.Protect & PAGE_NOACCESS))
        continue;

    DWORD value = *(DWORD*)addr;

    wsprintfA(buf, "[ESP + %X] -> %08X\n", i * 4, value);
    Log::Write(buf);
}

// ================= MODULE ==================
Log::Write("Module:\n");

HMODULE mods[512];
DWORD needed;

if (EnumProcessModules(GetCurrentProcess(), mods, sizeof(mods), &needed))
{
    for (DWORD i = 0; i < needed / sizeof(HMODULE); i++)
    {
        MODULEINFO mi;
        if (!GetModuleInformation(GetCurrentProcess(), mods[i], &mi, sizeof(mi)))
            continue;

        DWORD base = (DWORD)mi.lpBaseOfDll;
        DWORD end = base + mi.SizeOfImage;

        if (eip >= base && eip < end)
        {
            char name[MAX_PATH];
            GetModuleFileNameA(mods[i], name, MAX_PATH);

            wsprintfA(buf, "%s @ %08X Size: %X\n", name, base, mi.SizeOfImage);
            Log::Write(buf);
            break;
        }
    }
}

Log::Write("====================================\n");
return EXCEPTION_EXECUTE_HANDLER;

}

And in DllMain I was adding the callback for the vectored exception handler:

AddVectoredExceptionHandler(0, CustomExceptionHandler);

Relevant log output

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions