axmol: AddressSanitizer find bugs in axmol engine

  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 https://github.com/axmolengine/axmol/issues/1211

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (18 by maintainers)

Most upvoted comments

const V3F_C4B_T2F_Quad& getQuad() const { is best