Without this, we can end up double-writing to files if we call write()
during the same epoch a file is opened in, like:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define USED(v) ((void)(v))
int main(int argc, char** argv) {
int* p = (int*)malloc(sizeof(int));
*p = 123;
printf("Hello use after free\n");
int fd = open("/tmp/append-test", O_CREAT|O_WRONLY|O_APPEND, S_IRWXU|S_IRWXG);
write(fd, "write1\n", strlen("write1\n"));
free(p);
for (int i = 0; i < 1000; i++) {
volatile int q = 1.0 * 1.0;
USED(q);
}
*p = 456;
return 0;
}
However, printf still results in messages being printed twice, like:
printf("Hello use after free\n");. I'm not sure why this is - maybe
the internal buffering of printf? But shouldn't that be reset/cleared
when we rollback?
This partially addresses #6.
Without this, we can end up double-writing to files if we call write() during the same epoch a file is opened in, like:
However, printf still results in messages being printed twice, like:
printf("Hello use after free\n");
. I'm not sure why this is - maybe the internal buffering of printf? But shouldn't that be reset/cleared when we rollback?