This should fix #40706. @nioncode confirms that it works also for him. Not backported. @ttuegel do you want to rearrange the patches before any backport?