summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-09-06 14:22:24 +0900
committerYusuke Endoh <mame@ruby-lang.org>2021-09-06 14:22:24 +0900
commitf336a3eb6c76890f3d8f878725b3d328c8fdcf33 (patch)
treed1478fa271a2e6713be94609fda1bfab644a43cc /signal.c
parent13dd07e3972fb41c8c834a46e29d34976f478fbc (diff)
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]
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/signal.c b/signal.c
index 764031e78a..4ca52b2ee6 100644
--- a/signal.c
+++ b/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 */