Thanks a lot for the detailed analysis and trial patch. I have already created an upstream issue [1] for this bug some weeks ago but my proposed patch isn't really working and just a really poor shot in the dark. I am adding the URL to the upstream bug report and will also give your patch a try on the Debian sparc64 porterbox.
Thanks for that! I can see that upstream has already identified the issue, but it seems like they're unsure about how to address it properly. By the way: I do intend to test my patch, but building gtk4 takes a whole day on my Ultra 10.