1 diff --git a/pthread_stop_world.c b/pthread_stop_world.c
2 index 2b45489..0e6d8ef 100644
3 --- a/pthread_stop_world.c
4 +++ b/pthread_stop_world.c
5 @@ -776,6 +776,8 @@ STATIC void GC_restart_handler(int sig)
6 /* world is stopped. Should not fail if it isn't. */
7 GC_INNER void GC_push_all_stacks(void)
10 + pthread_attr_t pattr;
11 GC_bool found_me = FALSE;
14 @@ -868,6 +870,40 @@ GC_INNER void GC_push_all_stacks(void)
15 hi = p->altstack + p->altstack_size;
17 /* FIXME: Need to scan the normal stack too, but how ? */
19 + #ifdef HAVE_PTHREAD_ATTR_GET_NP
20 + if (pthread_attr_init(&pattr) != 0) {
21 + ABORT("GC_push_all_stacks: pthread_attr_init failed!");
23 + if (pthread_attr_get_np(p->id, &pattr) != 0) {
24 + ABORT("GC_push_all_stacks: pthread_attr_get_np failed!");
27 + if (pthread_getattr_np(p->id, &pattr)) {
28 + ABORT("GC_push_all_stacks: pthread_getattr_np failed!");
31 + if (pthread_attr_getstacksize(&pattr, &stack_limit)) {
32 + ABORT("GC_push_all_stacks: pthread_attr_getstacksize failed!");
34 + if (pthread_attr_destroy(&pattr)) {
35 + ABORT("GC_push_all_stacks: pthread_attr_destroy failed!");
37 + // When a thread goes into a coroutine, we lose its original sp until
38 + // control flow returns to the thread.
39 + // While in the coroutine, the sp points outside the thread stack,
40 + // so we can detect this and push the entire thread stack instead,
41 + // as an approximation.
42 + // We assume that the coroutine has similarly added its entire stack.
43 + // This could be made accurate by cooperating with the application
44 + // via new functions and/or callbacks.
45 + #ifndef STACK_GROWS_UP
46 + if (lo >= hi || lo < hi - stack_limit) { // sp outside stack
47 + lo = hi - stack_limit;
50 + #error "STACK_GROWS_UP not supported in boost_coroutine2 (as of june 2021), so we don't support it in Nix."
53 # ifdef STACKPTR_CORRECTOR_AVAILABLE
54 if (GC_sp_corrector != 0)