ruby-changes:67923
From: nagachika <ko1@a...>
Date: Sat, 11 Sep 2021 14:18:44 +0900 (JST)
Subject: [ruby-changes:67923] 13f64b65e0 (ruby_3_0): merge revision(s) f336a3eb6c76890f3d8f878725b3d328c8fdcf33: [Backport #18126]
https://git.ruby-lang.org/ruby.git/commit/?id=13f64b65e0 From 13f64b65e0476c2fe416a29274fcc91e3c0cf5d3 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 11 Sep 2021 13:59:43 +0900 Subject: merge revision(s) f336a3eb6c76890f3d8f878725b3d328c8fdcf33: [Backport #18126] Use free instead of xfree to free altstack The altstack memory of a thread may be free'ed even after the VM is destructed. After that, GC is no longer available, so calling xfree may lead to a segfault. This changeset uses the bare free function to free the altstack memory instead of xfree. [Bug #18126] --- signal.c | 5 ++++- vm_core.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) --- signal.c | 5 ++++- version.h | 2 +- vm_core.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/signal.c b/signal.c index 6eea6aa..c13bc19 100644 --- a/signal.c +++ b/signal.c @@ -557,10 +557,13 @@ static int rb_sigaltstack_size_value = 0; https://github.com/ruby/ruby/blob/trunk/signal.c#L557 void * rb_allocate_sigaltstack(void) { + void *altstack; if (!rb_sigaltstack_size_value) { rb_sigaltstack_size_value = rb_sigaltstack_size(); } - return xmalloc(rb_sigaltstack_size_value); + altstack = malloc(rb_sigaltstack_size_value); + if (!altstack) rb_memerror(); + return altstack; } /* alternate stack for SIGSEGV */ diff --git a/version.h b/version.h index 687a8ef..ea49bd2 100644 --- a/version.h +++ b/version.h @@ -12,7 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 131 +#define RUBY_PATCHLEVEL 132 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 9 diff --git a/vm_core.h b/vm_core.h index a7644eb..edf6da1 100644 --- a/vm_core.h +++ b/vm_core.h @@ -136,7 +136,7 @@ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L136 void *rb_allocate_sigaltstack(void); void *rb_register_sigaltstack(void *); # define RB_ALTSTACK_INIT(var, altstack) var = rb_register_sigaltstack(altstack) -# define RB_ALTSTACK_FREE(var) xfree(var) +# define RB_ALTSTACK_FREE(var) free(var) # define RB_ALTSTACK(var) var #else /* noop */ # define RB_ALTSTACK_INIT(var, altstack) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/