Skip to content
Snippets Groups Projects
Commit 97e65445 authored by Balasankar 'Balu' C's avatar Balasankar 'Balu' C
Browse files

Merge branch 'pjphillips-master-patch-13820' into 'master'

parents 43d9ecfa 1a406d88
No related branches found
No related tags found
3 merge requests!128heptapod#1534: making 1.5 the oldstable,!125heptapod#1494: make 1.5 the new stable,!123Omnibus GitLab for upstream 16.10
diff --git a/gc.c b/gc.c
index 54400e4f6b..96d43ac8ac 100644
--- a/gc.c
+++ b/gc.c
@@ -12614,8 +12614,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);
+ }
}
}
......@@ -68,7 +68,7 @@
version('3.0.6') { source sha256: '6e6cbd490030d7910c0ff20edefab4294dfcd1046f0f8f47f78b597987ac683e' }
version('3.1.4') { source sha256: 'a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6' }
version('3.2.2') { source sha256: '96c57558871a6748de5bc9f274e93f4b5aad06cd8f37befa0e8d94e7b8a423bc' }
version('3.2.3') { source sha256: 'af7f1757d9ddb630345988139211f1fd570ff5ba830def1cc7c468ae9b65c9ba' }
source url: "https://cache.ruby-lang.org/pub/ruby/#{version.match(/^(\d+\.\d+)/)[0]}/ruby-#{version}.tar.gz"
......@@ -109,8 +109,13 @@
# 1. Enable custom patch created by ayufan that allows to count memory allocations
# per-thread. This is asked to be upstreamed as part of https://github.com/ruby/ruby/pull/3978
# 2. Backport Ruby upstream patch to fix seg faults in libxml2/Nokogiri: https://bugs.ruby-lang.org/issues/19580
# This has been merged for Ruby 3.3 but not yet backported: https://github.com/ruby/ruby/pull/7663
patches = %w[thread-memory-allocations fix-ruby-xfree-for-libxml2]
# This has been merged for Ruby 3.2.3 but not yet backported: https://github.com/ruby/ruby/pull/7663
patches = if version.satisfies?('>= 3.2.3')
%w[thread-memory-allocations]
else
%w[thread-memory-allocations fix-ruby-xfree-for-libxml2]
end
ruby_version = Gem::Version.new(version).canonical_segments[0..1].join('.')
patches.each do |patch_name|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment