Thanks for sharing a bit of history regarding my inquiry, John. That's always 
welcome as it helps drawing a more complete picture.

I'll look into some of your suggestions.

Thanks,
Thomas
________________________________
From: John Reiser <jrei...@bitwagon.com>
Sent: Sunday, June 16, 2024 1:05 AM
To: valgrind-users@lists.sourceforge.net <valgrind-users@lists.sourceforge.net>
Subject: Re: [Valgrind-users] Question regarding 'Conditional jump or move 
depends on uninitialised value(s)'

> 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?

For over two decades I have asked for a mode which complains at the
instant that an uninit bit is fetched from memory.  The usual excuse
of valgrind implementors is that uninit padding and alignment bytes,
plus compilers which can "over fetch", cause too many "false positive"
complaints.  But when I need this feature, then I *really* need it,
and I am willing to find the needle in the haystack.  Alas, valgrind
does not have such a mode.

For the case which you describe:
    a rather large class is allocated via operator new
    which comes with tons of subsequent data ... isn't
    default initialized
have you considered defining a function which calls calloc()
of the sizeof the class, then "placement new" to perform the
construction into that space?
Note that this hides real programming errors of type "forgot to
initialize"; and a few times a year it is very possible
that discovering such errors may reveal a real gap in your
overall logic.
Also note that malloc()+memset() can choose byte values other than 0;
and for floating point then bytes such as 0xFF (which causes NaN)
might be preferable because it effectively re-enables some checking
for uninit.
Also note that there is a feature of glibc malloc() such that the shell
environment variable MALLOC_PERTURN_=NNN (note the trailing underscore)
will do this for *all* calls to malloc().

For cases when the uninit is in not all the bits of a variable,
then you can use valgrind 'monitor' commands in a gdbserver to print
the status of each bit.  See the manual section 3.2: Debugging your
program using Valgrind gdbserver and GDB.



_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to