XChangeProperty needs data passed as "long" even if it's 32 bit
I was debugging a crash caused by gajim which turned out to be a wrong X11 API use by gtk+.
In gdkdisplay-x11.c and gdkwindow-x11.c there are calls to the function XChangeProperty() with a pid as a parameter that is of type pid_t.
pid_t is 32 bit, yet if you pass a 32 bit value to XChangeProperty it has to be long, which is 64 bit on 64 bit systems. This is unexpected and probably a case of bad API design, but it's written in the docs [1] of XChangeProperty: "If the specified format is 32, the property data must be a long array."
The crash is thus caused by an overread: libX11 tries to access a 32 bit variable as 64 bit.
I have also asked xorg whether they'd consider changing the API to be less surprising [2], but for now the correct usage is to use long instead of pid_t. I'm attaching a patch for gtk+ 3.24.1.gtk+-3.24.1-fix-xchangeproperty-pid-long.diff
[1] https://tronche.com/gui/x/xlib/window-information/XChangeProperty.html
[2] https://lists.x.org/archives/xorg-devel/2019-January/057849.html