Skip to content

AsciiString memory corruption #1394

Description

@Stubbjax

Prerequisites

  • I have searched for similar issues and confirmed this is not a duplicate

Game Version

  • Command & Conquer Generals
  • Command & Conquer Generals: Zero Hour
  • Other (please specify below)

Bug Description

Playing the game for a while (especially on maps with lots of miscellaneous audio sources, such as Alpine Assault) will eventually lead to an m_refCount assertion failure in the AsciiString class. The issue can be reproduced faster if there is lots of looping audio playing, like ComancheAmbientLoop.

Image

The source of the issue appears to be the val local static variable in GetRegistryLanguage becoming corrupted. As val is only assigned once early on in the program's lifecycle, its value becoming garbage is likely indicative of a memory overflow somewhere else in the program. The fact that the same assertion occurs twice at once might also be a clue (thread safety?).

Image

The issue is observed with 100% certainty in both clean 32-bit Debug and 32-bit Release builds (the game will just silently freeze and close in the release build) as of the latest commit 94fe5e5 at the time of writing. The issue does not seem to occur in the retail version of the game.

Reproduction Steps

  1. Start a new Skirmish game on Alpine Assault as any USA
  2. Hit ALT+F to enter instant-build mode
  3. Build many Comanches (e.g. 150+) and leave them on-screen
  4. Wait between 1 - 5 in-game minutes
  5. Observe the eventual assertion error and the audio getting stuck
  6. For optional fun, ignore the assertion(s), select Restart Game and observe the game's UI textures going haywire

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is not working right, typically is user facingCrashThis is a crash, very badCriticalSeverity: Minor < Major < Critical < BlockerThisProjectThe issue was introduced by this project, or this task is specific to this project

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions