mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
This fixes seg faults seen after tests finish running. This pulls in an upstream fix for Nokogiri/libxml2: https://github.com/ruby/ruby/pull/7663. These patches can be dropped once Nokogiri v1.15 is available and `NOKOGIRI_LIBXML_MEMORY_MANAGEMENT=default` is set in CI. See https://gitlab.com/gitlab-org/gitlab/-/issues/390313#note_1342807685 for more details.
23 lines
679 B
Diff
23 lines
679 B
Diff
diff --git a/gc.c b/gc.c
|
|
index 030a4627bd..1c96f6401f 100644
|
|
--- a/gc.c
|
|
+++ b/gc.c
|
|
@@ -11763,8 +11763,16 @@ ruby_xrealloc2_body(void *ptr, size_t n, size_t size)
|
|
void
|
|
ruby_sized_xfree(void *x, size_t size)
|
|
{
|
|
- if (x) {
|
|
- objspace_xfree(&rb_objspace, x, size);
|
|
+ if (LIKELY(x)) {
|
|
+ /* It's possible for a C extension's pthread destructor function set by pthread_key_create
|
|
+ * to be called after ruby_vm_destruct and attempt to free memory. Fall back to mimfree in
|
|
+ * that case. */
|
|
+ if (LIKELY(GET_VM())) {
|
|
+ objspace_xfree(&rb_objspace, x, size);
|
|
+ }
|
|
+ else {
|
|
+ ruby_mimfree(x);
|
|
+ }
|
|
}
|
|
}
|
|
|