我在使用Valgrind来检查内存泄漏时遇到了一些问题(并且还了解了我在fprintf中遇到的段错误),但似乎有些o未初始化的值使用的不是来自我的码。 我是调试器的新手,所以我可能会遗漏一些东西。
我知道Valgrind与我的默认GCC OpenMP(http://valgrind.org/docs/manual/drd-manual.html#drd-manual.openmp)不相容,但是我正在使用它并用-pedantic -Wall -static -O0 -g -fopenmp
编译我的代码我没有错误。
然而,当用
运行Valgrind时valgrind --leak-check=full --track-origins=yes --error-limit=no --log-file=./logfile ~/developing/trunk/gop.exe
我在日志文件中输入了许多以
开头的警告==5944== Memcheck, a memory error detector
==5944== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==5944== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==5944== Command: /home/henrique/developing/trunk/gop.exe
==5944== Parent PID: 11534
==5944==
==5944== Syscall param set_robust_list(head) points to uninitialised byte(s)
==5944== at 0x4983DF: __pthread_initialize_minimal (nptl-init.c:369)
==5944== by 0x498920: (below main) (libc-start.c:146)
==5944== Address 0x4000bf0 is not stack'd, malloc'd or (recently) free'd
==5944== Uninitialised value was created
==5944== at 0x513A6A: brk (brk.c:32)
==5944== by 0x4ED4EB: sbrk (sbrk.c:54)
==5944== by 0x498C13: __libc_setup_tls (libc-tls.c:150)
==5944== by 0x498366: __pthread_initialize_minimal (nptl-init.c:296)
==5944== by 0x498920: (below main) (libc-start.c:146)
然后得到很多警告(数千!)类似于下面的警告
==5944== Conditional jump or move depends on uninitialised value(s)
==5944== at 0x4EF546: __linkin_atfork (register-atfork.c:119)
==5944== by 0x4BA5D3: ptmalloc_init (arena.c:388)
==5944== by 0x4BB283: malloc_hook_ini (hooks.c:32)
==5944== by 0x51842B: _dl_init_paths (dl-load.c:732)
==5944== by 0x4F097A: _dl_non_dynamic_init (dl-support.c:268)
==5944== by 0x4F1352: __libc_init_first (init-first.c:83)
==5944== by 0x49895B: (below main) (libc-start.c:165)
==5944== Uninitialised value was created
==5944== at 0x513A6A: brk (brk.c:32)
==5944== by 0x4ED4EB: sbrk (sbrk.c:54)
==5944== by 0x498C13: __libc_setup_tls (libc-tls.c:150)
==5944== by 0x498366: __pthread_initialize_minimal (nptl-init.c:296)
==5944== by 0x498920: (below main) (libc-start.c:146)
编译或运行Valgrind时我错过了什么?或者我的代码确实存在所有这些错误?
非常感谢!
答案 0 :(得分:0)
有些图书馆确实有许多小警告,比如你正在展示的那些。 我不认为它们来自你的代码,看到它们出现的文件的名称。
你必须在其他地方寻找你的段错误。尝试使用gdb运行它,查看停止的位置并在错误周围打印值以查看是什么。
希望有所帮助:)