Re: Crash in GDBM when SDL2 is cleaned-up using atexit

Pekka Paalanen <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <[email protected]>
On Sat, 23 Mar 2019 14:28:16 +0100
Sylvain Becker <[email protected]> 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

_______________________________________________
mesa-users mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEJQjwWQChkWOYOIONI1/ltBGqqqcFAlyYjbUACgkQI1/ltBGq
qqdq4A/9HSJWZuqbC2KL0MlvRMHHrCu3kKWhqqu/8uuM1PF58lRbjmk+F3wUccBi
9e/kjkCHdLSXZhq1D8oimNrPfEgS0pkvtmLCTXN3Utpptd+P0vNM1+IiuZNPhlht
Co549M4xD1KHN3fxwUkkCFn12LPt+K66BGp840q5fPXNZlYHRQsRNw/F68rn2VLD
b9gG3zm3L/YFnD/K3KCCm8sCAml12TRjEaGauFBu87Kjn+spNdXpTFi4yOQHB0yg
m2PHkDEc191Aos2Sxs+uc2Xo9uMmorO0SG9dyUsK4VlcFlXx1meiFS91SeRrcxHH
cbQmHbbSYBNBsm2StdderiyP2qxeYpceYE3xqiZwem0ms+VgOTckQXq+9hATPI3o
DClaS4Hcqzwod5+wWTcwmIy9so7e+cGPgvC24u+3QpSpqLWAUZOrJjKlJxwooYBn
buiJWuurldPi6bDdBcpL2SJn5y3JorwxnbMf4wOp9EKkJhE6kF+jiLj+VXz3bYjf
3ppJghrHq67mriBAdny2wrpqTvctSAEn80awyNi/jcp/7PzsFk54ZhuALq9lIATI
psstRp1t37kbFPUneemmS+IpY3xUzByuWgg6tw2/ry2kVyJXGWgKJPyGrobKZa6u
1nRivP5coYoNuShJf2Q0taKLAWFLCN2/xV4Qi9XDDFogNQzgTSw=
=4fQz
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.