diff --git a/addr2line.c b/addr2line.c index b783e8e470..dc0892e308 100644 --- a/addr2line.c +++ b/addr2line.c @@ -296,9 +296,11 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di for (i = 1; i <= file; i++) { filename = p; if (!*p) { +#ifndef __APPLE__ /* Need to output binary file name? */ kprintf("Unexpected file number %d in %s at %tx\n", file, binary_filename, filenames - obj->mapped); +#endif return; } while (*p) p++; diff --git a/thread_pthread_mn.c b/thread_pthread_mn.c index b5efb90f28..cc0dae3b70 100644 --- a/thread_pthread_mn.c +++ b/thread_pthread_mn.c @@ -429,7 +429,12 @@ native_thread_check_and_create_shared(rb_vm_t *vm) } } -static COROUTINE +#ifdef __APPLE__ +# define co_start ruby_coroutine_start +#else +static +#endif +COROUTINE co_start(struct coroutine_context *from, struct coroutine_context *self) { #ifdef RUBY_ASAN_ENABLED diff --git a/vm_dump.c b/vm_dump.c index 99339fd9cc..7bfa7c1d7a 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -510,6 +510,15 @@ rb_vmdebug_thread_dump_state(FILE *errout, VALUE self) # include # include # 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