mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-03-30 02:42:35 +02:00
Ruby tries to grab the size of main thread's stack with pthread_getattr_np() and other pthread_*_np friends, however as indicated by the _np suffix, the behavior when pthread_getattr_np() is called on main thread isn't the consistent across platforms. On glibc, pthread_getattr_np() will try to parse /proc/self/maps to determine the the already allocated stack's size, and subtracts the RLIMIT_STACK with the size, while musl tries to mremap() pages below auxvectors to change their size from one page to two pages, and if the space is allocated for stack, the mremap() call will fail. However musl only takes the already allocated stack into account, and don't care about RLIMIT_STACK settings. Since Linux allocates stack lazily, this will cause the stack size returned by pthread_getattr_np() is smaller than the maximum stack size. This underestimation of the maximum stack size will cause the active stack overflow checking logic of Ruby to consider the stack has been used out, and throws false SystemStackError, fails recursion cases in test_insn.rb. As the underestimation has been fixed by fix-get_main_stack.patch, we don't need to work around the test failure anymore. Reference: - https://github.com/eweOS/packages/pull/6633 - https://bugs.ruby-lang.org/issues/14387 - 818d6e0c2336b8c682c96e933acbf8a1d6e7a343