|
From: Tom H. <th...@cy...> - 2004-07-12 19:54:16
|
In message <200...@we...>
Hoai Tran <ho...@ya...> wrote:
> I'm a new guy in Valgrind. It's quite useful to me. However, there is a
> case that I cannot explain. I have a segment of code as following:
>
> double best;
> ....
> best = -1.0e20;
> cout << "BEst = " << best << endl;
>
> And Valgrind prints messages:
>
> ==12945== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
> ==12945== at 0x3C3F43E4: write (in /lib/libc-2.2.5.so)
> ==12945== by 0x3C39B7C7: _IO_file_write (in /lib/libc-2.2.5.so)
> ==12945== by 0x3C2E5E37: sys_write__7filebufPCci (in /usr/lib/libstdc++-3-libc6.2-2-2.10.0.so)
> ==12945== by 0x3C39AE87: (within /lib/libc-2.2.5.so)
> ==12945== by 0x3C39B92B: _IO_file_xsputn (in /lib/libc-2.2.5.so)
> ==12945== by 0x3C2E5EAF: xsputn__7filebufPCci (in /usr/lib/libstdc++-3-libc6.2-2-2.10.0.so)
> ==12945== by 0x3C2E9871: (within /usr/lib/libstdc++-3-libc6.2-2-2.10.0.so)
> ==12945== by 0x3C2E9998: __ls__7ostreami (in /usr/lib/libstdc++-3-libc6.2-2-2.10.0.so)
> ==12945== by 0x80E64D2: newOpenSubCount__13ABA_PARMASTER (parmaster_opensubcount.cc:178)
>
> Please help me to work around the error. Or tell me what exactly I must
> follow in order to use Valgrind correctly. Thank alot.
You are writing uninitialised data to cout at some point. Note that
if cout is buffered then the actual problem write may have occurred
some time before because valgrind will only report the problem when
the write system call occurs as the buffer is flushed, which may be
sometime later.
Making the stream unbuffered can help make this sort of problem easier
to track down.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|