Cleanup testsuite with ASAN

Bug #1734304 reported by GunChleoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Won't Fix
Undecided
GunChleoc

Bug Description

Since we now have easy ASAN compiling in the pipeline

https://code.launchpad.net/~widelands-dev/widelands/run-asan

I'm planning to go through the test suite until it passes.

This bug will be fixed with that as well:

https://bugs.launchpad.net/widelands/+bug/1734088

GunChleoc (gunchleoc)
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
description: updated
Revision history for this message
GunChleoc (gunchleoc) wrote :

All testsuite scenarios are producing the same memory leak:

=================================================================
==3752==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 288 byte(s) in 1 object(s) allocated from:
    #0 0x7f4c7d87f602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f4c7bfaf593 in glXGetFBConfigs (/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1+0x1a593)

Direct leak of 144 byte(s) in 1 object(s) allocated from:
    #0 0x7f4c7d87f79a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
    #1 0x7f4c7bd3fb38 (/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xbdb38)

SUMMARY: AddressSanitizer: 432 byte(s) leaked in 2 allocation(s).

Revision history for this message
SirVer (sirver) wrote :

This one seems to be either in libMesa or in SDL. Maybe it is also something we are doing wrong with cleaning up, hard to say.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes, I think so too. I tried to find a way to exclude them from the LeakSanitizer for now, but all my attempts were ignored. I'll concentrate on the errors in our own code first and then try to find out where glXGetFBConfigs is called from.

GunChleoc (gunchleoc)
tags: added: asan
Revision history for this message
GunChleoc (gunchleoc) wrote :

tl;dr: #1 is not our bug.

I have done some digging and came up with this:

https://stackoverflow.com/questions/10065849/memory-leak-using-glxcreatecontext

> Checking the docs, on glXChooseFBConfig (https://www.opengl.org/sdk/docs/man2/xhtml/glXChooseFBConfig.xml) the return value is expected to be freed with XFree called on it.

==============================

WIDELANDS:

We trigger this function once from Graphic::initialize and store the SDL_GLContext in gl_context_.

On shutdown, in Graphic::~Graphic(), we call:

    SDL_GL_DeleteContext(gl_context_);

So, we are doing everything right.

==============================

SDL2:

I found this in the SDL2 source code for it:

    void X11_GL_DeleteContext(_THIS, SDL_GLContext context)
    {
        Display *display = ((SDL_VideoData *) _this->driverdata)->display;
        GLXContext glx_context = (GLXContext) context;

        if (!_this->gl_data) {
            return;
        }
        _this->gl_data->glXDestroyContext(display, glx_context);
        X11_XSync(display, False);
    }

glXDestroyContext is documented here:

https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXDestroyContext.xml

No idea if that calls XFree or not - I guess we have to dig into libmesa next to see if we can file a bug with them.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Could somebody with Valgrind powers check if WaresWorkersMap in the attached branch is indeed leaking?

I'm stumped right now, it's a unique_ptr of a map that contains only basic data types.

Revision history for this message
GunChleoc (gunchleoc) wrote :

P.S. the test I'm running for #5 is:

./widelands --language=en --scenario=test/maps/lua_testsuite.wmf --datadir_for_testing=.

GunChleoc (gunchleoc)
Changed in widelands:
milestone: build20-rc1 → build21-rc1
Revision history for this message
GunChleoc (gunchleoc) wrote :
Changed in widelands:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.