Skip to content

Backport Ruby upstream patch to fix seg faults in libxml2/Nokogiri

Stan Hu requested to merge sh-fix-nokogiri-segfaults into master

What does this MR do?

As https://github.com/sparklemotion/nokogiri/issues/2785#issuecomment-1496277453 explains, there is a bug in the Ruby interpreter (https://bugs.ruby-lang.org/issues/19580) that has been fixed upstream (https://github.com/ruby/ruby/pull/7663) that causes a seg fault during shutdown with libxml2/Nokogiri.

We patched the Ruby interpreter in CI to work around the problem (gitlab-org/gitlab-build-images!672 (merged)) in gitlab-org/gitlab#390313 (closed), but it appears the seg faults have appeared in production now. On GitLab.com, this week we have seen more than 20 cases with the error:

[BUG] Segmentation fault at 0x0000000000000440

We could also work around this problem by setting NOKOGIRI_LIBXML_MEMORY_MANAGEMENT=default, but this may cause unexpected memory growth since Ruby no longer manages the memory (see https://github.com/sparklemotion/nokogiri/pull/2843/files).

Let's just fix the interpreter since we'd also need to make sure that environment variable is set in any environment that uses Nokogiri (including Rake tasks).

Related issues

Omnibus MR: gitlab-org/omnibus-gitlab!6938 (merged)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion

Required

  • Merge Request Title, and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Integration tests added to GitLab QA
  • The impact any change in container size has should be evaluated
Edited by Stan Hu

Merge request reports