Skip to content

[AC] [Bug/Crash] [Core] Crashes when (un)loading maps / bgs #1011

@Ramvaris

Description

@Ramvaris

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that my issue may get closed without notice if I intentionally remove or skip any mandatory* field

Current behaviour

Since I accidentally closed my last ticket, because I am really bad with GitHub - here is my problem again - but this time a bit more structured and right away with a crash log.

My findings / theories summarized by an AI since I got this all a bit to cluttered.


Summary of the Bug:
The server is experiencing critical stability issues due to a Use-After-Free memory corruption bug. The bug is triggered during map/grid unload events (e.g., leaving a Battleground, switching characters). A debug build has confirmed a dangling pointer is being used during the map cleanup process, causing a fatal ACCESS_VIOLATION.

Symptoms:
The bug manifests differently depending on the build configuration:

Release Build: Intermittent BREAKPOINT crash in libmysql.dll after leaving a BG, or a World Thread hang crash when the server is left idle.

Debug Build: A hard crash with ACCESS_VIOLATION, preceded by heap assertions like _CrtIsValidHeapPointer and vector subscript out of range.

Steps to Reproduce:
The issue is intermittent and appears to be cumulative, requiring an invalid memory state to be reached.

Engage in activity that loads and then unloads map instances or grids.

Reliable trigger: Play and leave several Battlegrounds. The crash will eventually occur upon leaving one of the instances.

Other triggers: Switching between characters or logging out of the game.

The common, unifying factor for all crashes is a map/grid unloading event.

Root Cause Analysis:
A Debug build has definitively identified the root cause as a Use-After-Free memory error in the C++ code. The proof is as follows:

Dangling Pointer Confirmed: At the moment of the crash in a debug build, the RAX register contains the value 0xFEFEFEFEFEFEFEFE. This is the specific sentinel value used by the MSVC debug heap to mark freed memory, which is undeniable proof that a dangling pointer is being used.

Crash Location: The call stack consistently shows the crash occurs during the map cleanup process, within functions like MapInstanced::DestroyInstance or Map::UnloadGrid.

Immediate Trigger: The use of the dangling pointer leads to reading a garbage value from the freed memory. This garbage value is then used as an invalid index for an std::vector, causing a vector subscript out of range assertion which results in the final ACCESS_VIOLATION.

Two crash logs:
c6ab8cefae4d_worldserver.exe_[5-8_9-57-20].txt
c6ab8cefae4d_worldserver.exe_[5-8_10-4-45].txt

Expected behaviour

No crashes when joining / leaving BGs or by Bots despawning and unloading maps.

Crashlog

No response

Steps to reproduce the problem

a) Join and Leave a BG. Sometimes multiple times until it happens
or
b) Switch between characters

TrinityCore or AzerothCore

AzerothCore

Core rev. hash/commit

AzerothCore rev. c6ab8cefae4d 2025-08-03 15:38:01 +0700 (npcbots_3.3.5 branch) (Win64, Debug, Static) (worldserver-daemon)

Operating system

Win 11 Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions