简体   繁体   中英

OpenMP Uninitialized values and Valgrind

I'm having some problems using Valgrind to check for memory leaks (and also to understand a segfault I'm getting in fprintf), but it seems that somehow there are a couple o uninitialized values used that does not come from my code. I'm new to debugging with debuggers so I may be missing something.

I know Valgrind is not confortable with my default GCC OpenMP ( http://valgrind.org/docs/manual/drd-manual.html#drd-manual.openmp ), but I'm using it and compilimg my code with -pedantic -Wall -static -O0 -g -fopenmp I get no errors.

However, when running Valgrind with

valgrind --leak-check=full --track-origins=yes --error-limit=no --log-file=./logfile ~/developing/trunk/gop.exe

I get in my logfile a lot of warnings starting with

==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)

And then getting a lot of warnings (thousands!) similar to the one below

==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)

Am I missing something when compiling or running Valgrind? Or my code really have all these errors?

Thank you very much!

Some libraries do have a lot of little warnings like the ones you are showing. I don't think they come from your code here seeing the names of the files where they occur.

You'll have to look somewhere else for your segfault. Try running it with gdb, look where it stops and print values around the error to see what's up.

Hope it helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM