0

我有一个用活性分析实现的寄存器分配器,我遇到了一个段错误:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7560d9d in _int_malloc () from /lib64/libc.so.6

所以我在 valgrind 上运行它,试图用这个命令查看错误是什么:

valgrind -v --leak-check=yes

我以前从未使用过这个程序,我真的不知道为什么会发生段错误。我怀疑某处有内存泄漏。有人可以帮我理解 valgrind 的输出在说什么吗?

--58831-- Reading syms from /lib64/ld-2.11.3.so (0x4000000)
--58831-- Reading syms from /usr/lib64/valgrind/amd64-linux/memcheck (0x38000000)
--58831--    object doesn't have a symbol table
--58831--    object doesn't have a dynamic symbol table
--58831-- Reading suppressions file: /usr/lib64/valgrind/default.supp
==58831== Conditional jump or move depends on uninitialised value(s)
==58831==    at 0x401677D: strlen (in /lib64/ld-2.11.3.so)
==58831==    by 0x4005072: fillin_rpath (in /lib64/ld-2.11.3.so)
==58831==    by 0x40086D8: _dl_init_paths (in /lib64/ld-2.11.3.so)
==58831==    by 0x400311F: dl_main (in /lib64/ld-2.11.3.so)
==58831==    by 0x4014AD2: _dl_sysdep_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x40013CB: _dl_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x4000B07: (within /lib64/ld-2.11.3.so)
==58831==    by 0x2: ???
==58831==    by 0x7FF00057E: ???
==58831==    by 0x7FF000584: ???
==58831==    by 0x7FF000587: ???
--58831-- Reading syms from /usr/lib64/valgrind/amd64-linux/vgpreload_core.so (0x4A21000)
--58831--    object doesn't have a symbol table
==58831==
==58831== Conditional jump or move depends on uninitialised value(s) 
==58831==    at 0x4016616: index (in /lib64/ld-2.11.3.so)
==58831==    by 0x4007682: expand_dynamic_string_token (in /lib64/ld-2.11.3.so)
==58831==    by 0x4007C75: _dl_map_object (in /lib64/ld-2.11.3.so)
==58831==    by 0x400184D: map_doit (in /lib64/ld-2.11.3.so)
==58831==    by 0x400DE45: _dl_catch_error (in /lib64/ld-2.11.3.so)
==58831==    by 0x4001766: do_preload (in /lib64/ld-2.11.3.so)
==58831==    by 0x4003D3F: dl_main (in /lib64/ld-2.11.3.so)
==58831==    by 0x4014AD2: _dl_sysdep_start (in /lib64/ld-2.11.3.so) 
==58831==    by 0x40013CB: _dl_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x4000B07: (within /lib64/ld-2.11.3.so)   
==58831==    by 0x2: ???
==58831==    by 0x7FF00057E: ???
==58831==
==58831== Conditional jump or move depends on uninitialised value(s)
==58831==    at 0x401661B: index (in /lib64/ld-2.11.3.so)
==58831==    by 0x4007682: expand_dynamic_string_token (in /lib64/ld-2.11.3.so)
==58831==    by 0x4007C75: _dl_map_object (in /lib64/ld-2.11.3.so)
==58831==    by 0x400184D: map_doit (in /lib64/ld-2.11.3.so)
==58831==    by 0x400DE45: _dl_catch_error (in /lib64/ld-2.11.3.so)  
==58831==    by 0x4001766: do_preload (in /lib64/ld-2.11.3.so)
==58831==    by 0x4003D3F: dl_main (in /lib64/ld-2.11.3.so)
==58831==    by 0x4014AD2: _dl_sysdep_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x40013CB: _dl_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x4000B07: (within /lib64/ld-2.11.3.so)
==58831==    by 0x2: ???
==58831==    by 0x7FF00057E: ???
--58831-- Reading syms from /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so     (0x4C23000)
--58831--    object doesn't have a symbol table
--58831-- REDIR: 0x40165b0 (index) redirected to 0x4c27ba0 (index)
--58831-- REDIR: 0x4016630 (strcmp) redirected to 0x4c28160 (strcmp)
--58831-- REDIR: 0x4016740 (strlen) redirected to 0x4c27e60 (strlen)
--58831-- Reading syms from /usr/lib64/libstdc++.so.6.0.17 (0x4E2C000)
--58831-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x2a

valgrind: m_debuginfo/readdwarf.c:2152 (copy_convert_CfiExpr_tree): Assertion 'srcix >= 0     && srcix < VG_(sizeXA)(srcxa)' failed.
==58831==    at 0x3801C15C: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x3801C46A: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x380560A1: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x3805635D: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x38056BAB: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x380586BA: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x38053BFD: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x380356C0: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x3806BFC3: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x3806FE93: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x38039886: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x38036CB2: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x38037CD7: (within /usr/lib64/valgrind/amd64-linux/memcheck)
==58831==    by 0x38049A70: (within /usr/lib64/valgrind/amd64-linux/memcheck)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable
==58831==    at 0x40161AA: mmap (in /lib64/ld-2.11.3.so)
==58831==    by 0x40065DA: _dl_map_object_from_fd (in /lib64/ld-2.11.3.so)
==58831==    by 0x4007D1C: _dl_map_object (in /lib64/ld-2.11.3.so)
==58831==    by 0x400D401: openaux (in /lib64/ld-2.11.3.so)
==58831==    by 0x400DE45: _dl_catch_error (in /lib64/ld-2.11.3.so)
==58831==    by 0x400C48F: _dl_map_object_deps (in /lib64/ld-2.11.3.so)
==58831==    by 0x40032DF: dl_main (in /lib64/ld-2.11.3.so)
==58831==    by 0x4014AD2: _dl_sysdep_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x40013CB: _dl_start (in /lib64/ld-2.11.3.so)
==58831==    by 0x4000B07: (within /lib64/ld-2.11.3.so)
==58831==    by 0x2: ???
==58831==    by 0x7FF00057E: ???
==58831==    by 0x7FF000584: ???
==58831==    by 0x7FF000587: ???
4

1 回答 1

0

在我看来,您在编译程序时没有添加调试符号。如果您使用的是 GCC,请将“-ggdb”附加到您的编译命令中。例如,如果你写过:

gcc -o program main.c

将其更改为:

gcc -o program main.c -ggdb

然后 Valgrind 将能够将潜在的错误与代码联系起来。另外,我认为您的 Valgrind 命令中不需要“-v”标志。

祝你好运!

于 2013-12-09T11:35:59.370 回答