I'm not familiar with the Xserver code but get regularly issues with tigervnc (a patched X server) getting stuck on exit and this prevents a new one from being started in the same display nr (manual intervention required to kill -9 the Xvnc process that is stuck).
After reporting and discussing the issue with the maintainers, I got informed that the root cause is in the X server, see :
As this is probably a heap corruption combined with a race condition, there is no way to systematically reproduce the effect.
If nothing else can be done, maybe you could advice if there are ways to avoid the free() calls on process exit (as they are completely useless, the kernel will reclaim this memory anyway).
-- GitLab Migration Automatic Message --
This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/534.