Fix backtraces on cancellation points

This commit is contained in:
Justine Tunney 2022-11-04 19:55:41 -07:00
parent 022536cab6
commit 0d7c265392
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
4 changed files with 22 additions and 13 deletions

View file

@ -34,8 +34,10 @@
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
extern const char systemfive_cancellable[] hidden;
extern const char systemfive_cancellable_end[] hidden;
int systemfive_cancel(void);
extern const char systemfive_cancellable[];
extern const char systemfive_cancellable_end[];
int _pthread_cancel_sys(void) {
struct PosixThread *pt;
@ -57,7 +59,7 @@ static void OnSigCancel(int sig, siginfo_t *si, void *ctx) {
if ((pt->flags & PT_ASYNC) ||
(systemfive_cancellable <= (char *)uc->uc_mcontext.rip &&
(char *)uc->uc_mcontext.rip < systemfive_cancellable_end)) {
uc->uc_mcontext.rip = (intptr_t)_pthread_cancel_sys;
uc->uc_mcontext.rip = (intptr_t)systemfive_cancel;
} else {
tkill(atomic_load_explicit(&tib->tib_tid, memory_order_relaxed), sig);
}