Avoid crash looping on AARCH64

This commit is contained in:
Justine Tunney 2024-05-08 01:00:58 -07:00
parent 8f18b3ad65
commit 952b9009e8
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3 changed files with 10 additions and 11 deletions

View file

@ -78,17 +78,14 @@ int feenableexcept(int excepts) {
#elif defined(__aarch64__) #elif defined(__aarch64__)
unsigned fpcr; unsigned fpcr = __builtin_aarch64_get_fpcr();
unsigned fpcr2; unsigned want = excepts << 8;
unsigned updated_fpcr; unsigned fpcr2 = fpcr | want;
fpcr = __builtin_aarch64_get_fpcr();
fpcr2 = fpcr | (excepts << 8);
if (fpcr != fpcr2) { if (fpcr != fpcr2) {
__builtin_aarch64_set_fpcr(fpcr2); __builtin_aarch64_set_fpcr(fpcr2);
// floating point exception trapping is optional in aarch64 fpcr2 = __builtin_aarch64_get_fpsr();
updated_fpcr = __builtin_aarch64_get_fpsr(); if ((fpcr2 & want) != want)
if (fpcr2 & ~updated_fpcr) return -1; // not supported by cpu
return -1;
} }
return (fpcr >> 8) & FE_ALL_EXCEPT; return (fpcr >> 8) & FE_ALL_EXCEPT;

View file

@ -394,6 +394,8 @@ relegated void __oncrash(int sig, struct siginfo *si, void *arg) {
BLOCK_CANCELATION; BLOCK_CANCELATION;
SpinLock(&lock); SpinLock(&lock);
__oncrash_impl(sig, si, arg); __oncrash_impl(sig, si, arg);
if (sig != SIGQUIT && sig != SIGTRAP)
_exit(1);
SpinUnlock(&lock); SpinUnlock(&lock);
ALLOW_CANCELATION; ALLOW_CANCELATION;
} }

View file

@ -68,13 +68,13 @@ static unsigned long ParseMask(const char *str) {
* *
* __get_tls() * __get_tls()
* *
* %fs Linux/BSDs * %fs OpenBSD/NetBSD
* _Thread_local * _Thread_local
* *
* pad .tdata .tbss tib * pad .tdata .tbss tib
* *
* *
* Windows/Mac %gs * Linux/FreeBSD/Windows/Mac %gs
* *
* Here's the TLS memory layout on aarch64: * Here's the TLS memory layout on aarch64:
* *