在我的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>
和/或<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不能给我指示问题发生的位置,我该如何解决?