【问题标题】:OpenMP Uninitialized values and ValgrindOpenMP 未初始化的值和 Valgrind
【发布时间】:2014-03-21 21:16:19
【问题描述】:

我在使用 Valgrind 来检查内存泄漏时遇到了一些问题(也为了理解我在 fprintf 中遇到的段错误),但似乎不知何故使用了一些未初始化的值,这些值不是来自我的代码。 我是使用调试器调试的新手,所以我可能会遗漏一些东西。

我知道 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 时是否遗漏了什么?还是我的代码真的有所有这些错误?

非常感谢!

【问题讨论】:

    标签: c openmp valgrind


    【解决方案1】:

    有些库确实有很多小警告,就像您展示的那样。 我不认为它们来自您的代码,在这里看到它们出现的文件的名称。

    您必须在其他地方寻找您的段错误。尝试使用 gdb 运行它,查看它在哪里停止并打印错误周围的值以查看发生了什么。

    希望对你有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      • 2012-07-15
      相关资源
      最近更新 更多