Improve crash signal reporting on Windows

This change fixes a bug where exiting a crash signal handler on Windows
after adding the signal to uc_sigmask, but not correcting the CPU state
would cause the signal handler to loop infinitely, causing process hang

Another issue is that very tiny programs, that don't link posix signals
would not have their SIGILL / SIGSEGV / etc. status reported to Cosmo's
bash shell when terminating on crash. That's fixed by a tiny handler in
WinMain() that knows how to map WIN32 crash codes to the POSIX flavors.
This commit is contained in:
Justine Tunney 2024-05-30 13:42:59 -07:00
parent 500a47bc2f
commit cd672e251f
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
7 changed files with 169 additions and 88 deletions

View file

@ -512,6 +512,8 @@ syscon compat SA_ONESHOT 0x80000000 0x80000000 4 4 4 4 4 0x800000
# The New Technology NT is polyfilled as Linux.
# Unsupported values are encoded as 0x80000000.
#
# NOTE: Some of these Windows constants are duplicated in sigcrashsig.c
#
# group name GNU/Systemd GNU/Systemd (Aarch64) XNU's Not UNIX! MacOS (Arm64) FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon sicode SI_USER 0 0 0x010001 0x010001 0x010001 0 0 0 # sent by kill(2); openbsd defines si_code<=0 as originating from user
syscon sicode SI_QUEUE -1 -1 0x010002 0x010002 0x010002 -2 -1 -1 # sent by sigqueue(2)