Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 83bdd21

Browse files
janvorlijkotas
authored andcommitted
Fix alternate stack cleanup on MUSL (#18685)
The MUSL implementation of sigaltstack checks that the ss.ss_size is larger or equal than the MINSIGSTKSZ even when the ss_flags is set to SS_DISABLE even though Linux man page for sigaltstack states that when this flag is set, all other ss fields are ignored. We were not setting the ss_size in this case and it was causing a memory leak for each thread that has terminated on MUSL based Linux distros like Alpine. Glibc implementation doesn't check the ss_size when the SS_DISABLE is set so the problem was really MUSL specific.
1 parent 1a34c72 commit 83bdd21

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/pal/src/exception/signal.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ Return :
199199
void FreeSignalAlternateStack()
200200
{
201201
stack_t ss, oss;
202+
// The man page for sigaltstack says that when the ss.ss_flags is set to SS_DISABLE,
203+
// all other ss fields are ignored. However, MUSL implementation checks that the
204+
// ss_size is >= MINSIGSTKSZ even in this case.
205+
ss.ss_size = MINSIGSTKSZ;
202206
ss.ss_flags = SS_DISABLE;
203207
int st = sigaltstack(&ss, &oss);
204208
if ((st == 0) && (oss.ss_flags != SS_DISABLE))

0 commit comments

Comments
 (0)