1 version: valgrind-3.20.0 4.19.25-200.el7.bclinux.x86_64 gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) 2 Problem description: -- source code: mmap a mdev device
static int test_mmap_bar(void) { const char *path="/sys/class/mdev_bus/0000:06:00.0/resource4"; ... flags = O_RDWR; prot = PROT_READ | PROT_WRITE; unsigned long len = 4096; unsigned long offset = 0x320000; fd = open(path, flags | O_SYNC); if (fd < 0) { printf("[ERROR] open device err\n"); return -1; } addr = mmap(0, len, prot, MAP_SHARED, fd, offset); if (addr == P_FAILED) { printf("[ERROR] mmap faild\n"); } ... } --run with valgrind : valgrind --leak-check=full --show-leak-kinds=all -v --log-file=valgrind.log ./build/valgrind-test --base-virtaddr=0x4000000000 -- The valgrind log reported the following error with mmap?? valgrind: m_debuginfo/image.c:587 (set_CEnt): Assertion '! sr_isError(sr)' failed. --strace valgrind: open("/sys/class/mdev_bus/0000:06:00.0/resource4", O_RDWR|O_SYNC) = 94 rt_sigprocmask(SIG_SETMASK, ~[ILL TRAP BUS FPE KILL SEGV STOP SYS], NULL, 8) = 0 gettid() = 13758 read(1028, "Y", 1) = 1 mmap(0x4033000, 4096, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 94, 0x320000) = 0x4033000 syscall_332(0x5e, 0x58246543, 0x1000, 0xfff, 0x1003633aa0, 0) = 0 readlink("/proc/self/fd/94", "/sys/devices/pci0000:00/0000:00:"..., 4096) = 59 syscall_332(0xffffffffffffff9c, 0x597789da, 0, 0xfff, 0x10036346d0, 0) = 0 syscall_332(0x5e, 0x58246543, 0x1000, 0xfff, 0x1003634560, 0) = 0 pread64(94, 0x100299acd0, 8192, 0) = -1 EIO (Input/output error) valgrind will do pread64 after mmap ?? 4 run directly: -- There is no problem with mmap -- use pread64(..) will cause io error 5 Quesions: How can I use valgrind in this case
valgrind.log
Description: Binary data
_______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users