backport r43265 from ruby/ruby