Skip to content

AddressSanitizer find bugs in axmol engine #1257

@crazyhappygame

Description

@crazyhappygame
  • axmol version: 4e664e6
  • devices test on: Windows 10
  • developing environments
    • NDK version: r19c
    • Xcode version: 12.4
    • Visual Studio:
      • VS version: 2022 (17.6.3)
      • MSVC version: 1929, 1934
      • Windows SDK version: 10.0.22621.0
    • cmake version: 3.25.2
      Steps to Reproduce:
      Windows, Visual studio 2022
  1. Enable adress sanitizer for VS
    https://learn.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-170
    by adding on the top of to CMakeLists.txt
add_compile_options(/fsanitize=address)
  1. build and start cpp-test
  2. Press "Start AutoTest"
  3. After some time application crashed with

image

Sample errors:

  1. ActionsProgressTests
    Address Sanitizer Error: Use of out-of-scope stack memory
void ProgressTimer::updateColor()
{
    if (!_sprite)
        return;

    if (!_vertexData.empty())
    {
        const Color4B& sc = _sprite->getQuad().tl.colors;
        for (int i = 0; i < _vertexData.size(); ++i)
        {
            _vertexData[i].colors = sc;
        }
    }
}
  1. TextureCacheUnbindTest
    Address Sanitizer Error: Use of deallocated memory
        // release the asyncStruct
        delete asyncStruct;
        --_asyncRefCount;

Comments:
This kind of problems means that we are in undefined behavior zone and can not reason about program correctness.
This kind of issue could result in the problems seen in #1211

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions