[Bug #21150] macOS: Temporary workaround at unwinding coroutine

On arm64 macOS, libunwind (both of system library and homebrew
llvm-18) seems not to handle our coroutine switching code.
This commit is contained in:
Nobuyoshi Nakada 2025-02-21 17:53:16 +09:00
parent d97884a58b
commit 1bc57b5e0e
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465
Notes: git 2025-02-21 10:17:54 +00:00
3 changed files with 20 additions and 1 deletions

View file

@ -510,6 +510,15 @@ rb_vmdebug_thread_dump_state(FILE *errout, VALUE self)
# include <libunwind.h>
# include <sys/mman.h>
# undef backtrace
static bool
is_coroutine_start(unw_word_t ip)
{
struct coroutine_context;
extern void ruby_coroutine_start(struct coroutine_context *, struct coroutine_context *);
return ((void *)(ip) == (void *)ruby_coroutine_start);
}
int
backtrace(void **trace, int size)
{
@ -617,6 +626,9 @@ darwin_sigtramp:
// I wish I could use "ptrauth_strip()" but I get an error:
// "this target does not support pointer authentication"
trace[n++] = (void *)(ip & 0x7fffffffffffull);
// Apple's libunwind can't handle our coroutine switching code
if (is_coroutine_start(ip)) break;
}
return n;
# endif