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

Fix alternate stack cleanup on MUSL #18685

Merged
merged 1 commit into from
Jun 28, 2018

Conversation

janvorli
Copy link
Member

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.

@janvorli janvorli added os-linux Linux OS (any supported distro) area-PAL Servicing-consider Issue for next servicing release review labels Jun 28, 2018
@janvorli janvorli added this to the 2.1.x milestone Jun 28, 2018
@janvorli janvorli self-assigned this Jun 28, 2018
@janvorli janvorli requested a review from jkotas June 28, 2018 09:32
@@ -199,6 +199,7 @@ Return :
void FreeSignalAlternateStack()
{
stack_t ss, oss;
ss.ss_size = MINSIGSTKSZ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment that this field is not actually ignored for SS_DISABLE on MUSL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird - I have added that comment, I must have forgotten to push that change.

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.
@janvorli janvorli force-pushed the fix-musl-sigaltstack-issue branch from a325aa8 to 76ce225 Compare June 28, 2018 09:53
@jkotas jkotas merged commit 83bdd21 into dotnet:master Jun 28, 2018
@danmoseley danmoseley removed the Servicing-consider Issue for next servicing release review label Aug 17, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
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.

Commit migrated from dotnet/coreclr@83bdd21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-PAL os-linux Linux OS (any supported distro)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants