Stable6 backport of #8557