|
From: Nicholas N. <nj...@ca...> - 2003-03-18 09:27:18
|
Hi,
I just discovered a minor bug with --attach-gdb. If an error is caused by
a bad argument to write(), when Valgrind prompts the user whether to drop
into GDB, the first character of the write() is used as the prompt's
input. This program:
int main(void)
{
char buf[5];
buf[0] =3D 'a'; // not one of [yYnNcC]
write(1, buf, 5);
return 0;
}
gives this result:
[njn25@trent head4] vghead4 --gdb-attach=3Dyes a.out
=3D=3D3113=3D=3D Memcheck, a.k.a. Valgrind, a memory error detector for x86=
-linux.
=3D=3D3113=3D=3D Copyright (C) 2002, and GNU GPL'd, by Julian Seward.
=3D=3D3113=3D=3D Using valgrind-1.9.4, a program instrumentation system for=
x86-linux.
=3D=3D3113=3D=3D Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
=3D=3D3113=3D=3D Estimated CPU clock rate is 1410 MHz
=3D=3D3113=3D=3D For more details, rerun with: -v
=3D=3D3113=3D=3D
=3D=3D3113=3D=3D Syscall param write(buf) contains uninitialised or unaddre=
ssable byte(s)
=3D=3D3113=3D=3D at 0x402F27B4: __libc_write (in /lib/libc-2.2.4.so)
=3D=3D3113=3D=3D by 0x40235335: __libc_start_main (../sysdeps/generic/li=
bc-start.c:129)
=3D=3D3113=3D=3D by 0x8048330: (within /local/scratch-2/njn25/local/src/=
grind/head4/a.out)
=3D=3D3113=3D=3D Address 0xBFFFF301 is on thread 1's stack
=3D=3D3113=3D=3D
=3D=3D3113=3D=3D ---- Attach to GDB ? --- [Return/N/n/Y/y/C/c] ---- a
"@=B0=3D=3D311=
3=3D=3D
=3D=3D3113=3D=3D ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 fro=
m 0)
=3D=3D3113=3D=3D malloc/free: in use at exit: 0 bytes in 0 blocks.
=3D=3D3113=3D=3D malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
=3D=3D3113=3D=3D For a detailed leak analysis, rerun with: --leak-check=3D=
yes
=3D=3D3113=3D=3D For counts of detected errors, rerun with: -v
The `a"@=B0' is the last 4 bytes of the string.
It's a pretty obscure bug, and I don't know how to fix it because it goes
beyond my understanding of how the scheduler works. So maybe it's not
worth fixing. But I thought I'd report it.
N
|