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-build-images!672 (merged)) in 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

Checklist

See Definition of done.

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

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened: gitlab-org/build/CNG!1419 (merged)
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Stan Hu

Merge request reports