valgrind:获得有意义的回溯

valgrind: getting a meaningful backtrace

在我的 Debian/sid 系统上,当 运行 我的程序通过 valgrind 时,我得到一大堆错误。 不幸的是,错误并没有告诉我,valgrind 认为问题出在哪里:

==24268== Use of uninitialised value of size 8
==24268==    at 0x51CF257: ??? (in /lib/x86_64-linux-gnu/libc-2.27.so)
==24268==    by 0x18D4F9: ??? (in /path/to/app)
==24268==    by 0x19A369: ??? (in /path/to/app)
==24268==    by 0x19A6F0: ??? (in /path/to/app)
==24268==    by 0x19A8C7: ??? (in /path/to/app)
==24268==    by 0x19267A: ??? (in /path/to/app)
==24268==    by 0x192857: ??? (in /path/to/app)
==24268==    by 0x192A20: ??? (in /path/to/app)
==24268==    by 0x19ABF6: ??? (in /path/to/app)
==24268==    by 0x11E0B9: ??? (in /path/to/app)
==24268==    by 0x5155B16: ??? (in /lib/x86_64-linux-gnu/libc-2.27.so)
==24268==  Uninitialised value was created by a stack allocation
==24268==    at 0x19A2E0: ??? (in /path/to/app)
==24268== 
==24268== Use of uninitialised value of size 8
==24268==    at 0x51CF440: ??? (in /lib/x86_64-linux-gnu/libc-2.27.so)
==24268==    by 0x18D4F9: ??? (in /path/to/app)
==24268==    by 0x19A369: ??? (in /path/to/app)
==24268==    by 0x19A6F0: ??? (in /path/to/app)
==24268==    by 0x19A8C7: ??? (in /path/to/app)
==24268==    by 0x19267A: ??? (in /path/to/app)
==24268==    by 0x192857: ??? (in /path/to/app)
==24268==    by 0x192A20: ??? (in /path/to/app)
==24268==    by 0x19ABF6: ??? (in /path/to/app)
==24268==    by 0x11E0B9: ??? (in /path/to/app)
==24268==    by 0x5155B16: ??? (in /lib/x86_64-linux-gnu/libc-2.27.so)
==24268==  Uninitialised value was created by a stack allocation
==24268==    at 0x19A2E0: ??? (in /path/to/app)
==24268== 

不祥之兆 ??? 我本以为会是 <filename>:<linenumber> and/or <functionname>.

当然程序是用-g编译的,之后没有去掉调试符号:

$ file app
app: ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=6a2de5a8779ca1f745cb79999f6e24adc73def7d, with debug_info, not stripped

还有一些系统信息:

$ dpkg-query -W gcc libc6 valgrind
gcc         4:7.3.0-3
libc6:amd64 2.27-4
libc6:i386  2.27-4
valgrind    1:3.13.0-2+b1
$ valgrind --version
valgrind-3.13.0

所以我的问题是:为什么 valgrind 不指示问题发生的位置,以及我该如何解决?

您可能已经命中 https://bugs.kde.org/show_bug.cgi?id=395682, 其中包含一些(尚未推送的)补丁提案。