diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2018-06-28 23:39:51 +0200 |
---|---|---|
committer | Wes Haggard <Wes.Haggard@microsoft.com> | 2018-06-28 14:54:01 -0700 |
commit | c6e7fbc5516842945b9b375f7724438dece10627 (patch) | |
tree | 18284afe80b3d6b19b7464b89480ae97453c4d42 | |
parent | 105e2abe69f4768023e2483158d4d05d55f97982 (diff) | |
download | coreclr-c6e7fbc5516842945b9b375f7724438dece10627.tar.gz coreclr-c6e7fbc5516842945b9b375f7724438dece10627.tar.bz2 coreclr-c6e7fbc5516842945b9b375f7724438dece10627.zip |
Port to 2.1: Fix alternate stack cleanup on MUSL (#18687)
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.
-rw-r--r-- | src/pal/src/exception/signal.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp index 458e331698..7f2e5c5b3d 100644 --- a/src/pal/src/exception/signal.cpp +++ b/src/pal/src/exception/signal.cpp @@ -199,6 +199,10 @@ Return : void FreeSignalAlternateStack() { stack_t ss, oss; + // The man page for sigaltstack says that when the ss.ss_flags is set to SS_DISABLE, + // all other ss fields are ignored. However, MUSL implementation checks that the + // ss_size is >= MINSIGSTKSZ even in this case. + ss.ss_size = MINSIGSTKSZ; ss.ss_flags = SS_DISABLE; int st = sigaltstack(&ss, &oss); if ((st == 0) && (oss.ss_flags != SS_DISABLE)) |