mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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]
This commit is contained in:
parent
13dd07e397
commit
f336a3eb6c
2 changed files with 5 additions and 2 deletions
5
signal.c
5
signal.c
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue