Skip to content

Commit

Permalink
thread_pthread: Grow main_stack if required (fixes tests on HPPA)
Browse files Browse the repository at this point in the history
On HPPA, test_insns.rb fails (along with various Ruby gems) with
'stack level too deep (SystemStackError)'. This turns out to be because HPPA
defaults to a small(er) stack.

With this change, Ruby's test suite passes on HPPA.

Thanks to both Dave and Helge for the investigation and coming up with the
patch.

Bug: https://bugs.gentoo.org/701494
Bug: https://bugs.debian.org/881773
Bug: https://bugs.debian.org/881772 (for PPC64)
Bug: rack/rack#1640
Thanks-to: John David Anglin <dave.anglin@bell.net>
Thanks-to: Helge Deller <deller@gmx.de>
  • Loading branch information
thesamesam committed Apr 7, 2023
1 parent 250e97c commit af72430
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions thread_pthread.c
Expand Up @@ -777,8 +777,18 @@ size_t pthread_get_stacksize_np(pthread_t);
# define MAINSTACKADDR_AVAILABLE 0
# endif
#endif
#if MAINSTACKADDR_AVAILABLE && !defined(get_main_stack)
# define get_main_stack(addr, size) get_stack(addr, size)
#if MAINSTACKADDR_AVAILABLE
static int get_stack(void **, size_t *);
static int
get_main_stack(void **addr, size_t *size)
{
get_stack(addr, size);

/* On some architectures, the inital stack size may be too small, but fortunately,
it's growable. Bump it up to the minimum needed if it is too small. */
if (*size < RUBY_VM_THREAD_VM_STACK_SIZE)
*size = RUBY_VM_THREAD_VM_STACK_SIZE;
}
#endif

#ifdef STACKADDR_AVAILABLE
Expand Down

0 comments on commit af72430

Please sign in to comment.