Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use libuv thread instead of std::thread to avoid musl issues #52149

Merged
merged 5 commits into from
Nov 14, 2023

Conversation

@giordano giordano added building Build system, or building Julia or its dependencies compiler:musl Support for musl linked binaries on linux instead of glibc labels Nov 13, 2023
Make.inc Outdated
@@ -1357,6 +1357,11 @@ endif
JLIBLDFLAGS += -Wl,-z,noexecstack
endif

#musl has a really small default stack
Copy link
Contributor

Choose a reason for hiding this comment

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

Strictly speaking I think it's only Alpine Linux, but that probably covers vast majority of musl-based systems (and this option should hopefully be good in all other cases)

Copy link
Member Author

Choose a reason for hiding this comment

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

https://git.musl-libc.org/cgit/musl/commit/?id=7b3348a98c139b4 Seems to a musl thing. Well the flag is a linker thing but it seems musl respects it since 2018

@PallHaraldsson
Copy link
Contributor

I suppose you have this all figured out and this changes "PT_GNU_STACK program header", in the ELF format.

I was looking into what controls the stack size on different platforms, and that's it on also Musl, and thus seemingly all platforms, except Windows (and likely macOS):

https://wiki.musl-libc.org/functional-differences-from-glibc.html

Since 1.1.21, musl supports increasing the default thread stack size via the PT_GNU_STACK program header, which can be set at link time via -Wl,-z,stack-size=N.

https://stackoverflow.com/questions/61909762/when-setting-execution-bit-on-pt-gnu-stack-program-header-why-do-all-segments-o

@vtjnash
Copy link
Member

vtjnash commented Nov 13, 2023

I thought we avoided using this code path in all cases, since libuv is already aware that musl's defaults are wrong (it usually will result in memory corruption if receiving any signals on any platforms since it is smaller than even a single a page)

@gbaraldi gbaraldi changed the title Increase stack size when building in musl Use libuv thread instead of std::thread to avoid musl issues Nov 13, 2023
Make.inc Outdated Show resolved Hide resolved
Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
@staticfloat staticfloat merged commit c1f67f8 into master Nov 14, 2023
7 checks passed
@staticfloat staticfloat deleted the gb/musl-stack branch November 14, 2023 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies compiler:musl Support for musl linked binaries on linux instead of glibc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants