]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix missing pselect syscall (OS X 10.11). bz#379748
authorRhys Kidd <rhyskidd@gmail.com>
Sun, 3 Sep 2017 16:55:52 +0000 (12:55 -0400)
committerRhys Kidd <rhyskidd@gmail.com>
Sun, 3 Sep 2017 16:55:52 +0000 (12:55 -0400)
Based upon patch from Louis Brunner.

NEWS
coregrind/m_syswrap/priv_syswrap-darwin.h
coregrind/m_syswrap/syswrap-darwin.c
include/vki/vki-scnums-darwin.h
memcheck/tests/darwin/scalar.c
memcheck/tests/darwin/scalar.stderr.exp

diff --git a/NEWS b/NEWS
index 316beaf4fe6f41d2092d0f820496d44eb34c6e17..835e35fcd9cd9963dd023b9b598ce99161c4aa59 100644 (file)
--- 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
index 4755e716dfc6e58807e7d0c281816c2b903be723..bdefd61523547e8033f59a1f416695ffe84a4471 100644 (file)
@@ -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
index f2199201f1abee7083cd3b85f4227a36fd1b665f..0ae281ce811750828221defe336edbffdd83deae 100644 (file)
@@ -9793,6 +9793,39 @@ PRE(guarded_writev_np)
 #endif /* DARWIN_VERS >= DARWIN_10_10 */
 
 
+/* ---------------------------------------------------------------------
+   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
index 04b42c84403f95ab6bd96aa947bfbe21530c8871..961e33558ab7c057bd5258b529aef14daf7d7207 100644 (file)
 #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)
index d74996c6572cfc340db457be8d1bd59b9fa4222e..4aac07ae0ad9e851d5c933e32d8444186cedd903 100644 (file)
@@ -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.
index 56fd999aff590c7d8d744a4e74e4ee1d4d826c6c..aba39e86368e7375371c20145cc87d5142695b08 100644 (file)
@@ -1176,6 +1176,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
 -----------------------------------------------------