mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-10 22:52:28 +00:00
Fix fork() regression on Windows
Recent optimizations to fork() introduced a regression, that could cause the subprocess to fail unexpectedly, when TlsAlloc() returns a different index. This is because we were burning the indexes into the displacement of x86 opcodes. So when fork() happened and the executable memory copied it would use the old index. Right now the way this is being solved is to not copy the executable on fork() and then re-apply code changes. If you need to be able to preserve self-modified code on fork, reach out and we can implement a better solution for you. This gets us unblocked quickly.
This commit is contained in:
parent
f71f61cd40
commit
29eb7e67bb
11 changed files with 66 additions and 34 deletions
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
void GenBuf(char buf[8], int x) {
|
||||
|
@ -40,5 +41,15 @@ int main(int argc, char *argv[]) {
|
|||
tinyprint(2, "error: buf check failed\n", NULL);
|
||||
return 10;
|
||||
}
|
||||
const char *prog = "./execve_test_prog2";
|
||||
if (!fork()) {
|
||||
execl(prog, prog, NULL);
|
||||
_Exit(127);
|
||||
}
|
||||
int ws;
|
||||
if (wait(&ws) == -1)
|
||||
return 30;
|
||||
if (ws)
|
||||
return 31;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue