This comment has been minimized.

Problem is the way ruby calculate stacksize for main thread and what musl reports as available via the non-portable pthread_getattr_np() call. Musl will give you the memory size that is guaranteed by kernel while glibc gives you the number you will "hopefully" get.

This comment has been minimized.

No, that is sort of the problem. The stack size is big enough, (sort of) but it the way musl reports it. A possible workaround would be to implement ruby's own pthread_getattr_np() and use that when current thread (pthread_self()) is the same as main thread. (syscall(SYS_gettid) == getpid()) and fallback to libc's phread_getattr_np() when its not main thread.

The code there is already messy as it is and "fixing" it or adding a workaround in ruby will make it worse 😞 What ruby tries to do here is somewhat controversial in the first place. Kernel could still deny ruby the stack memory it believes it has available.

It may look like __APPLE__ systems have similar problem? I need to investigate why they do the check if (pthread_equal(th->thread_id, native_main_thread.id)). Thats the logic we need: if current thread is main thread, then use getrlimit(RLIMIT_STACK)

The Alpine docker image has a smaller stack size which results in
SystemStackError from being raised in situations where you have a
deep call stack.
This error was being raised in this repository when running
Capybara tests involving rack-test and SASS compilation.
Switching to Debian should fix this as it doesn't have this stack
size problem.
See more information on this issue here:
docker-library/ruby#196
When switching to Debian, we're pulling in the yarn binary via
their apt repository as default Debian doesn't provide an npm
from which we could use `npm install -g yarn`.
An additional problem is that the default Debian install doesn't
support apt repositories on HTTPS urls. We first have to install
the `apt-transport-https` before being able to use the yarn repo.

This comment has been minimized.

When will this change get pushed to Docker Hub? I see here that the images on Docker Hub are still built using this commit from BEFORE the PR merge. The last time the official images were built was 11 days ago.