|
From: Paul F. <pa...@so...> - 2026-02-28 15:44:18
|
https://sourceware.org/cgit/valgrind/commit/?id=ab1cf750c53cc1ec2ecb3d885764caa81b8fdd14 commit ab1cf750c53cc1ec2ecb3d885764caa81b8fdd14 Author: Paul Floyd <pj...@wa...> Date: Sat Feb 28 16:43:38 2026 +0100 Darwin syscall: clean up posix_spawn and add to scalar Diff: --- coregrind/m_syswrap/syswrap-darwin.c | 4 +++- memcheck/tests/darwin/scalar.c | 6 ++++- memcheck/tests/darwin/scalar.stderr.exp | 39 ++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index ff0eaa27b0..44357b0afb 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -3801,6 +3801,8 @@ static void pre_argv_envp(Addr a, ThreadId tid, const HChar* s1, const HChar* s2 Addr a_deref; Addr* a_p = (Addr*)a; PRE_MEM_READ( s1, (Addr)a_p, sizeof(Addr) ); + if (!ML_(safe_to_deref)(a_p, sizeof(char*))) + return; a_deref = *a_p; if (0 == a_deref) break; @@ -4009,7 +4011,7 @@ PRE(posix_spawn) // are omitted. // if (!trace_this_child) { - argv = (HChar**)ARG6; + argv = (HChar**)ARG5; } else { vg_assert( VG_(args_for_valgrind) ); vg_assert( VG_(args_for_valgrind_noexecpass) >= 0 ); diff --git a/memcheck/tests/darwin/scalar.c b/memcheck/tests/darwin/scalar.c index dd53145d2c..c4e93814ba 100644 --- a/memcheck/tests/darwin/scalar.c +++ b/memcheck/tests/darwin/scalar.c @@ -421,7 +421,11 @@ int main(void) // __NR_flistxattr 241 // __NR_fsctl 242 // __NR_initgroups 243 - // __NR_posix_spawn 244 + + // two of the pointers, file_actions and attr, are opaque void* pointers + // currently we do not check what they point to, so "4m" for the moment + GO(__NR_posix_spawn, 244, "6s 4m"); + SY(__NR_posix_spawn, x0+1, x0+1, x0+1, x0+1, x0+1, x0+1); GO_UNIMP(245-246, "unused"); diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index b0fd9e4a34..da616dcb79 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -544,6 +544,43 @@ Syscall param exchangedata(path2) points to unaddressable byte(s) ----------------------------------------------------- (228-229): unused ----------------------------------------------------- +----------------------------------------------------- +x20000f4(244): __NR_posix_spawn 6s 4m +----------------------------------------------------- +Syscall param posix_spawn(pid) contains uninitialised byte(s) + ... + +Syscall param posix_spawn(path) contains uninitialised byte(s) + ... + +Syscall param posix_spawn(file_actions) contains uninitialised byte(s) + ... + +Syscall param posix_spawn(attrp) contains uninitialised byte(s) + ... + +Syscall param posix_spawn(argv) contains uninitialised byte(s) + ... + +Syscall param posix_spawn(envp) contains uninitialised byte(s) + ... + +Syscall param posix_spawn(pid) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param posix_spawn(path) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param posix_spawn(argv) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param posix_spawn(envp) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + ----------------------------------------------------- (245-246): unused ----------------------------------------------------- @@ -584,6 +621,7 @@ Syscall param shmctl(IPC_STAT, buf) points to unaddressable byte(s) ----------------------------------------------------- x2000108(264): __NR_shmdt 1s 0m ----------------------------------------------------- + Syscall param shmdt(shmaddr) contains uninitialised byte(s) ... @@ -630,7 +668,6 @@ Syscall param sem_close(sem) contains uninitialised byte(s) ----------------------------------------------------- x200010e(270): __NR_sem_unlink 1s 1m ----------------------------------------------------- - Syscall param sem_unlink(name) contains uninitialised byte(s) ... |