backport of #5062 to 71x