Add better fix for Windows fork+strace TLS crashes

This commit is contained in:
Justine Tunney 2022-10-02 07:46:34 -07:00
parent ad97775370
commit 6c60793f3a
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -87,19 +87,20 @@ static inline textwindows ssize_t ForkIo(int64_t h, char *p, size_t n,
}
static dontinline textwindows bool ForkIo2(int64_t h, void *buf, size_t n,
bool32 (*fn)(), const char *sf) {
bool32 (*fn)(), const char *sf,
bool ischild) {
ssize_t rc = ForkIo(h, buf, n, fn);
if (ischild) __tls_enabled = false; // prevent tls crash in kprintf
NTTRACE("%s(%ld, %p, %'zu) → %'zd% m", sf, h, buf, n, rc);
return rc != -1;
}
static dontinline textwindows bool WriteAll(int64_t h, void *buf, size_t n) {
return ForkIo2(h, buf, n, WriteFile, "WriteFile");
return ForkIo2(h, buf, n, WriteFile, "WriteFile", false);
}
static textwindows dontinline void ReadOrDie(int64_t h, void *buf, size_t n) {
__tls_enabled = false; // prevent tls crash in kprintf
if (!ForkIo2(h, buf, n, ReadFile, "ReadFile")) {
if (!ForkIo2(h, buf, n, ReadFile, "ReadFile", true)) {
AbortFork("ReadFile");
}
}