Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valgrind doesn't work #120

Closed
tycho opened this issue Apr 11, 2016 · 31 comments
Closed

valgrind doesn't work #120

tycho opened this issue Apr 11, 2016 · 31 comments

Comments

@tycho
Copy link

tycho commented Apr 11, 2016

# valgrind -v ./test1
--1791:0:aspacem   -1: ANON 0038000000-00383d5fff 4022272 r-x-- SmFixed d=0x000 i=205168  o=0       (0) m=0 /usr/lib/valgrind/memcheck-amd64-linux
--1791:0:aspacem  Valgrind: FATAL: aspacem assertion failed:
--1791:0:aspacem    segment_is_sane
--1791:0:aspacem    at m_aspacemgr/aspacemgr-linux.c:1502 (add_segment)
--1791:0:aspacem  Exiting now.
@sunilmut
Copy link
Member

It might be helpful to collect a strace to see which syscall is failing? Or you can take it a step further by comparing it to a strace from a real Ubuntu box.

@xuanruiqi
Copy link

I have been getting the same bug as @tycho. I collected a strace and here's the full strace output:

# valgrind ./hello
--8593:0:aspacem   -1: ANON 0038000000-00383d5fff 4022272 r-x-- SmFixed d=0x000 i=311715  o=0       (0) m=0 /usr/lib/valgrind/memcheck-amd64-linux
--8593:0:aspacem  Valgrind: FATAL: aspacem assertion failed:
--8593:0:aspacem    segment_is_sane
--8593:0:aspacem    at m_aspacemgr/aspacemgr-linux.c:1502 (add_segment)
--8593:0:aspacem  Exiting now.
# strace valgrind ./hello
strace: Test for PTRACE_O_TRACESYSGOOD failed, giving up using this feature.
execve("/usr/bin/valgrind", ["valgrind", "./hello"], [/* 13 vars */]) = 0
brk(0)                                  = 0x8220000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffee0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=30501, ...}) = 0
mmap(NULL, 30501, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ff5ffff7000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ff5ff830000
mprotect(0x7ff5ff9eb000, 2093056, PROT_NONE) = 0
mmap(0x7ff5ffbea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7ff5ffbea000
mmap(0x7ff5ffbf0000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffbf0000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffed0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffec0000
arch_prctl(ARCH_SET_FS, 0x7ff5ffec0740) = 0
mprotect(0x7ff5ffbea000, 16384, PROT_READ) = 0
mprotect(0x821b000, 8192, PROT_READ)    = 0
mprotect(0x7ff5ffe22000, 4096, PROT_READ) = 0
munmap(0x7ff5ffff7000, 30501)           = 0
getpid()                                = 8597
rt_sigaction(SIGCHLD, {0x8012460, ~[RTMIN RT_1], SA_RESTORER, 0x7ff5ff866d40}, NULL, 8) = 0
geteuid()                               = 0
brk(0)                                  = 0x8220000
brk(0x8241000)                          = 0x8241000
getppid()                               = 8594
stat("/mnt/c/Users/Ray/Desktop", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
stat(".", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
open("/usr/bin/valgrind", O_RDONLY)     = 3
fcntl(3, F_DUPFD, 10)                   = 10
close(3)                                = 0
fcntl(10, F_SETFD, FD_CLOEXEC)          = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], SA_RESTORER, 0x7ff5ff426d40}, 8) = 0
rt_sigaction(SIGINT, {0x8012460, ~[RTMIN RT_1], SA_RESTORER, 0x7ff5ff866d40}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], SA_RESTORER, 0x7ff5ff426d40}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7ff5ff866d40}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], SA_RESTORER, 0x7ff5ff426d40}, 8) = 0
rt_sigaction(SIGTERM, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7ff5ff866d40}, NULL, 8) = 0
read(10, "#!/bin/sh -e\n#\n# Valgrind wrappe"..., 8192) = 528
execve("/usr/bin/valgrind.bin", ["/usr/bin/valgrind.bin", "./hello"], [/* 16 vars */]) = 0
brk(0)                                  = 0x605000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffee0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug/tls/x86_64", 0x7ff5fffeedb0) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug/tls", 0x7ff5fffeedb0) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug/x86_64", 0x7ff5fffeedb0) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=30501, ...}) = 0
mmap(NULL, 30501, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ff5ffff7000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ff5ff830000
mprotect(0x7ff5ff9eb000, 2093056, PROT_NONE) = 0
mmap(0x7ff5ffbea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7ff5ffbea000
mmap(0x7ff5ffbf0000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffbf0000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffed0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5ffec0000
arch_prctl(ARCH_SET_FS, 0x7ff5ffec0740) = 0
mprotect(0x7ff5ffbea000, 16384, PROT_READ) = 0
mprotect(0x603000, 4096, PROT_READ)     = 0
mprotect(0x7ff5ffe22000, 4096, PROT_READ) = 0
munmap(0x7ff5ffff7000, 30501)           = 0
open("./hello", O_RDONLY)               = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\2\0>\0\1\0\0\0@\4@\0\0\0\0\0"..., 4096) = 4096
close(3)                                = 0
readlink("/proc/self/exe", "/usr/bin/valgrind.bin", 4096) = 21
brk(0)                                  = 0x605000
brk(0x626000)                           = 0x626000
execve("/usr/lib/valgrind/memcheck-amd64-linux", ["/usr/bin/valgrind.bin", "./hello"], [/* 17 vars */]) = 0
open("/proc/self/maps", O_RDONLY)       = 3
read(3, "38000000-383d6000 r-x- 00000000 "..., 100000) = 344
read(3, 0x38e26b18, 99656)              = 0
close(3)                                = 0
getpid()                                = 8597
write(2, "--8597:0:aspacem   -1: ANON 0038"..., 90--8597:0:aspacem   -1: ANON 0038000000-00383d5fff 4022272 r-x-- SmFixed d=0x000 i=311715  ) = 90
write(2, "o=0       (0) m=0 /usr/lib/valgr"..., 57o=0       (0) m=0 /usr/lib/valgrind/memcheck-amd64-linux
) = 57
getpid()                                = 8597
write(2, "--8597:0:aspacem  Valgrind: FATA"..., 61--8597:0:aspacem  Valgrind: FATAL: aspacem assertion failed:
) = 61
getpid()                                = 8597
write(2, "--8597:0:aspacem    segment_is_s"..., 36--8597:0:aspacem    segment_is_sane
) = 36
getpid()                                = 8597
write(2, "--8597:0:aspacem    at m_aspacem"..., 72--8597:0:aspacem    at m_aspacemgr/aspacemgr-linux.c:1502 (add_segment)
) = 72
getpid()                                = 8597
write(2, "--8597:0:aspacem  Exiting now.\n", 31--8597:0:aspacem  Exiting now.
) = 31
exit_group(1)                           = ?
<... exit_group resumed> _exit returned!
)              = ?
+++ exited with 1 +++

@tycho
Copy link
Author

tycho commented Apr 17, 2016

My bet is the /proc/self/maps contents not being digestible by valgrind.

@roboticlemon
Copy link

None of the following memory tools are working atm:

  • AddressSanitizer
  • LeakSanitizer
  • Valgrind

@roboticlemon
Copy link

roboticlemon commented Apr 18, 2016

Tried with clang as well and no luck

==7882==AddressSanitizer CHECK failed: /build/buildd/llvm-toolchain-3.4-3.4/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:462 "((IsOneOf(*current_, 's', 'p'))) != (0)" (0x0, 0x0)

Strace

write(2, "==7908== AddressSanitizer CHECK "..., 163==7908== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0) ) = 163 munmap(0x7ff5fc140000, 16384) = 0 open("/proc/self/maps", O_RDONLY) = 3 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc140000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc140000, 4096) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc140000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffd00000"..., 4096) = 1848 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc140000, 8192) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc140000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffd00000"..., 4096) = 1848 read(3, 0x7ff5fc141738, 4096) = 0 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc130000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc130000, 4096) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc130000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffcf0000"..., 4096) = 1896 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc130000, 8192) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc130000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffcf0000"..., 4096) = 1896 read(3, 0x7ff5fc131768, 4096) = 0 close(3) = 0 munmap(0x7ff5fc160000, 16384) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc160000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc120000 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc110000 write(2, " #0 0x7ff5fcc8231d", 21 #0 0x7ff5fcc8231d) = 21 munmap(0x7ff5fc110000, 16384) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc110000 write(2, "==7908== AddressSanitizer CHECK "..., 163==7908== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0) ) = 163 munmap(0x7ff5fc110000, 16384) = 0 open("/proc/self/maps", O_RDONLY) = 3 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc110000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc110000, 4096) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc110000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffcd0000"..., 4096) = 1992 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc110000, 8192) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc110000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffcd0000"..., 4096) = 1992 read(3, 0x7ff5fc1117c8, 4096) = 0 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc100000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc100000, 4096) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc100000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffcc0000"..., 4096) = 2040 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc100000, 8192) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc100000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffcc0000"..., 4096) = 2040 read(3, 0x7ff5fc1017f8, 4096) = 0 close(3) = 0 munmap(0x7ff5fc130000, 16384) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc130000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0f0000 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0e0000 write(2, " #0 0x7ff5fcc8231d", 21 #0 0x7ff5fcc8231d) = 21 munmap(0x7ff5fc0e0000, 16384) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0e0000 write(2, "==7908== AddressSanitizer CHECK "..., 163==7908== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0) ) = 163 munmap(0x7ff5fc0e0000, 16384) = 0 open("/proc/self/maps", O_RDONLY) = 3 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0e0000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc0e0000, 4096) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0e0000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffca0000"..., 4096) = 2136 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc0e0000, 8192) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0e0000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffca0000"..., 4096) = 2136 read(3, 0x7ff5fc0e1858, 4096) = 0 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0d0000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc0d0000, 4096) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0d0000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffc90000"..., 4096) = 2184 close(3) = 0 open("/proc/self/maps", O_RDONLY) = 3 munmap(0x7ff5fc0d0000, 8192) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0d0000 read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096 read(3, "-- 00000000 00:00 0\n7ff5ffc90000"..., 4096) = 2184 read(3, 0x7ff5fc0d1888, 4096) = 0 close(3) = 0 munmap(0x7ff5fc100000, 16384) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc100000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0c0000 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0b0000 write(2, " #0 0x7ff5fcc8231d", 21 #0 0x7ff5fcc8231d) = 21 munmap(0x7ff5fc0b0000, 16384) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fc0b0000

@xilun
Copy link

xilun commented Apr 26, 2016

problem still present on build 14328

@ambertx
Copy link

ambertx commented May 10, 2016

Also getting this exact error on 14332

@jbhumphe
Copy link

jbhumphe commented May 20, 2016

Also having this issue on build14342

strace

strace: Test for PTRACE_O_TRACESYSGOOD failed, giving up using this feature.
execve("/usr/bin/valgrind", ["valgrind", "./hello"], [/* 16 vars */]) = 0
brk(0)                                  = 0x8220000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fffffed0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22124, ...}) = 0
mmap(NULL, 22124, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fffffed9000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fffff830000
mprotect(0x7fffff9eb000, 2093056, PROT_NONE) = 0
mmap(0x7fffffbea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7fffffbea000
mmap(0x7fffffbf0000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fffffbf0000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fffffec0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fffffeb0000
arch_prctl(ARCH_SET_FS, 0x7fffffeb0740) = 0
mprotect(0x7fffffbea000, 16384, PROT_READ) = 0
mprotect(0x821b000, 8192, PROT_READ)    = 0
mprotect(0x7fffffe22000, 4096, PROT_READ) = 0
munmap(0x7fffffed9000, 22124)           = 0
getpid()                                = 9340
rt_sigaction(SIGCHLD, {0x8012460, ~[RTMIN RT_1], SA_RESTORER, 0x7fffff866d40}, NULL, 8) = 0
geteuid()                               = 1000
brk(0)                                  = 0x8220000
brk(0x8241000)                          = 0x8241000
getppid()                               = 9337
stat("/home/jbhum/dev/hello", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
stat(".", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
open("/usr/bin/valgrind", O_RDONLY)     = 3
fcntl(3, F_DUPFD, 10)                   = 10
close(3)                                = 0
fcntl(10, F_SETFD, FD_CLOEXEC)          = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], SA_RESTORER, 0x7fffff426d40}, 8) = 0
rt_sigaction(SIGINT, {0x8012460, ~[RTMIN RT_1], SA_RESTORER, 0x7fffff866d40}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], SA_RESTORER, 0x7fffff426d40}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7fffff866d40}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], SA_RESTORER, 0x7fffff426d40}, 8) = 0
rt_sigaction(SIGTERM, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7fffff866d40}, NULL, 8) = 0
read(10, "#!/bin/sh -e\n#\n# Valgrind wrappe"..., 8192) = 528
execve("/usr/bin/valgrind.bin", ["/usr/bin/valgrind.bin", "./hello"], [/* 19 vars */]) = 0
brk(0)                                  = 0x605000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffffffd0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug/tls/x86_64", 0x7fffffedcda0) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug/tls", 0x7fffffedcda0) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug/x86_64", 0x7fffffedcda0) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/debug", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22124, ...}) = 0
mmap(NULL, 22124, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffffffda000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fffff630000
mprotect(0x7fffff7eb000, 2093056, PROT_NONE) = 0
mmap(0x7fffff9ea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7fffff9ea000
mmap(0x7fffff9f0000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fffff9f0000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffffffc0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffffffb0000
arch_prctl(ARCH_SET_FS, 0x7ffffffb0740) = 0
mprotect(0x7fffff9ea000, 16384, PROT_READ) = 0
mprotect(0x603000, 4096, PROT_READ)     = 0
mprotect(0x7fffffc22000, 4096, PROT_READ) = 0
munmap(0x7ffffffda000, 22124)           = 0
open("./hello", O_RDONLY)               = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\2\0>\0\1\0\0\0\220\6@\0\0\0\0\0"..., 4096) = 4096
close(3)                                = 0
readlink("/proc/self/exe", "/usr/bin/valgrind.bin", 4096) = 21
brk(0)                                  = 0x605000
brk(0x626000)                           = 0x626000
execve("/usr/lib/valgrind/memcheck-amd64-linux", ["/usr/bin/valgrind.bin", "./hello"], [/* 20 vars */]) = 0
open("/proc/self/maps", O_RDONLY)       = 3
read(3, "38000000-383d6000 r-x- 00000000 "..., 100000) = 393
read(3, 0x38e26b49, 99607)              = 0
close(3)                                = 0
getpid()                                = 9340
write(2, "--9340:0:aspacem   -1: ANON 0038"..., 90--9340:0:aspacem   -1: ANON 0038000000-00383d5fff 4022272 r-x-- SmFixed d=0x000 i=167890  ) = 90
write(2, "o=0       (0) m=0 /usr/lib/valgr"..., 57o=0       (0) m=0 /usr/lib/valgrind/memcheck-amd64-linux
) = 57
getpid()                                = 9340
write(2, "--9340:0:aspacem  Valgrind: FATA"..., 61--9340:0:aspacem  Valgrind: FATAL: aspacem assertion failed:
) = 61
getpid()                                = 9340
write(2, "--9340:0:aspacem    segment_is_s"..., 36--9340:0:aspacem    segment_is_sane
) = 36
getpid()                                = 9340
write(2, "--9340:0:aspacem    at m_aspacem"..., 72--9340:0:aspacem    at m_aspacemgr/aspacemgr-linux.c:1502 (add_segment)
) = 72
getpid()                                = 9340
write(2, "--9340:0:aspacem  Exiting now.\n", 31--9340:0:aspacem  Exiting now.
) = 31
exit_group(1)                           = ?
<... exit_group resumed> _exit returned!
)              = ?
+++ exited with 1 +++

Let me know if there is anything else you want me to test out or run.

edit: Changed Stack Trace to strace because stack trace was wrong, lol. Thank you @tycho

@tycho
Copy link
Author

tycho commented May 20, 2016

@jbhum nitpick: that's not a stack trace, it's an strace, or syscall trace.

@ad3angel1s
Copy link

Issue still there with 14366.

@Jon-Davis
Copy link

Ok so it looks like I'm not the only one with the problem, having this issue on 14372. Are there any work around? I have been needing to scp onto a linux machine to use valgrind.

@xilun
Copy link

xilun commented Jul 10, 2016

Just re-tested on 14385, and valgrind still does not run. I don't know of any workaround. I guess we will have to wait for after RS1?

@povijarrro
Copy link

Hi for me it helped to download sources and compile (./configure, make, make install , make clean , make distclean) in bash. valgrind installed from repositories writed above rubbish.

@MotorizedWandOfFury
Copy link

Installing Valgrind 3.11.0 from source also works for me (currently on Windows Anniversary build). Thanks @povijarrro .

@tycho
Copy link
Author

tycho commented Aug 11, 2016

If you find the delta in config.log between a native Linux machine and a
Linux-on-Windows machine, you might find what kernel feature it depends on
is flaking out on Windows.

On Aug 10, 2016 7:59 PM, "MotorizedWandOfFury" notifications@github.com
wrote:

Installing Valgrind 3.11.0 from source also works for me (currently on
Windows Anniversary build). Thanks @povijarrro
https://github.com/povijarrro .


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#120 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABzsI1QrL5eAJwdQvL45ezp0nup5wg1ks5qepAYgaJpZM4IEIfI
.

@rodrigocaus
Copy link

I have also installed Valgrind 3.11.0 from source (on Windows 10 14393.82 version 1607). It seems to work well. Thanks to @povijarrro and @MotorizedWandOfFury.

@arthurpham
Copy link

Have you guys managed to make callgrind work ? It seems i have a seg fault with it.

@rodrigocaus
Copy link

I had segmentation fault problems with callgrind using callgrind_control and malloc. I don't actually use this tool, I often use memcheck.

yartff added a commit to yartff/rdfl that referenced this issue Oct 28, 2016
= sync
= Little changes
= Started reprocessing DEVEL source code
= Added valgrind exec support in Makefile (Untested on BashOnWindows: microsoft/WSL#120)
@byvlstr
Copy link

byvlstr commented Dec 1, 2016

Installing from repository solved the first issue, but now I am getting the General protection fault as you guys... Any fixes for that?

Process terminating with default action of signal 11 (SIGSEGV): dumping core

==14714== General Protection Fault ==14714== at 0x400F476: _dl_fixup (dl-runtime.c:73) ==14714== by 0x40164D4: _dl_runtime_resolve (dl-trampoline.S:45) ==14714== by 0x430C6D: std::log(long double) (cmath:362)

==14714== by 0x435A05: float std::generate_canonical<float, 24ul, std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul> >(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&) (random.tcc:3471) ==14714== by 0x4348FA: std::__detail::_Adaptor<std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>, float>::operator()() (random.h:190) ==14714== by 0x43335E: float std::uniform_real_distribution<float>::operator()<std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul> >(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&, std::uniform_real_distribution<float>::param_type const&) (random.h:1983) ==14714== by 0x4323DC: float std::uniform_real_distribution<float>::operator()<std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul> >(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&) (random.h:1974)

==14714== by 0x447411: Common::init_binding_matrix(unsigned int) (Common.cpp:22) ==14714== by 0x42E84B: main (main.cpp:9) --14714-- REDIR: 0x58f1d00 (libc.so.6:free) redirected to 0x4c2bc56 (free) ==14714== ==14714== HEAP SUMMARY: ==14714== in use at exit: 0 bytes in 0 blocks ==14714== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==14714== ==14714== All heap blocks were freed -- no leaks are possible ==14714== ==14714== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==14714== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Segmentation fault (core dumped)

@LAHumphreys
Copy link

@byvlstr As per my comment in #1295 I have a dirty hack that at least gets you past the SIGSEGV: https://github.com/Grauniad/valgrind

It's not perfect - but applying this change to the 3.12.0 release of valgrind gets you going at least. Note that:

  1. I'm not a valgrind dev
  2. I'm not a WLS dev
  3. There are still a handful of regression test failures after applying this patch...

...so use it at your own risk :)

@arthurpham: The callgrind suite passes clean on my machine, but 1 & 2 still apply...

@misenesi
Copy link

@Grauniad Outstanding investigation, thank you very much! Fix is checked in.

@FranklinYu
Copy link

Is it expected that I still got this behavior? I kept my Windows 10 and Ubuntu updated. Is this released?

@ghost
Copy link

ghost commented Jul 11, 2017

Thanks @povijarrro that worked!

@aahaselgrove
Copy link

This issue was previously closed, but I'm not sure what the outcome was. Is valgrind supposed to work directly off apt, or is it only supposed to work if installing from source?

I got version 3.10.1-1 off apt (Windows version 1703), and received the original error message (aspacem assertion failed).

@Kyrluckechuck
Copy link

Kyrluckechuck commented Aug 23, 2017

I found that using this method solved it for me, however it could have been a coincidence/my code was just too simple, but every test I did that involved intentional memory leaks were properly tracked (I have no attachment to my current LSFW install as I haven't been able to do anything noteworthy in it yet, so I just nuked the whole install and reinstalled it (which is a very quick process btw))
As per this:
Turns out they actually did resolve it, just destroy your old linux subsystem and install a new one (I did this as I've been having problems when updating packages where it has issues with grub and other functions not being implemented, but those issues were fixed in newer installs of lxsfw), and install the valgrind available from apt -- it naturally works
To reinstall (using cmd prompt)
To uninstall and preserve /home directory on WSL:

lxrun /uninstall

To uninstall and trash/home directory on WSL:

lxrun /uninstall /full

To install again:

lxrun /install

To install again without user & password (always root):

lxrun /install /y

@MotorizedWandOfFury
Copy link

I'm currently on Windows 10 Pro (Version 10.0.15063 Build 15063) and I had no trouble at all installing and using Valgrind.

@aahaselgrove
Copy link

@Kyrluckechuck Thanks, I didn't realise I needed to reinstall.

@AndreasTisland
Copy link

Valgrind works after I installed Windows 10 creator update (version 1703) and reinstalled Bash/WSL :)

@FrankHB
Copy link

FrankHB commented Aug 29, 2018

Actually the workaround works well till a few days ago...

==16438== error calling PR_SET_PTRACER, vgdb might block
vex amd64->IR: unhandled instruction bytes: 0xF3 0xF 0x1E 0xFA 0x55 0x48 0x89 0xE5 0x41 0x57
vex amd64->IR:   REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=0F
vex amd64->IR:   PFX.66=0 PFX.F2=0 PFX.F3=1
==16438== valgrind: Unrecognised instruction at address 0x4002e00.
==16438==    at 0x4002E00: ??? (in /usr/lib/ld-2.28.so)
==16438==    by 0x4002007: ??? (in /usr/lib/ld-2.28.so)
==16438==    by 0x1: ???
==16438==    by 0xFFF000312: ???
==16438==    by 0xFFF000326: ???

Not sure why, but finally I realize this is in my /usr/local/bin since 30 May 2017. After reinstalling the package from official Arch repo it works again. So the workaround retires.

@therealkenc therealkenc removed the bug label Aug 29, 2018
@FranklinYu
Copy link

@FrankHB Arch is not officially supported by Microsoft, so I think it's better to report to them directly. I guess you are using ArchWSL?

@FrankHB
Copy link

FrankHB commented Aug 30, 2018

@FranklinYu No. I was using alwsl but this time it was based on a squashfs'd backup of my previous installation. (So I had a hard time to remove my /usr/local stuff as I the build directory is left on another machine...)
I think this would not be accepted by Arch team, as Arch would probably never have official support of WSL stuff. Anyway, the official Arch package does work at current; just note that the hack from @Grauniad is outdated now (although I'm still a bit curious about the reason).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests