|
From: Rhys K. <rhy...@so...> - 2017-09-03 17:08:22
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=55fe390c7ac2bbd6b1b591747329fa4041d6c464 commit 55fe390c7ac2bbd6b1b591747329fa4041d6c464 Author: Rhys Kidd <rhy...@gm...> Date: Sun Sep 3 12:55:52 2017 -0400 Fix missing pselect syscall (OS X 10.11). bz#379748 Based upon patch from Louis Brunner. Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-darwin.h | 4 ++++ coregrind/m_syswrap/syswrap-darwin.c | 34 +++++++++++++++++++++++++++++++ include/vki/vki-scnums-darwin.h | 6 ++++++ memcheck/tests/darwin/scalar.c | 10 +++++++++ memcheck/tests/darwin/scalar.stderr.exp | 27 ++++++++++++++++++++++++ 6 files changed, 82 insertions(+) diff --git a/NEWS b/NEWS index 316beaf..835e35f 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,7 @@ To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX where XXXXXX is the bug number as listed below. +379748 Fix missing pselect syscall (OS X 10.11) 380397 s390x: __GI_strcspn() replacemenet needed 381162 possible array overrun in VEX register allocator 381272 ppc64 doesn't compile test_isa_2_06_partx.c without VSX support diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index 4755e71..bdefd61 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -489,7 +489,11 @@ DECL_TEMPLATE(darwin, __mac_syscall); // 381 // NYI __mac_get_lcid 391 // NYI __mac_get_lctx 392 // NYI __mac_set_lctx 393 +#if DARWIN_VERS >= DARWIN_10_11 +DECL_TEMPLATE(darwin, pselect); // 394 +#else // NYI setlcid 394 +#endif /* DARWIN_VERS >= DARWIN_10_11 */ // NYI getlcid 395 // GEN read_nocancel 396 // GEN write_nocancel 397 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index f219920..0ae281c 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -9794,6 +9794,39 @@ PRE(guarded_writev_np) /* --------------------------------------------------------------------- + Added for OSX 10.11 (El Capitan) + ------------------------------------------------------------------ */ + +#if DARWIN_VERS >= DARWIN_10_11 + +PRE(pselect) +{ + *flags |= SfMayBlock; + PRINT("pselect ( %ld, %#lx, %#lx, %#lx, %#lx, %#lx )", SARG1, ARG2, ARG3, + ARG4, ARG5, ARG6); + PRE_REG_READ5(long, "pselect", + int, n, vki_fd_set *, readfds, vki_fd_set *, writefds, + vki_fd_set *, exceptfds, struct vki_timeval *, timeout); + // XXX: this possibly understates how much memory is read. + if (ARG2 != 0) + PRE_MEM_READ( "pselect(readfds)", + ARG2, ARG1/8 /* __FD_SETSIZE/8 */ ); + if (ARG3 != 0) + PRE_MEM_READ( "pselect(writefds)", + ARG3, ARG1/8 /* __FD_SETSIZE/8 */ ); + if (ARG4 != 0) + PRE_MEM_READ( "pselect(exceptfds)", + ARG4, ARG1/8 /* __FD_SETSIZE/8 */ ); + if (ARG5 != 0) + PRE_timeval_READ( "pselect(timeout)", ARG5 ); + if (ARG6 != 0) + PRE_MEM_READ( "pselect(sigmask)", ARG6, sizeof(vki_sigset_t) ); +} + +#endif /* DARWIN_VERS >= DARWIN_10_11 */ + + +/* --------------------------------------------------------------------- Added for macOS 10.12 (Sierra) ------------------------------------------------------------------ */ @@ -10454,6 +10487,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { #if DARWIN_VERS >= DARWIN_10_11 // _____(__NR_kdebug_trace_string), // 178 // _____(__NR_kevent_qos), // 374 + MACX_(__NR_pselect, pselect), // 394 // _____(__NR_netagent_trigger), // 490 // _____(__NR_stack_snapshot_with_config), // 491 // _____(__NR_microstackshot), // 492 diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index 04b42c8..961e335 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -673,7 +673,13 @@ #define __NR___mac_get_lcid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(391) #define __NR___mac_get_lctx VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(392) #define __NR___mac_set_lctx VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(393) + +#if DARWIN_VERS >= DARWIN_10_11 +#define __NR_pselect VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(394) +#else #define __NR_setlcid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(394) +#endif /* DARWIN_VERS >= DARWIN_10_11 */ + #define __NR_getlcid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(395) #define __NR_read_nocancel VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(396) #define __NR_write_nocancel VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(397) diff --git a/memcheck/tests/darwin/scalar.c b/memcheck/tests/darwin/scalar.c index d74996c..4aac07a 100644 --- a/memcheck/tests/darwin/scalar.c +++ b/memcheck/tests/darwin/scalar.c @@ -676,7 +676,17 @@ int main(void) // __NR___mac_get_lcid 391 // __NR___mac_get_lctx 392 // __NR___mac_set_lctx 393 + +#if DARWIN_VERS >= DARWIN_10_11 + { + long args[6] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1, x0+1 }; + GO(__NR_pselect, 394, "1s 6m"); + SY(__NR_pselect, args+x0); FAIL; + } +#else // __NR_setlcid 394 +#endif /* DARWIN_VERS >= DARWIN_10_11 */ + // __NR_getlcid 395 // The nocancel syscalls (396--423) are tested in scalar_nocancel.c. diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index 56fd999..aba39e8 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -1177,6 +1177,33 @@ Syscall param getfsstat64(buf) points to unaddressable byte(s) (369-379): unused ----------------------------------------------------- ----------------------------------------------------- +x200018a(394): __NR_pselect 1s 6m +----------------------------------------------------- +Syscall param pselect(readfds) contains uninitialised byte(s) + ... + by 0x........: main (scalar.c:684) + +Syscall param pselect(writefds) contains uninitialised byte(s) + ... + by 0x........: main (scalar.c:684) + +Syscall param pselect(readfds) points to uninitialised byte(s) + ... + by 0x........: main (scalar.c:684) + Address 0x........ is on thread 1's stack + in frame #1, created by main (scalar.c:12) + +Syscall param pselect(writefds) points to unaddressable byte(s) + ... + by 0x........: main (scalar.c:684) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param pselect(exceptfds) points to unaddressable byte(s) + ... + by 0x........: main (scalar.c:684) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +----------------------------------------------------- x270f(9999): 9999 1e ----------------------------------------------------- WARNING: unhandled amd64-darwin syscall: unix:9999 |