Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 1659468 - valgrind arm64 bad ptrace PTRACE_TRACEME support
Summary: valgrind arm64 bad ptrace PTRACE_TRACEME support
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: valgrind
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Mark Wielaard
QA Contact: Alexandra Petlanová Hájková
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-14 13:28 UTC by Mark Wielaard
Modified: 2019-06-14 01:50 UTC (History)
3 users (show)

Fixed In Version: valgrind-3.14.0-7.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-14 01:50:26 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)

Description Mark Wielaard 2018-12-14 13:28:57 UTC
In most cases arm64 ptrace works under valgrind, but the PTRACE_TRACEME support might fail when signals are immediately sent before attach. This can (sometimes) seen with the memcheck/tests/linux/getregset testcase:

memcheck/tests/linux/getregset           (stderr)

# cat memcheck/tests/linux/getregset.stderr.out 

valgrind: the 'impossible' happened:
   main(): signal was supposed to be fatal

host stacktrace:
   ...

sched status:
  running_tid=1


Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.

The fix is simple:

diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
index 9ef54b40a..650f5b9f0 100644
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
@@ -499,6 +499,9 @@ PRE(sys_ptrace)
 POST(sys_ptrace)
 {
    switch (ARG1) {
+   case VKI_PTRACE_TRACEME:
+         ML_(linux_POST_traceme)(tid);
+         break;
    case VKI_PTRACE_PEEKTEXT:
    case VKI_PTRACE_PEEKDATA:
    case VKI_PTRACE_PEEKUSR:

With that memcheck/tests/linux/getregset.vgtest always passes on arm64 too.


Note You need to log in before you can comment on or make changes to this bug.