summary refs log tree commit diff stats
path: root/results/scraper/launchpad-without-comments/1810433
blob: 706f1f3247d2278a9e079284de159789acbeb3a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
aarch64-linux-user master: inconsistent pwrite behaviour

Hello,

I am running aarch64-linux-user from master, commit 20d6c7312f1b812bb9c750f4087f69ac8485cc90

And I've found the following inconsistent emulation of pwrite() call when buf==NULL and len=0.
Minimal reproducible sample is the following:

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

/*
 System                  | Result
-------------------------+----------------
 Native x86_64 4.12.14   | pwrite ret = 0
 Native aarch64 4.4.159  | pwrite ret = 0
 qemu-aarch64 at x86_64  | pwrite ret = -1
   ( 20d6c7312f1b8 )     |
*/

int main(int argc, char** argv) {
	int fd = open("test.dat", O_CREAT | O_RDWR, 0644);
	if (fd < 0) {
		perror("open");
		return 1;
	}

	int ret = fallocate(fd, 0, 0, 1000);
	if (ret < 0) {
		perror("fallocate");
		return 1;
	}

	ssize_t ret_pwrite = pwrite(fd, NULL, 0, 0);
	printf("pwrite ret = %ld\n", ret_pwrite);

	close(fd);

	return 0;
}