[Mesa-users] Crash in GDBM when SDL2 is cleaned-up using atexit

Sylvain Becker sylvain.becker at gmail.com
Tue Apr 2 06:52:47 UTC 2019


On Mon, 25 Mar 2019 at 09:13, Pekka Paalanen <ppaalanen at gmail.com> wrote:

> On Sat, 23 Mar 2019 14:28:16 +0100
> Sylvain Becker <sylvain.becker at gmail.com> wrote:
>
> > Hi,
> >
> > There is a crash when an SDL2 game (Exult), using KMS-DRM back-end,
> > terminates.
> > It appears in GBM (gbm_device_destroy()), there migh be also invalid
> access
> > in egl datas.
> >
> > SDL2 issue can be found at
> https://bugzilla.libsdl.org/show_bug.cgi?id=4530
> > (with a very small test case)
> > Exult game at https://github.com/exult
> >
> > It occurs because:
> > - Mesa uses atexit()
> > - Exult game also chooses atexit() to clean up SDL2 internals. (e.g
> > atexit(SDL_Quit))
> >
> > Depending on how atexit callbacks are sorted/registered :
> > - Mesa cleans up first GBM with an atexit().
> > - If SDL2 tries to clean up things once again and it crashes.
> >
> > This is reported for SDL2, but any layer using atexit() and GBM could
> > reproduce the same crash.
> >
> > There are surely several ways to avoid this, but I wonder what you would
> > advice to solve this.
>
> Hi,
>
> my personal opinion is that the use of atexit() is almost always a bad
> idea, both for the app and Mesa. I'm not a Mesa developer and I don't
> know why Mesa wanted to use it, but I can imagine it is a compromise
> between bad choices - I'm sure they know the caveats of atexit(). Your
> problem is a good example of why atexit() should not be used at all.
>
> It should be much easier to make the game not use atexit(), because it
> controls the application main event loop, than Mesa which has no
> knowledge of any main loop and therefore cannot reasonably hook up to
> its exit sequence on its own.
>
>
> Thanks,
> pq
>

Hi,
Thanks for your answer. Indeed not using atexit() is the easiest way.
I wish I had an API to detect the library has been terminated.

Thanks,
Sylvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-users/attachments/20190402/5895e164/attachment.html>


More information about the mesa-users mailing list