1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) f336a3eb6c: [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(-)
This commit is contained in:
nagachika 2021-09-11 13:59:43 +09:00
parent 8e4ed4ed00
commit 13f64b65e0
3 changed files with 6 additions and 3 deletions

View file

@ -557,10 +557,13 @@ static int rb_sigaltstack_size_value = 0;
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 */

View file

@ -12,7 +12,7 @@
# 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

View file

@ -136,7 +136,7 @@
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)