* [RFC PATCH] Appease Valgrind over ptrace calls.
@ 2013-02-14 18:38 Pedro Alves
2013-02-14 18:41 ` Pedro Alves
0 siblings, 1 reply; 2+ messages in thread
From: Pedro Alves @ 2013-02-14 18:38 UTC (permalink / raw)
To: gdb-patches
Trying out Valgrind on gdbserver, on x86_64, I get these annoying warnings:
==3987== Conditional jump or move depends on uninitialised value(s)
==3987== at 0x430FB2: x86_linux_update_xmltarget (linux-x86-low.c:1250)
==3987== by 0x4310F7: x86_linux_process_qsupported (linux-x86-low.c:1304)
==3987== by 0x42BD07: linux_process_qsupported (linux-low.c:5253)
==3987== by 0x40CF75: handle_query (server.c:1571)
==3987== by 0x41045E: process_serial_event (server.c:2930)
==3987== by 0x41154C: handle_serial_event (server.c:3364)
==3987== by 0x4170BA: handle_file_event (event-loop.c:436)
==3987== by 0x416847: process_event (event-loop.c:191)
==3987== by 0x41762E: start_event_loop (event-loop.c:554)
==3987== by 0x410137: main (server.c:2781)
==3987==
==3987== Conditional jump or move depends on uninitialised value(s)
==3987== at 0x431009: x86_linux_update_xmltarget (linux-x86-low.c:1258)
==3987== by 0x4310F7: x86_linux_process_qsupported (linux-x86-low.c:1304)
==3987== by 0x42BD07: linux_process_qsupported (linux-low.c:5253)
==3987== by 0x40CF75: handle_query (server.c:1571)
==3987== by 0x41045E: process_serial_event (server.c:2930)
==3987== by 0x41154C: handle_serial_event (server.c:3364)
==3987== by 0x4170BA: handle_file_event (event-loop.c:436)
==3987== by 0x416847: process_event (event-loop.c:191)
==3987== by 0x41762E: start_event_loop (event-loop.c:554)
==3987== by 0x410137: main (server.c:2781)
==3987==
==3987== Conditional jump or move depends on uninitialised value(s)
==3987== at 0x435AD9: i387_xsave_to_cache (i387-fp.c:477)
==3987== by 0x42FD67: x86_store_xstateregset (linux-x86-low.c:353)
==3987== by 0x42A01C: regsets_fetch_inferior_registers (linux-low.c:4063)
==3987== by 0x42A7FC: linux_fetch_registers (linux-low.c:4355)
==3987== by 0x40675B: get_thread_regcache (regcache.c:50)
==3987== by 0x408D0F: prepare_resume_reply (remote-utils.c:1337)
==3987== by 0x40F5CC: handle_status (server.c:2372)
==3987== by 0x41077F: process_serial_event (server.c:3029)
==3987== by 0x41154C: handle_serial_event (server.c:3364)
==3987== by 0x4170BA: handle_file_event (event-loop.c:436)
==3987== by 0x416847: process_event (event-loop.c:191)
==3987== by 0x41762E: start_event_loop (event-loop.c:554)
It seems like Valgrind doesn't understand that ptrace writes to the
buffers in question, so throws out false positives.
Valgrind on GDB spews out equivalent warnings.
This patch works around it in gdbserver. Is there a better way to do
this perhaps?
Hmm, nut, I'm now wondering why we don't see many more ptrace-related
warnings in other cases. Maybe Valgrind does know about ptrace, but
not about PTRACE_GETREGSET?
gdb/gdbserver/
2013-02-14 Pedro Alves <palves@redhat.com>
* linux-low.c (regsets_fetch_inferior_registers)
---
gdb/gdbserver/linux-low.c | 6 ++++--
gdb/gdbserver/linux-x86-low.c | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c52cd2e..00214da 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4022,7 +4022,8 @@ regsets_fetch_inferior_registers (struct regcache *regcache)
continue;
}
- buf = xmalloc (regset->size);
+ /* Zero out the buffer to appease Valgrind. */
+ buf = xcalloc (1, regset->size);
nt_type = regset->nt_type;
if (nt_type)
@@ -4092,7 +4093,8 @@ regsets_store_inferior_registers (struct regcache *regcache)
continue;
}
- buf = xmalloc (regset->size);
+ /* Zero out the buffer to appease Valgrind. */
+ buf = xcalloc (1, regset->size);
/* First fill the buffer with the current register set contents,
in case there are any items in the kernel's regset that are
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 31657d3..604ecd6 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -1224,7 +1224,9 @@ x86_linux_update_xmltarget (void)
/* Check if XSAVE extended state is supported. */
if (have_ptrace_getregset == -1)
{
- unsigned long long xstateregs[I386_XSTATE_SSE_SIZE / sizeof (long long)];
+ /* Zeroed out to appease Valgrind. */
+ unsigned long long
+ xstateregs[I386_XSTATE_SSE_SIZE / sizeof (long long)] = {0};
struct iovec iov;
iov.iov_base = xstateregs;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC PATCH] Appease Valgrind over ptrace calls.
2013-02-14 18:38 [RFC PATCH] Appease Valgrind over ptrace calls Pedro Alves
@ 2013-02-14 18:41 ` Pedro Alves
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2013-02-14 18:41 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 02/14/2013 06:38 PM, Pedro Alves wrote:
> Hmm, but, I'm now wondering why we don't see many more ptrace-related
> warnings in other cases. Maybe Valgrind does know about ptrace, but
> not about PTRACE_GETREGSET?
Found it... https://bugs.kde.org/show_bug.cgi?id=308886
Answer is yes. Valgrind doesn't know about PTRACE_GETREGSET. Issue
seems to be fixed upstream.
Dropping this patch.
Thanks for listening. :-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-14 18:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-14 18:38 [RFC PATCH] Appease Valgrind over ptrace calls Pedro Alves
2013-02-14 18:41 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox