On 6/15/2024 10:38 AM, Thomas Wollenzin wrote:
Hi,

I'm not too familiar with valgrind yet so excuse a potentially dumb question.

I'm trying to fix an issue in our code base that valgrind reported as 'Conditional jump or move depends on uninitialised value(s)'. In particular I have a hard time understanding what the exact item is that's being seen as uninitialised. I can't share code as it's very complex and non-public.

What happens is that a rather large class is allocated via operator new which comes with tons of subsequent data. Unfortunately, a lot of that data isn't default initialized so it's rather impossible to go by trial and error. Valgrind does report the place where the condition is but it's a super busy loop that works on tons of templated data.

Is there a way to have Valgrind tell me what type exactly has the uninitialised field or at best break at the time this exact incident occurs?

Thanks,
Thomas

I have fixed so many bugs by initializing seemingly harmless variables that I now initialize all variables and all data structure fields, even if only to nullptr.  Valgrind found one use of an uninitialized variable; you probably have many more that didn't show up in this run.

My advice is to make some guesses and initialize the most likely suspects until the problem goes away.  You might call that "trial and error", but initialization fixes bugs; it does not create new ones.

Then schedule a pass to go over all your code and initialize everything else.  You won't regret it.

--
    David chapmandcchap...@acm.org
    Chapman Consulting -- San Jose, CA
    EDA Software Developer, Expert Witness
    www.chapman-consulting-sj.com
    2018-2019 Chair, IEEE Consultants' Network of Silicon Valley
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to