The only way to have G_IO_ERROR_CANCELLED in the write callback goes through having the array of pending writers already cleared. It should not access the invalid AsyncWriteData and StoredSelection in that case.
wayland-scanner private-code