Ruby Ruby 4.0.4 修复了一个性能问题

Rei · May 15, 2026 · Last by geekontheway replied at May 22, 2026 · 575 hits

我的网站在升级 Ruby 4.0 的时候遇到了性能问题,具体表现为,如果网站有大量的 html 内容需要 sanitize,那么在执行 2、3 次后网站就会卡死,cpu 100%。

排查了很久自己的代码和依赖的 gem 也没解决,不得已只好回退 3.4。

问题原因在这里:https://bugs.ruby-lang.org/issues/21856

最近发布的 Ruby 4.0.4 已经修复了这个问题,我升级了网站不再出现卡死。有需要的可以升级测一测。

4.0.5 在 5.20 出了,这个版本日期好……

Ruby 4.0.5 fixed a critical use-after-free race condition in the getaddrinfo timeout handler. CVE-2026-46727

You need to Sign in before reply, if you don't have an account, please Sign up first.