See https://bugs.ruby-lang.org/issues/16136. This patch is on Ruby trunk, but hasn't been backported (yet?).