|
From: Greg P. <gp...@ap...> - 2009-04-21 23:05:49
|
On Apr 21, 2009, at 3:33 PM, Filipe Cabecinhas wrote:
> This is a weird one. I copied the definition of alarm() from libc
> but the error cause eludes me. Attached is a small test case for the
> error.
> The output is:
> $ valgrind -q --track-origins=yes ./test-alarmallegedly
> uninitialized value: 0xbffff6e8, start of oitv: 0xbffff6dc, end:
> 0xbffff6ec
> ==84680== Conditional jump or move depends on uninitialised value(s)
> ==84680== at 0x1F38: alrm (test-alarm.c:24)
> ==84680== by 0x1FAC: main (test-alarm.c:39)
> ==84680== Uninitialised value was created by a stack allocation
> ==84680== at 0x1EAE: alrm (test-alarm.c:11)
> in handler: 14
>
> What's weird is that line 24 reads something that is inside the
> struct itimerval oitv and setitimer writes to the address specified
> for the third parameter for sizeof(struct itimerval) bytes, as we
> can see in syswrap-generic.c:
>
> PRE(sys_setitimer)
> {
> ...
> if (ARG3 != (Addr)NULL)
> PRE_MEM_WRITE( "setitimer(ovalue)", ARG3, sizeof(struct
> vki_itimerval));
> }
>
> POST(sys_setitimer)
> {
> if (ARG3 != (Addr)NULL)
> POST_MEM_WRITE(ARG3, sizeof(struct vki_itimerval));
> ...
>
> vki_itimerval is #defined to itimerval.
>
> What could be the error?
The error is the syscall_table entry in syswrap-darwin.c, at least if
yours looks like mine:
GENX_(__NR_setitimer, sys_setitimer),
That should be GENXY; as written it fails to run the POST handler.
Aside: struct itimerval is two struct timevals, and 64-bit struct
timeval has an alignment pad in the middle, so you should use
PRE_timeval_READ/PRE_timeval_WRITE/POST_timeval_WRITE. Using
PRE_MEM_READ(sizeof(struct itimerval)) to check setitimer(ARG2) will
cause false error reports.
--
Greg Parker gp...@ap... Runtime Wrangler
|