recorder offset issue
Recording seek operations with recorder can in some edge cases lead to wrong offset: Here is a simple example:
int main() {
FILE *fd, *fd2;
int len;
char buf[20] = "hello";
fd = fopen("./tmp_4", "w+");
fd2 = fopen("./tmp_4", "w+");
fwrite(buf, sizeof(buf), 100, fd);
fseek(fd2, 100, SEEK_SET);
fseek(fd, -500, SEEK_CUR);
fwrite(buf, sizeof(buf), 10, fd);
fwrite(buf, sizeof(buf), 10, fd2);
return 0;
}
We start by opening the same file twice withing the same process, this creates two different file descriptors. In otf2 this wouldn't be an issue because each open creates a new file handle. In recorder however only the filename is associated with the offset hence in this special case the offset is wrong because to recorder fd is the same as fd2
offset of fd:
line | otf2 | recorder |
---|---|---|
4 | 0 | 0 |
5 | 0 | 0 |
6 | 2000 | 2000 |
7 | 2000 | 100 |
8 | 1500 | -400 |
9 | 1700 | -200 |
10 | 1700 | 0 |