paulfloyd / freebsd_valgrind

Git repo used to Upstream the FreeBSD Port of Valgrind
GNU General Public License v2.0
15 stars 4 forks source link

none/tests/pth_cancel1 is failing [i386] #63

Closed paulfloyd closed 4 years ago

paulfloyd commented 4 years ago

Looks like ESP and/or EIP are getting corrupted

--65622-- thr_kill: sending signal 32 to tid 101216
--65622-- thr_kill: sent signal 32 to tid 101216
--65622-- async signal handler: signal=32, tid=2, si_code=65543, exitreason VgSrc_None
--65622-- interrupted_syscall: tid=2, ip=0x38092079, restart=False, sres.isErr=T
rue, sres.val=4
--65622--   completed, but uncommitted: committing
--65622:1:  gdbsrv VG core calling VG_(gdbserver_report_signal) vki_nr 32 SIG32 gdb_nr 77 SIG32 tid 2
--65622:1:  gdbsrv not connected => pass
--65622-- delivering signal 32 (SIG32):65543 to thread 2
--65622-- push_signal_frame (thread 2): signal 32
--65622:2:  stacks   segment for SP 0xFBFFCEF8 changed stack end limit from 0xFBFFD000 to 0xFBFFCFFF
==65622==    at 0x5848293: _sigsuspend (in /usr/lib32/libc.so.7)
==65622==    by 0x57C16F8: sigsuspend (in /usr/lib32/libc.so.7)
==65622==    by 0x57B561D: pause (in /usr/lib32/libc.so.7)
==65622==    by 0x80489B2: thread_main (pth_cancel1.c:30)
==65622==    by 0x57268AA: ??? (in /usr/lib32/libthr.so.3)
==65622== valgrind: Unrecognised instruction at address 0x380909c1.
--65622:2:  stacks   segment for SP 0xFBFFC588 changed stack end limit from 0xFBFFD000 to 0xFBFFCFFF
==65622==    at 0x380909C1: ??? (in /usr/home/paulf/scratch/valgrind/none/none-x86-freebsd)
==65622==    by 0x57C16F8: sigsuspend (in /usr/lib32/libc.so.7)
==65622==    by 0x57B561D: pause (in /usr/lib32/libc.so.7)
==65622==    by 0x80489B2: thread_main (pth_cancel1.c:30)
==65622==    by 0x57268AA: ??? (in /usr/lib32/libthr.so.3)

Looks like this will involve debugging

static Addr build_sigframe() in sigframe-x86-freebsd.c

VG_(x86_freebsd_SUBST_FOR_sigreturn) in trampoline.S

PRE(sys_sigreturn) in syswrap-x86-freebsd.c

paulfloyd commented 4 years ago

Looking at some older versions of Valgrind, it looks like this has never worked on FreeBSD.

Possibly not as difficult as I'd feared

This test

   uc = (struct vki_ucontext *)ARG1;
   if (uc == NULL || uc->uc_mcontext.len != sizeof(uc->uc_mcontext)) {
      SET_STATUS_Failure(VKI_EINVAL);
      return;
   }

in PRE(sys_fake_sigreturn) is failing with mcontext len 4227845880 sz 640 i.e., uc->uc_mcontext.len is junk

Is this right? VG_(x86_freebsd_SUBST_FOR_sigreturn): lea 0x14(%esp), %eax / args to sigreturn(ucontext_t ) */

paulfloyd commented 4 years ago

Easy when you know how. To https://github.com/paulfloyd/freebsd_valgrind.git ead92d15f..618f1aa2c freebsd -> freebsd