You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(83) |
Oct
(89) |
Nov
(97) |
Dec
(30) |
| 2024 |
Jan
(25) |
Feb
(73) |
Mar
(76) |
Apr
(122) |
May
(46) |
Jun
(44) |
Jul
(27) |
Aug
(30) |
Sep
(33) |
Oct
(67) |
Nov
(91) |
Dec
(70) |
| 2025 |
Jan
(44) |
Feb
(36) |
Mar
(85) |
Apr
(100) |
May
(138) |
Jun
(55) |
Jul
(107) |
Aug
(96) |
Sep
(151) |
Oct
(129) |
Nov
(23) |
Dec
|
|
From: Paul F. <pa...@so...> - 2025-11-10 08:28:00
|
https://sourceware.org/cgit/valgrind/commit/?id=c430409dd6b7a7d43ae62c98a2c025709dce8057 commit c430409dd6b7a7d43ae62c98a2c025709dce8057 Author: Paul Floyd <pj...@wa...> Date: Mon Nov 10 09:25:54 2025 +0100 Darwin syscall args: missing piece for layout Getting the layout and PRE_REG_READX in the PRE wrappers should now be correct for amd64. Diff: --- coregrind/m_syswrap/priv_types_n_macros.h | 4 ++-- memcheck/tests/darwin/scalar.stderr.exp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/coregrind/m_syswrap/priv_types_n_macros.h b/coregrind/m_syswrap/priv_types_n_macros.h index 6da1cad31d..3cc0be8a44 100644 --- a/coregrind/m_syswrap/priv_types_n_macros.h +++ b/coregrind/m_syswrap/priv_types_n_macros.h @@ -491,7 +491,7 @@ static inline UWord getERR ( SyscallStatus* st ) { # define PRA7(s,t,a) PSRAn(7,s,t,a) # define PRA8(s,t,a) PSRAn(8,s,t,a) -#elif defined(VGP_amd64_freebsd) +#elif defined(VGP_amd64_freebsd) || defined(VGP_amd64_darwin) /* Up to 8 parameters, 6 in registers, 2 on the stack. */ /* or 7 in registers and 3 on the stack */ # define PRA1(s,t,a) PRRAn(1,s,t,a) @@ -531,7 +531,7 @@ static inline UWord getERR ( SyscallStatus* st ) { # define PRA7(s,t,a) PSRAn(7,s,t,a) # define PRA8(s,t,a) PSRAn(8,s,t,a) -#elif defined(VGP_amd64_darwin) || defined(VGP_amd64_solaris) +#elif defined(VGP_amd64_solaris) /* Up to 8 parameters, 6 in registers, 2 on the stack. */ # define PRA1(s,t,a) PRRAn(1,s,t,a) # define PRA2(s,t,a) PRRAn(2,s,t,a) diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index a336413601..b0fd9e4a34 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -1061,6 +1061,9 @@ Syscall param kevent_qos(eventlist) contains uninitialised byte(s) Syscall param kevent_qos(nevents) contains uninitialised byte(s) ... +Syscall param kevent_qos(data_out) contains uninitialised byte(s) + ... + Syscall param kevent_qos(data_available) contains uninitialised byte(s) ... |
|
From: Paul F. <pa...@so...> - 2025-11-09 20:58:45
|
https://sourceware.org/cgit/valgrind/commit/?id=ed27b47d8101f6d850a8fd50589e750cae09c43e commit ed27b47d8101f6d850a8fd50589e750cae09c43e Author: Paul Floyd <pj...@wa...> Date: Sun Nov 9 21:57:01 2025 +0100 Darwin redirs: add several str* amd mem* redirs to vg_replace_strmem.c Mostly these are _chk variants. I've also undone a change that forced the compiler to not use these variants. Diff: --- memcheck/tests/Makefile.am | 22 ++++++++++++++++++++++ memcheck/tests/filter_libc_variants | 2 +- memcheck/tests/memccpy2.c | 8 ++++---- memcheck/tests/overlap.c | 10 +++++----- memcheck/tests/overlap.vgtest | 1 + shared/vg_replace_strmem.c | 15 ++++++++------- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 6343b1b7c8..5cdc2082c9 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -814,7 +814,13 @@ origin4_many_CFLAGS = $(AM_CFLAGS) -O @FLAG_W_NO_USE_AFTER_FREE@ @FLAG_W_NO_UNIN # Apply -O so as to run in reasonable time. origin5_bz2_CFLAGS = $(AM_CFLAGS) -O -Wno-inline +if VGCONF_OS_IS_DARWIN +origin5_bz2_CFLAGS += -fno-inline +endif origin6_fp_CFLAGS = $(AM_CFLAGS) -O +if VGCONF_OS_IS_DARWIN +origin6_fp_CFLAGS += -fno-inline +endif # Don't allow GCC to inline memcpy() and strcpy(), # because then we can't intercept it @@ -876,11 +882,27 @@ wrap6_CFLAGS = $(AM_CFLAGS) -O2 # To make it a bit more realistic, have some optimisation enabled # for the varinfo tests. We still expect sane results. varinfo1_CFLAGS = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@ +if VGCONF_OS_IS_DARWIN +varinfo1_CFLAGS += -fno-inline +endif varinfo2_CFLAGS = $(AM_CFLAGS) -O -Wno-shadow @FLAG_W_NO_MAYBE_UNINITIALIZED@ +if VGCONF_OS_IS_DARWIN +varinfo2_CFLAGS += -fno-inline +endif varinfo3_CFLAGS = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@ +if VGCONF_OS_IS_DARWIN +varinfo3_CFLAGS += -fno-inline +endif varinfo4_CFLAGS = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@ +if VGCONF_OS_IS_DARWIN +varinfo4_CFLAGS += -fno-inline +endif varinfo5_CFLAGS = $(AM_CFLAGS) -O varinfo6_CFLAGS = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@ +if VGCONF_OS_IS_DARWIN +varinfo6_CFLAGS += -fno-inline +endif + # Build shared object for varinfo5 varinfo5_SOURCES = varinfo5.c diff --git a/memcheck/tests/filter_libc_variants b/memcheck/tests/filter_libc_variants index bfffa84689..3ecf1fb808 100755 --- a/memcheck/tests/filter_libc_variants +++ b/memcheck/tests/filter_libc_variants @@ -2,4 +2,4 @@ ./filter_stderr "$@" | -sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /;s/ _platform_memccpy / memccpy /' +sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /;s/ _platform_memccpy / memccpy /;s/ __memccpy_chk / memccpy /;s/ __strncat_chk / strncat /;s/ __strncpy_chk / strncpy /;s/ __strcpy_chk / strcpy /' diff --git a/memcheck/tests/memccpy2.c b/memcheck/tests/memccpy2.c index be7808d5fd..9473245817 100644 --- a/memcheck/tests/memccpy2.c +++ b/memcheck/tests/memccpy2.c @@ -8,9 +8,9 @@ int main(void) { char* astring = strdup("this is a string # with something to seek"); size_t len = strlen(astring); - (memccpy)(astring+10, astring, '#', len-10); + memccpy(astring+10, astring, '#', len-10); sprintf(astring, "this is a string # with something to seek"); - (memccpy)(astring, astring+10, '#', len); + memccpy(astring, astring+10, '#', len); sprintf(astring, "this is a string # with something to seek"); /* @@ -23,10 +23,10 @@ int main(void) assert(res && *res == 'g'); sprintf(astring, "this is a string # with something to seek"); /* length is 0, nothing copied, returns NULL */ - res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0); + res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0); assert(NULL == res); /* 'z' not found so 20 bytes copied, returns NULL */ - res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20); + res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20); assert(NULL == res); free(astring); } diff --git a/memcheck/tests/overlap.c b/memcheck/tests/overlap.c index 649b1e34d3..d868886f38 100644 --- a/memcheck/tests/overlap.c +++ b/memcheck/tests/overlap.c @@ -42,16 +42,16 @@ int main(void) memcpy(x, x+20, 21); // overlap strncpy(x+20, x, 20); // ok - (strncpy)(x+20, x, 21); // overlap + strncpy(x+20, x, 21); // overlap strncpy(x, x+20, 20); // ok - (strncpy)(x, x+20, 21); // overlap + strncpy(x, x+20, 21); // overlap x[39] = '\0'; strcpy(x, x+20); // ok x[39] = 39; x[40] = '\0'; - (strcpy)(x, x+20); // overlap + strcpy(x, x+20); // overlap x[19] = '\0'; strcpy(x+20, x); // ok @@ -109,8 +109,8 @@ int main(void) always run forever, I think... */ for ( i = 0; i < 2; i++) - (strncat)(a+20, a, 21); // run twice to check 2nd error isn't shown - (strncat)(a, a+20, 21); + strncat(a+20, a, 21); // run twice to check 2nd error isn't shown + strncat(a, a+20, 21); /* This is ok, but once gave a warning when strncpy() was wrong, and used 'n' for the length, even when the src was shorter than 'n' */ diff --git a/memcheck/tests/overlap.vgtest b/memcheck/tests/overlap.vgtest index 7e49d95c80..166bf73f7e 100644 --- a/memcheck/tests/overlap.vgtest +++ b/memcheck/tests/overlap.vgtest @@ -2,3 +2,4 @@ prog: overlap vgopts: -q # https://bugs.kde.org/show_bug.cgi?id=402833 prereq: ! ../../tests/os_test linux || ! ../../tests/arch_test amd64 +stderr_filter: filter_libc_variants diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 5ef4884efa..d9de90b411 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -386,7 +386,8 @@ static inline void my_exit ( int x ) STRNCAT(VG_Z_LIBC_SONAME, strncat) #elif defined(VGO_darwin) - //STRNCAT(VG_Z_LIBC_SONAME, strncat) + STRNCAT(VG_Z_LIBSYSTEM_C_SONAME, strncat) + STRNCAT(VG_Z_LIBSYSTEM_C_SONAME, __strncat_chk) //STRNCAT(VG_Z_DYLD, strncat) #elif defined(VGO_solaris) @@ -572,9 +573,8 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRCPY(VG_Z_LIBC_SONAME, strcpy) -# if DARWIN_VERS == DARWIN_10_9 - STRCPY(VG_Z_LIBSYSTEM_C_SONAME, strcpy) -# endif + STRCPY(VG_Z_LIBSYSTEM_C_SONAME, strcpy) + STRCPY(VG_Z_LIBSYSTEM_C_SONAME, __strcpy_chk) #elif defined(VGO_solaris) STRCPY(VG_Z_LIBC_SONAME, strcpy) @@ -620,9 +620,8 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRNCPY(VG_Z_LIBC_SONAME, strncpy) -# if DARWIN_VERS >= DARWIN_10_9 - STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, strncpy) -# endif + STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, strncpy) + STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, __strncpy_chk) #elif defined(VGO_solaris) STRNCPY(VG_Z_LIBC_SONAME, strncpy) @@ -1175,6 +1174,7 @@ static inline void my_exit ( int x ) # endif MEMCPY(VG_Z_LIBC_SONAME, memcpyZDVARIANTZDsse3x) /* memcpy$VARIANT$sse3x */ MEMCPY(VG_Z_LIBC_SONAME, memcpyZDVARIANTZDsse42) /* memcpy$VARIANT$sse42 */ + MEMCPY(VG_Z_LIBSYSTEM_C_SONAME, __memcpy_chk) #elif defined(VGO_solaris) MEMCPY(VG_Z_LIBC_SONAME, memcpy) @@ -2383,6 +2383,7 @@ static inline void my_exit ( int x ) #if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris) MEMCCPY(VG_Z_LIBC_SONAME, memccpy) #elif defined(VGO_darwin) + MEMCCPY(VG_Z_LIBSYSTEM_C_SONAME, __memccpy_chk) MEMCCPY(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memccpy) #endif |
|
From: Paul F. <pa...@so...> - 2025-11-09 18:55:35
|
https://sourceware.org/cgit/valgrind/commit/?id=7f71b26b924df4e81aa2f39cd5075338fb25bb8b commit 7f71b26b924df4e81aa2f39cd5075338fb25bb8b Author: Paul Floyd <pj...@wa...> Date: Sun Nov 9 19:28:13 2025 +0100 Darwin: rework syscall arg handling There were numerous issues, particularly with syscall SYS_syscall and the scalar tests. Only tested on amd64, I don't have access to an OSX 10.12 or earlier machine to do any testing. The key elements in VG_(client_syscall) are, when the PRE wrapper does not handle the syscall 1. getSyscallArgsFromGuestState 2. getSyscallArgLayout 3. call PRE wrapper either blocking 4. putSyscallArgsIntoGuestState 5. do_syscall_for_client or non-blocking 6. VG_(do_syscall) What has changed ---------------- struct SyscallArgs now like FreeBSD, stores both the canonical_sysno (which is the final syscall number, never SYS_syscall) and the original_sysno (which can be SYS_syscall). These get set in getSyscallArgsFromGuestState which has changed accordingly. getSyscallArgsFromGuestState has changed to always get the layout coresponding to the canonical layout. This was the cause of the problems with the scalar tests - the arguments were effectively out by one. Many subsequent changes to the scalar test, filter and expected. The scalar test still isn't quite right. __NR_kevent_qos is missing a scalar error from argument 6. That's the one with special case handling because it is a register argument for a normal syscall but a stack argument for syscall SYS_syscall. Diff: --- coregrind/m_syswrap/priv_types_n_macros.h | 6 +- coregrind/m_syswrap/syswrap-darwin.c | 8 +- coregrind/m_syswrap/syswrap-generic.c | 5 + coregrind/m_syswrap/syswrap-main.c | 16 +- memcheck/tests/darwin/Makefile.am | 2 +- memcheck/tests/darwin/filter_scalar | 13 ++ memcheck/tests/darwin/scalar.c | 61 +++--- memcheck/tests/darwin/scalar.stderr.exp | 298 ++++++++------------------- memcheck/tests/darwin/scalar.vgtest | 1 + memcheck/tests/darwin/scalar_nocancel.vgtest | 1 + 10 files changed, 161 insertions(+), 250 deletions(-) diff --git a/coregrind/m_syswrap/priv_types_n_macros.h b/coregrind/m_syswrap/priv_types_n_macros.h index 66a11879e5..6da1cad31d 100644 --- a/coregrind/m_syswrap/priv_types_n_macros.h +++ b/coregrind/m_syswrap/priv_types_n_macros.h @@ -51,7 +51,7 @@ typedef struct SyscallArgs { Word canonical_sysno; -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) /* * This may be the same as canonical_sysno (normal syscalls) * Or it may be __NR_syscall or __NR___syscall @@ -125,7 +125,7 @@ typedef Int s_arg6; Int s_arg7; Int s_arg8; -# elif defined(VGP_amd64_freebsd) +# elif defined(VGP_amd64_freebsd) || defined(VGP_amd64_darwin) Int o_arg1; Int o_arg2; Int o_arg3; @@ -168,7 +168,7 @@ typedef Int s_arg6; Int s_arg7; Int s_arg8; -# elif defined(VGP_amd64_darwin) || defined(VGP_amd64_solaris) +# elif defined(VGP_amd64_solaris) Int o_arg1; Int o_arg2; Int o_arg3; diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 4eec0eb36b..987e7ee0ff 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -2764,7 +2764,7 @@ PRE(fstat_extended) PRE_REG_READ4(int, "fstat_extended", int, fd, struct stat *, buf, void *, fsacl, vki_size_t *, fsacl_size); PRE_MEM_WRITE( "fstat_extended(buf)", ARG2, sizeof(struct vki_stat) ); - if (ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) + if (ARG4 && ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) PRE_MEM_WRITE("fstat_extended(fsacl)", ARG3, *(vki_size_t *)ARG4 ); PRE_MEM_READ( "fstat_extended(fsacl_size)", ARG4, sizeof(vki_size_t) ); } @@ -2785,7 +2785,7 @@ PRE(stat64_extended) void *, fsacl, vki_size_t *, fsacl_size); PRE_MEM_RASCIIZ( "stat64_extended(file_name)", ARG1 ); PRE_MEM_WRITE( "stat64_extended(buf)", ARG2, sizeof(struct vki_stat64) ); - if (ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) + if (ARG4 && ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) PRE_MEM_WRITE("stat64_extended(fsacl)", ARG3, *(vki_size_t *)ARG4 ); PRE_MEM_READ( "stat64_extended(fsacl_size)", ARG4, sizeof(vki_size_t) ); } @@ -2806,7 +2806,7 @@ PRE(lstat64_extended) void *, fsacl, vki_size_t *, fsacl_size); PRE_MEM_RASCIIZ( "lstat64_extended(file_name)", ARG1 ); PRE_MEM_WRITE( "lstat64_extended(buf)", ARG2, sizeof(struct vki_stat64) ); - if (ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) + if (ARG4 && ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) PRE_MEM_WRITE( "lstat64_extended(fsacl)", ARG3, *(vki_size_t *)ARG4 ); PRE_MEM_READ( "lstat64_extended(fsacl_size)", ARG4, sizeof(vki_size_t) ); } @@ -2826,7 +2826,7 @@ PRE(fstat64_extended) PRE_REG_READ4(int, "fstat64_extended", int, fd, struct stat64 *, buf, void *, fsacl, vki_size_t *, fsacl_size); PRE_MEM_WRITE( "fstat64_extended(buf)", ARG2, sizeof(struct vki_stat64) ); - if (ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) + if (ARG4 && ML_(safe_to_deref)( (void*)ARG4, sizeof(vki_size_t) )) PRE_MEM_WRITE("fstat64_extended(fsacl)", ARG3, *(vki_size_t *)ARG4 ); PRE_MEM_READ( "fstat64_extended(fsacl_size)", ARG4, sizeof(vki_size_t) ); } diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 6050f5b65d..2c113c69cf 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -5030,8 +5030,13 @@ PRE(sys_poll) *flags |= SfMayBlock; PRINT("sys_poll ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %ld )\n", ARG1, ARG2, SARG3); +#if defined(VGO_darwin) + PRE_REG_READ3(long, "poll", + struct vki_pollfd *, ufds, unsigned int, nfds, int, timeout); +#else PRE_REG_READ3(long, "poll", struct vki_pollfd *, ufds, unsigned int, nfds, long, timeout); +#endif for (i = 0; i < ARG2; i++) { PRE_MEM_READ( "poll(ufds.fd)", diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 49f841ff74..02993a58f9 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -460,7 +460,7 @@ static Bool eq_SyscallArgs ( SyscallArgs* a1, SyscallArgs* a2 ) { return a1->canonical_sysno == a2->canonical_sysno -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) && a1->original_sysno == a2->original_sysno #endif && a1->arg1 == a2->arg1 @@ -790,6 +790,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, VG_SYSNUM_STRING(canonical->canonical_sysno)); } + canonical->original_sysno = gst->guest_EAX; + // Here we determine what kind of syscall it was by looking at the // interrupt kind, and then encode the syscall number using the 64-bit // encoding for Valgrind's internal use. @@ -869,6 +871,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, VG_SYSNUM_STRING(canonical->canonical_sysno)); } + canonical->original_sysno = gst->guest_RAX; + // no canonical->canonical_sysno adjustment needed #elif defined(VGP_s390x_linux) @@ -1865,7 +1869,7 @@ void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout, /*IN*/Bool syscall_s layout->s_arg7 = sizeof(UWord) * 7; layout->s_arg8 = sizeof(UWord) * 8; -#elif defined(VGP_amd64_freebsd) +#elif defined(VGP_amd64_freebsd) || defined(VGP_amd64_darwin) if (syscall_syscall) { layout->o_sysno = OFFSET_amd64_RDI; @@ -2292,7 +2296,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Save the syscall number in the thread state in case the syscall is interrupted by a signal. */ canonical_sysno = sci->orig_args.canonical_sysno; -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) original_sysno = sci->orig_args.original_sysno; #else /* @@ -2347,6 +2351,12 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) original_sysno == __NR___syscall) { syscall_syscall = True; } +#endif +#if defined(VGP_amd64_darwin) + if (original_sysno == __NR_syscall) { + syscall_syscall = True; + } + original_sysno = canonical_sysno; #endif getSyscallArgLayout( &layout, syscall_syscall ); diff --git a/memcheck/tests/darwin/Makefile.am b/memcheck/tests/darwin/Makefile.am index 0810accdc0..e43d4af795 100644 --- a/memcheck/tests/darwin/Makefile.am +++ b/memcheck/tests/darwin/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/Makefile.tool-tests.am -dist_noinst_SCRIPTS = filter_stderr +dist_noinst_SCRIPTS = filter_stderr filter_scalar noinst_HEADERS = scalar.h diff --git a/memcheck/tests/darwin/filter_scalar b/memcheck/tests/darwin/filter_scalar new file mode 100755 index 0000000000..13972326a0 --- /dev/null +++ b/memcheck/tests/darwin/filter_scalar @@ -0,0 +1,13 @@ +#! /bin/sh + +sed '/in frame #., created by/d' | + +./filter_stderr "$@" | + +sed '/by 0x.*: main.*scalar.*\.c.*/d' | + +# get rid of error limit message +# but there is still an added extra blank line before +sed '/More than 100 errors detected. Subsequent errors/d' | +sed '/will still be recorded, but in less detail than before./d' + diff --git a/memcheck/tests/darwin/scalar.c b/memcheck/tests/darwin/scalar.c index 225615523b..dd53145d2c 100644 --- a/memcheck/tests/darwin/scalar.c +++ b/memcheck/tests/darwin/scalar.c @@ -4,6 +4,7 @@ #include <sched.h> #include <signal.h> #include <sys/shm.h> +#include <sys/socket.h> // See memcheck/tests/x86-linux/scalar.c for an explanation of what this test // is doing. @@ -210,7 +211,7 @@ int main(void) // __NR_bind 104 GO(__NR_setsockopt, 105, "5s 1m"); - SY(__NR_setsockopt, x0, x0, x0, x0+1, x0+1); FAIL; + SY(__NR_setsockopt, x0, x0, x0, px+x0, sizeof(socklen_t)+x0); FAIL; // __NR_listen 106 @@ -236,10 +237,11 @@ int main(void) // __NR_gettimeofday 116 // __NR_getrusage 117 - // Nb: there's no "getsockopt(optlen) points to unaddressable byte(s)"; - // difficult to get with arg4 being checked with buf_and_len_pre_check. - GO(__NR_getsockopt, 118, "5s 1m"); - SY(__NR_getsockopt, x0, x0, x0, x0+1, x0+&px[1]); FAIL; + socklen_t *len = malloc(sizeof(socklen_t)); + *len = 2*sizeof(long)+x0; + free(len); + GO(__NR_getsockopt, 118, "5s 2m"); + SY(__NR_getsockopt, x0, x0, x0, x0+1, len+x0); FAIL; GO_UNIMP(119, "old resuba"); @@ -505,10 +507,12 @@ int main(void) // requires the 4th arg to point to a valid value. SY(__NR_lstat_extended, 0, 0, 0, &one); FAIL; - GO(__NR_fstat_extended, 280, "4s 3m"); + GO(__NR_fstat_extended, 280, "4s 2m"); SY(__NR_fstat_extended, x0, x0, x0, x0); FAIL; + // Go again to get a complaint about where the 3rd arg points; it // requires the 4th arg to point to a valid value. + GO(__NR_fstat_extended, 280, "0s 2m"); SY(__NR_fstat_extended, 0, 0, 0, &one); FAIL; } @@ -611,20 +615,26 @@ int main(void) size_t one = 1; GO(__NR_stat64_extended, 341, "4s 4m"); SY(__NR_stat64_extended, x0, x0, x0, x0); FAIL; + // Go again to get a complaint about where the 3rd arg points; it // requires the 4th arg to point to a valid value. + GO(__NR_stat64_extended, 341, "0s 3m"); SY(__NR_stat64_extended, 0, 0, 0, &one); FAIL; GO(__NR_lstat64_extended, 342, "4s 4m"); SY(__NR_lstat64_extended, x0, x0, x0, x0); FAIL; + // Go again to get a complaint about where the 3rd arg points; it // requires the 4th arg to point to a valid value. + GO(__NR_lstat64_extended, 342, "0s 3m"); SY(__NR_lstat64_extended, 0, 0, 0, &one); FAIL; - GO(__NR_fstat64_extended, 342, "4s 3m"); + GO(__NR_fstat64_extended, 342, "4s 2m"); SY(__NR_fstat64_extended, x0, x0, x0, x0); FAIL; + // Go again to get a complaint about where the 3rd arg points; it // requires the 4th arg to point to a valid value. + GO(__NR_fstat64_extended, 342, "0s 2m"); SY(__NR_fstat64_extended, 0, 0, 0, &one); FAIL; } @@ -662,13 +672,10 @@ int main(void) GO_UNIMP(369-373, "unused"); -#if DARWIN_VERS >= DARWIN_10_11 - { - long args[8] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1, x0+1, x0+1, x0+1 }; - GO(__NR_kevent_qos, 374, "1s 8m"); - SY(__NR_kevent_qos, args+x0); FAIL; - } -#endif /* DARWIN_VERS >= DARWIN_10_11 */ +#if defined(__NR_kevent_qos) + GO(__NR_kevent_qos, 374, "8s 4m"); + SY(__NR_kevent_qos, x0+8, x0+0xffffffee, x0+1, x0+1, x0+1, x0+1, x0+1, x0+1); FAIL; +#endif GO_UNIMP(375-379, "unused"); @@ -687,15 +694,11 @@ int main(void) // __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 +#if defined(__NR_pselect) + GO(__NR_pselect, 394, "5s 4m"); + SY(__NR_pselect, x0+8, x0+0xffffffee, x0+1, x0+1, x0+1, x0+1); FAIL; +#endif // __NR_setlcid 394 -#endif /* DARWIN_VERS >= DARWIN_10_11 */ // __NR_getlcid 395 @@ -1005,11 +1008,8 @@ int main(void) SY(__NR_setgroups, x0+1, x0+1); FAIL; // __NR_select 82 - { - long args[5] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1 }; - GO(__NR_select, "1s 5m"); - SY(__NR_select, args+x0); FAIL; - } + GO(__NR_select, "5s ?m"); + SY(__NR_select, x0+8, x0+0xffffffee, x0+1, x0+1, x0+1); FAIL; // __NR_symlink 83 GO(__NR_symlink, "2s 2m"); @@ -1040,11 +1040,8 @@ int main(void) // (superseded, not handled by Valgrind) // __NR_mmap 90 - { - long args[6] = { x0, x0, x0, x0, x0-1, x0 }; - GO(__NR_mmap, "1s 1m"); - SY(__NR_mmap, args+x0); FAIL; - } + GO(__NR_mmap, "6s 1m"); + SY(__NR_mmap, x0, x0, x0, x0, x0-1, x0); FAIL; // __NR_munmap 91 GO(__NR_munmap, "2s 0m"); diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index 9212c8fcc8..a336413601 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -9,23 +9,18 @@ x2000003(3): __NR_read 1+3s 1m ----------------------------------------------------- Syscall param (syscallno) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:31) Syscall param read(fd) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:31) Syscall param read(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:31) Syscall param read(count) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:31) Syscall param read(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:31) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -33,19 +28,15 @@ x2000004(4): __NR_write 3s 1m ----------------------------------------------------- Syscall param write(fd) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:34) Syscall param write(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:34) Syscall param write(count) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:34) Syscall param write(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:34) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -53,15 +44,12 @@ x2000005(5): __NR_open (2-args) 2s 1m ----------------------------------------------------- Syscall param open(filename) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:38) Syscall param open(flags) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:38) Syscall param open(filename) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:38) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -81,28 +69,22 @@ x2000007(7): __NR_wait4 4s 2m ----------------------------------------------------- Syscall param wait4(pid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:49) Syscall param wait4(status) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:49) Syscall param wait4(options) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:49) Syscall param wait4(rusage) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:49) Syscall param wait4(status) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:49) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param wait4(rusage) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:49) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -113,20 +95,16 @@ x2000009(9): __NR_link 2s 2m ----------------------------------------------------- Syscall param link(oldpath) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:54) Syscall param link(newpath) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:54) Syscall param link(oldpath) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:54) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param link(newpath) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:54) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -134,11 +112,9 @@ x200000a(10): __NR_unlink 1s 1m ----------------------------------------------------- Syscall param unlink(pathname) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:57) Syscall param unlink(pathname) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:57) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -149,11 +125,9 @@ x200000c(12): __NR_chdir 1s 1m ----------------------------------------------------- Syscall param chdir(path) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:62) Syscall param chdir(path) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:62) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -167,19 +141,15 @@ x200000e(14): __NR_mknod 3s 1m ----------------------------------------------------- Syscall param mknod(pathname) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:68) Syscall param mknod(mode) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:68) Syscall param mknod(dev) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:68) Syscall param mknod(pathname) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:68) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -187,15 +157,12 @@ x200000f(15): __NR_chmod 2s 1m ----------------------------------------------------- Syscall param chmod(path) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:71) Syscall param chmod(mode) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:71) Syscall param chmod(path) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:71) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -203,19 +170,15 @@ x2000010(16): __NR_chown 3s 1m ----------------------------------------------------- Syscall param chown(path) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:74) Syscall param chown(owner) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:74) Syscall param chown(group) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:74) Syscall param chown(path) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:74) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -226,19 +189,15 @@ x2000012(18): __NR_getfsstat 3s 1m ----------------------------------------------------- Syscall param getfsstat(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:79) Syscall param getfsstat(bufsize) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:79) Syscall param getfsstat(flags) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:79) Syscall param getfsstat(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:79) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -297,19 +256,15 @@ x200004e(78): __NR_mincore 3s 1m ----------------------------------------------------- Syscall param mincore(start) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:165) Syscall param mincore(length) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:165) Syscall param mincore(vec) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:165) Syscall param mincore(vec) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:165) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -317,11 +272,9 @@ x2000052(82): __NR_setpgid 2s 0m ----------------------------------------------------- Syscall param setpgid(pid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:172) Syscall param setpgid(pgid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:172) ----------------------------------------------------- (78): old wait @@ -355,28 +308,23 @@ x2000069(105): __NR_setsockopt 5s 1m ----------------------------------------------------- Syscall param setsockopt(s) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:213) Syscall param setsockopt(level) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:213) Syscall param setsockopt(optname) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:213) Syscall param setsockopt(optval) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:213) Syscall param setsockopt(optlen) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:213) -Syscall param socketcall.setsockopt(optval) points to unaddressable byte(s) +Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s) ... - by 0x........: main (scalar.c:213) - Address 0x........ is not stack'd, malloc'd or (recently) free'd + Address 0x........ is 0 bytes inside a block of size 8 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) ----------------------------------------------------- (107): old vtimes @@ -406,34 +354,36 @@ x200006f(111): __NR_sigsuspend ignore (115): old vtrace ----------------------------------------------------- ----------------------------------------------------- -x2000076(118): __NR_getsockopt 5s 1m +x2000076(118): __NR_getsockopt 5s 2m ----------------------------------------------------- Syscall param getsockopt(s) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:242) Syscall param getsockopt(level) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:242) Syscall param getsockopt(optname) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:242) Syscall param getsockopt(optval) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:242) Syscall param getsockopt(optlen) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:242) Syscall param socketcall.getsockopt(optlen) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:242) - Address 0x........ is 0 bytes after a block of size 8 alloc'd + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + Block was alloc'd at at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (scalar.c:14) + +Syscall param socketcall.getsockopt(optval) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Conditional jump or move depends on uninitialised value(s) + ... ----------------------------------------------------- (119): old resuba @@ -450,16 +400,16 @@ Syscall param socketcall.getsockopt(optlen) points to unaddressable byte(s) ----------------------------------------------------- x2000084(132): __NR_mkfifo 2s 1m ----------------------------------------------------- +Syscall param mkfifo(path) contains uninitialised byte(s) + ... + Syscall param mkfifo(mode) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:265) Syscall param mkfifo(path) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:265) Address 0x........ is not stack'd, malloc'd or (recently) free'd ------------------------------------------------------ ----------------------------------------------------- (141): old getpeername ----------------------------------------------------- @@ -504,28 +454,22 @@ x20000a7(167): __NR_mount 4s 2m ----------------------------------------------------- Syscall param mount(type) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:323) Syscall param mount(dir) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:323) Syscall param mount(flags) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:323) Syscall param mount(data) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:323) Syscall param mount(type) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:323) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param mount(dir) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:323) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -536,23 +480,18 @@ x20000a9(169): __NR_csops 4s 1m ----------------------------------------------------- Syscall param csops(pid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:328) Syscall param csops(ops) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:328) Syscall param csops(useraddr) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:328) Syscall param csops(usersize) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:328) Syscall param csops(useraddr) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:328) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -587,24 +526,19 @@ x20000df(223): __NR_exchangedata 3s 2m ----------------------------------------------------- Syscall param exchangedata(path1) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:398) Syscall param exchangedata(path2) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:398) Syscall param exchangedata(options) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:398) Syscall param exchangedata(path1) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:398) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param exchangedata(path2) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:398) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -624,34 +558,27 @@ x2000106(262): __NR_shmat 3s 0m ----------------------------------------------------- Syscall param shmat(shmid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:447) Syscall param shmat(shmaddr) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:447) Syscall param shmat(shmflg) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:447) ----------------------------------------------------- x2000107(263): __NR_shmctl 3s 1m ----------------------------------------------------- Syscall param shmctl(shmid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:450) Syscall param shmctl(cmd) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:450) Syscall param shmctl(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:450) Syscall param shmctl(IPC_STAT, buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:450) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -665,30 +592,24 @@ x2000109(265): __NR_shmget 3s 0m ----------------------------------------------------- Syscall param shmget(key) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:456) Syscall param shmget(size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:456) Syscall param shmget(shmflg) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:456) ----------------------------------------------------- x200010c(268): __NR_sem_open 2s 1m ----------------------------------------------------- Syscall param sem_open(name) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:462) Syscall param sem_open(oflag) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:462) Syscall param sem_open(name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:462) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -709,13 +630,12 @@ 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) ... - by 0x........: main (scalar.c:472) Syscall param sem_unlink(name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:472) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -741,19 +661,15 @@ x2000113(275): __NR_sem_init 3s 1m ----------------------------------------------------- Syscall param sem_init(sem) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:486) Syscall param sem_init(pshared) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:486) Syscall param sem_init(value) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:486) Syscall param sem_init(sem) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:486) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -761,11 +677,9 @@ x2000114(276): __NR_sem_destroy 1s 1m ----------------------------------------------------- Syscall param sem_destroy(sem) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:489) Syscall param sem_destroy(sem) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:489) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -773,48 +687,38 @@ x2000117(279): __NR_stat_extended 4s 4m ----------------------------------------------------- Syscall param stat_extended(file_name) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:497) Syscall param stat_extended(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:497) Syscall param stat_extended(fsacl) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:497) Syscall param stat_extended(fsacl_size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:497) Syscall param stat_extended(file_name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:497) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:497) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat_extended(fsacl_size) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:497) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat_extended(file_name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:500) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:500) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat_extended(fsacl) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:500) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -822,97 +726,72 @@ x2000118(280): __NR_lstat_extended 4s 4m ----------------------------------------------------- Syscall param lstat_extended(file_name) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:503) Syscall param lstat_extended(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:503) Syscall param lstat_extended(fsacl) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:503) Syscall param lstat_extended(fsacl_size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:503) Syscall param lstat_extended(file_name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:503) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:503) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat_extended(fsacl_size) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:503) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat_extended(file_name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:506) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:506) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat_extended(fsacl) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:506) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- -x2000119(280): __NR_fstat_extended 4s 3m +x2000119(280): __NR_fstat_extended 4s 2m ----------------------------------------------------- Syscall param fstat_extended(fd) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:509) Syscall param fstat_extended(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:509) Syscall param fstat_extended(fsacl) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:509) Syscall param fstat_extended(fsacl_size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:509) - -Syscall param fstat_extended(fd) points to unaddressable byte(s) - ... - by 0x........: main (scalar.c:509) - Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param fstat_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:509) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param fstat_extended(fsacl_size) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:509) - Address 0x........ is not stack'd, malloc'd or (recently) free'd - -Syscall param fstat_extended(fd) points to unaddressable byte(s) - ... - by 0x........: main (scalar.c:512) Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- +x2000119(280): __NR_fstat_extended 0s 2m +----------------------------------------------------- Syscall param fstat_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:512) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param fstat_extended(fsacl) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:512) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -920,23 +799,18 @@ x200011c(284):__NR_access_extended 4s 1m ----------------------------------------------------- Syscall param access_extended(entries) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:521) Syscall param access_extended(size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:521) Syscall param access_extended(results) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:521) Syscall param access_extended(uid) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:521) Syscall param access_extended(entries) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:521) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -965,19 +839,15 @@ x200013b(315): __NR_aio_suspend 1s 0m ----------------------------------------------------- Syscall param aio_suspend(aiocbp) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:563) Syscall param aio_suspend(nent) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:563) Syscall param aio_suspend(timeout) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:563) Syscall param aio_suspend(list) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:563) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -991,11 +861,9 @@ x200013e(318): __NR_aio_read 1s 1m ----------------------------------------------------- Syscall param aio_read(aiocbp) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:571) Syscall param aio_read(aiocbp) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:571) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -1003,11 +871,9 @@ x200013f(319): __NR_aio_write 1s 1m ----------------------------------------------------- Syscall param aio_write(aiocbp) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:574) Syscall param aio_write(aiocbp) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:574) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -1021,22 +887,21 @@ x2000148(328): __NR___pthread_kill 2s 0m ----------------------------------------------------- Syscall param __pthread_kill(thread) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:590) Syscall param __pthread_kill(sig) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:590) ----------------------------------------------------- x2000149(329):__NR___pthread_sigmask 3s 0m ----------------------------------------------------- +Syscall param __pthread_sigmask(how) contains uninitialised byte(s) + ... + Syscall param __pthread_sigmask(set) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:593) Syscall param __pthread_sigmask(oldset) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:593) ----------------------------------------------------- (335): old utrace @@ -1046,38 +911,41 @@ x2000155(341):__NR_stat64_extended 4s 4m ----------------------------------------------------- Syscall param stat64_extended(file_name) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:613) Syscall param stat64_extended(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:613) Syscall param stat64_extended(fsacl) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:613) Syscall param stat64_extended(fsacl_size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:613) Syscall param stat64_extended(file_name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:613) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat64_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:613) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat64_extended(fsacl_size) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:613) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +----------------------------------------------------- +x2000155(341):__NR_stat64_extended 0s 3m +----------------------------------------------------- +Syscall param stat64_extended(file_name) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param stat64_extended(buf) points to unaddressable byte(s) + ... Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param stat64_extended(fsacl) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:616) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -1085,72 +953,75 @@ x2000156(342):__NR_lstat64_extended 4s 4m ----------------------------------------------------- Syscall param lstat64_extended(file_name) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:619) Syscall param lstat64_extended(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:619) Syscall param lstat64_extended(fsacl) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:619) Syscall param lstat64_extended(fsacl_size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:619) Syscall param lstat64_extended(file_name) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:619) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat64_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:619) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat64_extended(fsacl_size) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:619) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +----------------------------------------------------- +x2000156(342):__NR_lstat64_extended 0s 3m +----------------------------------------------------- +Syscall param lstat64_extended(file_name) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param lstat64_extended(buf) points to unaddressable byte(s) + ... Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param lstat64_extended(fsacl) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:622) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- -x2000157(342):__NR_fstat64_extended 4s 3m +x2000157(342):__NR_fstat64_extended 4s 2m ----------------------------------------------------- Syscall param fstat64_extended(fd) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:625) Syscall param fstat64_extended(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:625) Syscall param fstat64_extended(fsacl) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:625) Syscall param fstat64_extended(fsacl_size) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:625) Syscall param fstat64_extended(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:625) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param fstat64_extended(fsacl_size) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:625) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +----------------------------------------------------- +x2000157(342):__NR_fstat64_extended 0s 2m +----------------------------------------------------- +Syscall param fstat64_extended(buf) points to unaddressable byte(s) + ... Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param fstat64_extended(fsacl) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:628) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- @@ -1158,82 +1029,95 @@ x200015b(347): __NR_getfsstat64 3s 1m ----------------------------------------------------- Syscall param getfsstat64(buf) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:637) Syscall param getfsstat64(bufsize) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:637) Syscall param getfsstat64(flags) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:637) Syscall param getfsstat64(buf) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:637) Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- (369-373): unused ----------------------------------------------------- ----------------------------------------------------- -x2000176(374): __NR_kevent_qos 1s 8m +x2000176(374): __NR_kevent_qos 8s 4m ----------------------------------------------------- +Syscall param kevent_qos(kq) contains uninitialised byte(s) + ... + Syscall param kevent_qos(changelist) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:669) Syscall param kevent_qos(nchanges) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:669) + +Syscall param kevent_qos(eventlist) contains uninitialised byte(s) + ... + +Syscall param kevent_qos(nevents) contains uninitialised byte(s) + ... Syscall param kevent_qos(data_available) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:669) Syscall param kevent_qos(flags) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:669) -Syscall param kevent_qos(changelist) points to uninitialised byte(s) +Syscall param kevent_qos(changelist) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:669) - Address 0x........ is on thread 1's stack - in frame #1, created by main (scalar.c:12) + Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param kevent_qos(eventlist) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:669) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param kevent_qos(data_out) points to unaddressable byte(s) + ... Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- (375-379): unused ----------------------------------------------------- ----------------------------------------------------- -x200018a(394): __NR_pselect 1s 6m +x200018a(394): __NR_pselect 5s 4m ----------------------------------------------------- +Syscall param pselect(n) contains uninitialised byte(s) + ... + Syscall param pselect(readfds) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:694) Syscall param pselect(writefds) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:694) -Syscall param pselect(readfds) points to uninitialised byte(s) +Syscall param pselect(exceptfds) contains uninitialised byte(s) + ... + +Syscall param pselect(timeout) contains uninitialised byte(s) ... - by 0x........: main (scalar.c:694) - Address 0x........ is on thread 1's stack - in frame #1, created by main (scalar.c:12) + +Syscall param pselect(readfds) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param pselect(writefds) points to unaddressable byte(s) ... - by 0x........: main (scalar.c:694) 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:694) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param pselect(timeout) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param pselect(sigmask) points to unaddressable byte(s) + ... Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------------------------------------------------- diff --git a/memcheck/tests/darwin/scalar.vgtest b/memcheck/tests/darwin/scalar.vgtest index 897d9e73c2..2e10386373 100644 --- a/memcheck/tests/darwin/scalar.vgtest +++ b/memcheck/tests/darwin/scalar.vgtest @@ -1,3 +1,4 @@ prog: scalar vgopts: -q --error-limit=no args: < scalar.c +stderr_filter: filter_scalar diff --git a/memcheck/tests/darwin/scalar_nocancel.vgtest b/memcheck/tests/darwin/scalar_nocancel.vgtest index 788757263e..9ad0aa0938 100644 --- a/memcheck/tests/darwin/scalar_nocancel.vgtest +++ b/memcheck/tests/darwin/scalar_nocancel.vgtest @@ -1,3 +1,4 @@ prog: scalar_nocancel vgopts: -q --error-limit=no args: < scalar_nocancel.c +stderr_filter: filter_scalar |
|
From: Paul F. <pa...@so...> - 2025-11-09 08:31:20
|
https://sourceware.org/cgit/valgrind/commit/?id=f1ae846a7feeb4f48f904dd074f490cd96ad1e1b commit f1ae846a7feeb4f48f904dd074f490cd96ad1e1b Author: Paul Floyd <pj...@wa...> Date: Sun Nov 9 09:29:17 2025 +0100 FreeBSD regtest: getsockopt and setsockopt scalar tests were wrong getsockopt was miscopied as setsockopt and the memory checks weere not good. Diff: --- coregrind/m_syswrap/syswrap-freebsd.c | 2 +- memcheck/tests/freebsd/scalar.c | 17 ++++++++++++---- memcheck/tests/freebsd/scalar.stderr.exp | 29 +++++++++++++++++++++------- memcheck/tests/freebsd/scalar.stderr.exp-x86 | 29 +++++++++++++++++++++------- 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index dce26ba915..c2fd35d2b1 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -1510,7 +1510,7 @@ PRE(sys_getsockopt) PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4,ARG5); PRE_REG_READ5(int, "getsockopt", int, s, int, level, int, optname, - void *, optval, int, *optlen); + void *, optval, vki_socklen_t, *optlen); if (optval_p != (Addr)NULL) { ML_(buf_and_len_pre_check) ( tid, optval_p, optlen_p, "getsockopt(optval)", diff --git a/memcheck/tests/freebsd/scalar.c b/memcheck/tests/freebsd/scalar.c index acb4b662e7..b4d7a46d13 100644 --- a/memcheck/tests/freebsd/scalar.c +++ b/memcheck/tests/freebsd/scalar.c @@ -449,8 +449,8 @@ int main(void) SY(SYS_bind, x0, x0, x0); FAIL; /* SYS_setsockopt 105 */ - GO(SYS_setsockopt, "5s 0m"); - SY(SYS_setsockopt, x0, x0, x0, x0, x0); FAIL; + GO(SYS_setsockopt, "5s 1m"); + SY(SYS_setsockopt, x0, x0, x0, px+x0, sizeof(socklen_t)+x0); FAIL; /* SYS_listen 106 */ GO(SYS_listen, "2s 0m"); @@ -482,9 +482,18 @@ int main(void) GO(SYS_getrusage, "2s 1m"); SY(SYS_getrusage, x0, x0); FAIL; + socklen_t *len = malloc(sizeof(socklen_t)); + *len = 2*sizeof(long)+x0; + free(len); + /* + * Should be 2m but it is hard to trigger an optval + * error in the scalar, len needs to be safe to deref + * and the syscall needs to succeed to trigger a write + * error to optval + */ /* SYS_getsockopt 118 */ - GO(SYS_setsockopt, "5s 1m"); - SY(SYS_setsockopt, x0, x0, x0, x0, x0); FAIL; + GO(SYS_getsockopt, "5s 1m"); + SY(SYS_getsockopt, x0, x0, x0, px+x0, len+x0); FAIL; /* unimpl resuba 119 */ diff --git a/memcheck/tests/freebsd/scalar.stderr.exp b/memcheck/tests/freebsd/scalar.stderr.exp index 2acb864e73..449075f3e0 100644 --- a/memcheck/tests/freebsd/scalar.stderr.exp +++ b/memcheck/tests/freebsd/scalar.stderr.exp @@ -856,7 +856,7 @@ Syscall param bind(addrlen) contains uninitialised byte(s) ... --------------------------------------------------------- -105: SYS_setsockopt 5s 0m +105: SYS_setsockopt 5s 1m --------------------------------------------------------- Syscall param setsockopt(s) contains uninitialised byte(s) ... @@ -873,6 +873,12 @@ Syscall param setsockopt(optval) contains uninitialised byte(s) Syscall param setsockopt(optlen) contains uninitialised byte(s) ... +Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s) + ... + Address 0x........ is 0 bytes inside a block of size 16 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + ... + --------------------------------------------------------- 106: SYS_listen 2s 0m --------------------------------------------------------- @@ -913,21 +919,30 @@ Syscall param getrusage(usage) points to unaddressable byte(s) Address 0x........ is not stack'd, malloc'd or (recently) free'd --------------------------------------------------------- -105: SYS_setsockopt 5s 1m +118: SYS_getsockopt 5s 1m --------------------------------------------------------- -Syscall param setsockopt(s) contains uninitialised byte(s) +Syscall param getsockopt(s) contains uninitialised byte(s) ... -Syscall param setsockopt(level) contains uninitialised byte(s) +Syscall param getsockopt(level) contains uninitialised byte(s) ... -Syscall param setsockopt(optname) contains uninitialised byte(s) +Syscall param getsockopt(optname) contains uninitialised byte(s) ... -Syscall param setsockopt(optval) contains uninitialised byte(s) +Syscall param getsockopt(optval) contains uninitialised byte(s) ... -Syscall param setsockopt(optlen) contains uninitialised byte(s) +Syscall param getsockopt(*optlen) contains uninitialised byte(s) + ... + +Syscall param getsockopt(optlen) points to unaddressable byte(s) + ... + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + ... + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) ... --------------------------------------------------------- diff --git a/memcheck/tests/freebsd/scalar.stderr.exp-x86 b/memcheck/tests/freebsd/scalar.stderr.exp-x86 index 957ffb2058..e7e2ce0a6b 100644 --- a/memcheck/tests/freebsd/scalar.stderr.exp-x86 +++ b/memcheck/tests/freebsd/scalar.stderr.exp-x86 @@ -856,7 +856,7 @@ Syscall param bind(addrlen) contains uninitialised byte(s) ... --------------------------------------------------------- -105: SYS_setsockopt 5s 0m +105: SYS_setsockopt 5s 1m --------------------------------------------------------- Syscall param setsockopt(s) contains uninitialised byte(s) ... @@ -873,6 +873,12 @@ Syscall param setsockopt(optval) contains uninitialised byte(s) Syscall param setsockopt(optlen) contains uninitialised byte(s) ... +Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s) + ... + Address 0x........ is 0 bytes inside a block of size 16 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + ... + --------------------------------------------------------- 106: SYS_listen 2s 0m --------------------------------------------------------- @@ -913,21 +919,30 @@ Syscall param getrusage(usage) points to unaddressable byte(s) Address 0x........ is not stack'd, malloc'd or (recently) free'd --------------------------------------------------------- -105: SYS_setsockopt 5s 1m +118: SYS_getsockopt 5s 1m --------------------------------------------------------- -Syscall param setsockopt(s) contains uninitialised byte(s) +Syscall param getsockopt(s) contains uninitialised byte(s) ... -Syscall param setsockopt(level) contains uninitialised byte(s) +Syscall param getsockopt(level) contains uninitialised byte(s) ... -Syscall param setsockopt(optname) contains uninitialised byte(s) +Syscall param getsockopt(optname) contains uninitialised byte(s) ... -Syscall param setsockopt(optval) contains uninitialised byte(s) +Syscall param getsockopt(optval) contains uninitialised byte(s) ... -Syscall param setsockopt(optlen) contains uninitialised byte(s) +Syscall param getsockopt(*optlen) contains uninitialised byte(s) + ... + +Syscall param getsockopt(optlen) points to unaddressable byte(s) + ... + Address 0x........ is 0 bytes inside a block of size 4 free'd + at 0x........: free (vg_replace_malloc.c:...) + ... + Block was alloc'd at + at 0x........: malloc (vg_replace_malloc.c:...) ... --------------------------------------------------------- |
|
From: Paul F. <pa...@so...> - 2025-11-07 19:43:11
|
https://sourceware.org/cgit/valgrind/commit/?id=b3177c0d27189c5ef772b52b65080b52ebf64895 commit b3177c0d27189c5ef772b52b65080b52ebf64895 Author: Paul Floyd <pj...@wa...> Date: Fri Nov 7 20:40:21 2025 +0100 FreeBSD regtest: add comments for a sched_setaffinity equivalent Trying to get a fix for nlvgdbsigqueue flakiness. FreeBSD has cpuset_setaffinity which is similar to sched_setaffinity. Howeever, it needs privileges in order to be used. So I've just put the code there in a comment. Diff: --- gdbserver_tests/sleepers.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gdbserver_tests/sleepers.c b/gdbserver_tests/sleepers.c index 51d197a8e7..819536ca19 100644 --- a/gdbserver_tests/sleepers.c +++ b/gdbserver_tests/sleepers.c @@ -15,7 +15,7 @@ static int sleepms = 1000; // in each loop, will sleep "sleepms" milliseconds static int burn = 0; // after each sleep, will burn cpu in a tight 'burn' loop static void setup_sigusr_handler(void); // sigusr1 and 2 sigaction setup. -static pid_t gettid_sys() +static pid_t gettid_sys(void) { #ifdef __NR_gettid return syscall(__NR_gettid); @@ -32,7 +32,7 @@ void whoami(char *msg) } -static void do_burn () +static void do_burn(void) { int i; int loopnr = 0; @@ -124,13 +124,29 @@ static void wait_ready(void) // threads wanting to burn cpu. static void setaffinity(void) { -#ifdef VGO_linux +#if defined(VGO_linux) cpu_set_t single_cpu; CPU_ZERO(&single_cpu); CPU_SET(1, &single_cpu); (void) sched_setaffinity(0, sizeof(single_cpu), &single_cpu); #endif - // GDBTD: equivalent for Darwin ? + +#if defined(VGO_freebsd) + /* + * FreeBSD has something similar but it needs privileges + * somethinmg like this + */ + /* + cpuset_t cpuset; + CPU_ZERO(&cpuset); + CPU_SET(0, &cpuset); + if (cpuset_setaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, sizeof(cpuset), &cpuset) != 0) { + perror("cpuset_setaffinity"); + } + */ +#endif + + // FIXME: equivalent for Darwin and Solaris ? } int main (int argc, char *argv[]) |
|
From: Paul F. <pa...@so...> - 2025-11-07 06:24:19
|
https://sourceware.org/cgit/valgrind/commit/?id=e3001a5226b122fe031e73ac3d165cb7a370bda2 commit e3001a5226b122fe031e73ac3d165cb7a370bda2 Author: Paul Floyd <pj...@wa...> Date: Thu Nov 6 19:40:15 2025 +0100 Bug 511713 - Refactor syscall argument handling Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_types_n_macros.h | 14 +- coregrind/m_syswrap/syswrap-linux.c | 4 +- coregrind/m_syswrap/syswrap-main.c | 289 ++++++++++++++---------------- coregrind/m_syswrap/syswrap-xen.c | 2 +- include/vki/vki-scnums-freebsd.h | 13 -- 6 files changed, 148 insertions(+), 175 deletions(-) diff --git a/NEWS b/NEWS index 0941034a6d..a52af5119b 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 487055 memcheck/tests/x86-linux/scalar fails running in Docker 511329 Darwin and FreeBSD: Move setting of carry flag out of ML_(do_syscall_for_client_WRK) +511713 Refactor syscall argument handling To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_syswrap/priv_types_n_macros.h b/coregrind/m_syswrap/priv_types_n_macros.h index ff5d6a2de7..66a11879e5 100644 --- a/coregrind/m_syswrap/priv_types_n_macros.h +++ b/coregrind/m_syswrap/priv_types_n_macros.h @@ -50,7 +50,14 @@ /* Arguments for a syscall. */ typedef struct SyscallArgs { - Word sysno; + Word canonical_sysno; +#if defined(VGO_freebsd) + /* + * This may be the same as canonical_sysno (normal syscalls) + * Or it may be __NR_syscall or __NR___syscall + */ + Word original_sysno; +#endif RegWord arg1; RegWord arg2; RegWord arg3; @@ -59,9 +66,6 @@ typedef RegWord arg6; RegWord arg7; RegWord arg8; -#if defined(VGO_freebsd) - Word klass; -#endif } SyscallArgs; @@ -360,7 +364,7 @@ const SyscallTableEntry* ML_(get_freebsd_syscall_entry)( UInt sysno ); /* Reference to the syscall's arguments -- the ones which the pre-wrapper may have modified, not the original copy. */ -#define SYSNO (arrghs->sysno) +#define SYSNO (arrghs->canonical_sysno) #define ARG1 (arrghs->arg1) #define ARG2 (arrghs->arg2) #define ARG3 (arrghs->arg3) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index e8b200385b..0105fb98f3 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -9577,7 +9577,7 @@ PRE(sys_ioctl) break; VG_(memset)(&harrghs, 0, sizeof(harrghs)); - harrghs.sysno = args->op; + harrghs.canonical_sysno = args->op; harrghs.arg1 = args->arg[0]; harrghs.arg2 = args->arg[1]; harrghs.arg3 = args->arg[2]; @@ -12316,7 +12316,7 @@ POST(sys_ioctl) break; VG_(memset)(&harrghs, 0, sizeof(harrghs)); - harrghs.sysno = args->op; + harrghs.canonical_sysno = args->op; harrghs.arg1 = args->arg[0]; harrghs.arg2 = args->arg[1]; harrghs.arg3 = args->arg[2]; diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 45ece95cbf..49f841ff74 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -359,17 +359,10 @@ void do_syscall_for_client ( Int syscallno, syscall_mask, &saved, sizeof(vki_sigset_t) ); # elif defined(VGO_freebsd) - Word real_syscallno; UChar cflag; VG_(sigemptyset)(&saved); - if (tst->arch.vex.guest_SC_CLASS == VG_FREEBSD_SYSCALL0) - real_syscallno = __NR_syscall; - else if (tst->arch.vex.guest_SC_CLASS == VG_FREEBSD_SYSCALL198) - real_syscallno = __NR___syscall; - else - real_syscallno = syscallno; err = ML_(do_syscall_for_client_WRK)( - real_syscallno, &tst->arch.vex, + syscallno, &tst->arch.vex, syscall_mask, &saved, sizeof(vki_sigset_t), &cflag ); @@ -466,7 +459,10 @@ void do_syscall_for_client ( Int syscallno, static Bool eq_SyscallArgs ( SyscallArgs* a1, SyscallArgs* a2 ) { - return a1->sysno == a2->sysno + return a1->canonical_sysno == a2->canonical_sysno +#if defined(VGO_freebsd) + && a1->original_sysno == a2->original_sysno +#endif && a1->arg1 == a2->arg1 && a1->arg2 == a2->arg2 && a1->arg3 == a2->arg3 @@ -517,7 +513,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, { #if defined(VGP_x86_linux) VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla; - canonical->sysno = gst->guest_EAX; + canonical->canonical_sysno = gst->guest_EAX; canonical->arg1 = gst->guest_EBX; canonical->arg2 = gst->guest_ECX; canonical->arg3 = gst->guest_EDX; @@ -529,7 +525,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_amd64_linux) VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla; - canonical->sysno = gst->guest_RAX; + canonical->canonical_sysno = gst->guest_RAX; canonical->arg1 = gst->guest_RDI; canonical->arg2 = gst->guest_RSI; canonical->arg3 = gst->guest_RDX; @@ -541,7 +537,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_ppc32_linux) VexGuestPPC32State* gst = (VexGuestPPC32State*)gst_vanilla; - canonical->sysno = gst->guest_GPR0; + canonical->canonical_sysno = gst->guest_GPR0; canonical->arg1 = gst->guest_GPR3; canonical->arg2 = gst->guest_GPR4; canonical->arg3 = gst->guest_GPR5; @@ -553,7 +549,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) VexGuestPPC64State* gst = (VexGuestPPC64State*)gst_vanilla; - canonical->sysno = gst->guest_GPR0; + canonical->canonical_sysno = gst->guest_GPR0; canonical->arg1 = gst->guest_GPR3; canonical->arg2 = gst->guest_GPR4; canonical->arg3 = gst->guest_GPR5; @@ -576,20 +572,20 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, // FreeBSD supports different calling conventions switch (gst->guest_EAX) { case __NR_syscall: - canonical->klass = VG_FREEBSD_SYSCALL0; - canonical->sysno = stack[1]; + canonical->canonical_sysno = stack[1]; stack += 1; break; case __NR___syscall: - canonical->klass = VG_FREEBSD_SYSCALL198; - canonical->sysno = stack[1]; + canonical->canonical_sysno = stack[1]; stack += 2; break; default: - canonical->klass = 0; - canonical->sysno = gst->guest_EAX; + canonical->canonical_sysno = gst->guest_EAX; break; } + + canonical->original_sysno = gst->guest_EAX; + // stack[0] is a (fake) return address canonical->arg1 = stack[1]; canonical->arg2 = stack[2]; @@ -604,29 +600,22 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_RSP; - // FreeBSD supports different calling conventions - // @todo PJF this all seems over complicated to me - // SYSCALL_STD is OK but for the other - // two here we overwrite canonical->sysno with - // the final syscall number but then in do_syscall_for_client - // we switch real_syscallno back to __NR_syscall or __NR___syscall switch (gst->guest_RAX) { case __NR_syscall: - canonical->klass = VG_FREEBSD_SYSCALL0; - canonical->sysno = gst->guest_RDI; + canonical->canonical_sysno = gst->guest_RDI; break; case __NR___syscall: - canonical->klass = VG_FREEBSD_SYSCALL198; - canonical->sysno = gst->guest_RDI; + canonical->canonical_sysno = gst->guest_RDI; break; default: - canonical->klass = VG_FREEBSD_SYSCALL_STD; - canonical->sysno = gst->guest_RAX; + canonical->canonical_sysno = gst->guest_RAX; break; } + canonical->original_sysno = gst->guest_RAX; + // stack[0] is a (fake) return address - if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) { + if (gst->guest_RAX == __NR_syscall || gst->guest_RAX == __NR___syscall) { // stack[0] is return address canonical->arg1 = gst->guest_RSI; canonical->arg2 = gst->guest_RDX; @@ -652,19 +641,20 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla; switch (gst->guest_X8) { case __NR_syscall: - canonical->klass = VG_FREEBSD_SYSCALL0; - canonical->sysno = gst->guest_X0; + canonical->canonical_sysno = gst->guest_X0; break; case __NR___syscall: - canonical->klass = VG_FREEBSD_SYSCALL198; - canonical->sysno = gst->guest_X0; + canonical->canonical_sysno = gst->guest_X0; break; default: - canonical->klass = 0; - canonical->sysno = gst->guest_X8; + canonical->canonical_sysno = gst->guest_X8; break; } - if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) { + + canonical->original_sysno = gst->guest_X8; + + if (gst->guest_X8 == __NR_syscall || + gst->guest_X8 == __NR___syscall) { canonical->arg1 = gst->guest_X1; canonical->arg2 = gst->guest_X2; canonical->arg3 = gst->guest_X3; @@ -684,7 +674,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_arm_linux) VexGuestARMState* gst = (VexGuestARMState*)gst_vanilla; - canonical->sysno = gst->guest_R7; + canonical->canonical_sysno = gst->guest_R7; canonical->arg1 = gst->guest_R0; canonical->arg2 = gst->guest_R1; canonical->arg3 = gst->guest_R2; @@ -696,7 +686,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_arm64_linux) VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla; - canonical->sysno = gst->guest_X8; + canonical->canonical_sysno = gst->guest_X8; canonical->arg1 = gst->guest_X0; canonical->arg2 = gst->guest_X1; canonical->arg3 = gst->guest_X2; @@ -708,8 +698,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_mips32_linux) VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla; - canonical->sysno = gst->guest_r2; // v0 - if (canonical->sysno == __NR_exit) { + canonical->canonical_sysno = gst->guest_r2; // v0 + if (canonical->canonical_sysno == __NR_exit) { canonical->arg1 = gst->guest_r4; // a0 canonical->arg2 = 0; canonical->arg3 = 0; @@ -717,7 +707,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, canonical->arg5 = 0; canonical->arg6 = 0; canonical->arg8 = 0; - } else if (canonical->sysno != __NR_syscall) { + } else if (canonical->canonical_sysno != __NR_syscall) { canonical->arg1 = gst->guest_r4; // a0 canonical->arg2 = gst->guest_r5; // a1 canonical->arg3 = gst->guest_r6; // a2 @@ -728,7 +718,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, canonical->arg8 = 0; } else { // Fixme hack handle syscall() - canonical->sysno = gst->guest_r4; // a0 + canonical->canonical_sysno = gst->guest_r4; // a0 canonical->arg1 = gst->guest_r5; // a1 canonical->arg2 = gst->guest_r6; // a2 canonical->arg3 = gst->guest_r7; // a3 @@ -741,7 +731,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_mips64_linux) VexGuestMIPS64State* gst = (VexGuestMIPS64State*)gst_vanilla; - canonical->sysno = gst->guest_r2; // v0 + canonical->canonical_sysno = gst->guest_r2; // v0 canonical->arg1 = gst->guest_r4; // a0 canonical->arg2 = gst->guest_r5; // a1 canonical->arg3 = gst->guest_r6; // a2 @@ -753,7 +743,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_nanomips_linux) VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla; - canonical->sysno = gst->guest_r2; // t4 + canonical->canonical_sysno = gst->guest_r2; // t4 canonical->arg1 = gst->guest_r4; // a0 canonical->arg2 = gst->guest_r5; // a1 canonical->arg3 = gst->guest_r6; // a2 @@ -766,8 +756,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_ESP; // GrP fixme hope syscalls aren't called with really shallow stacks... - canonical->sysno = gst->guest_EAX; - if (canonical->sysno != 0) { + canonical->canonical_sysno = gst->guest_EAX; + if (canonical->canonical_sysno != 0) { // stack[0] is return address canonical->arg1 = stack[1]; canonical->arg2 = stack[2]; @@ -784,8 +774,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, // DDD: the tool can't see that the params have been shifted! Can // lead to incorrect checking, I think, because the PRRAn/PSARn // macros will mention the pre-shifted args. - canonical->sysno = stack[1]; - vg_assert(canonical->sysno != 0); + canonical->canonical_sysno = stack[1]; + vg_assert(canonical->canonical_sysno != 0); canonical->arg1 = stack[2]; canonical->arg2 = stack[3]; canonical->arg3 = stack[4]; @@ -797,7 +787,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, PRINT("SYSCALL[%d,?](0) syscall(%s, ...); please stand by...\n", VG_(getpid)(), /*tid,*/ - VG_SYSNUM_STRING(canonical->sysno)); + VG_SYSNUM_STRING(canonical->canonical_sysno)); } // Here we determine what kind of syscall it was by looking at the @@ -809,29 +799,29 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, switch (trc) { case VEX_TRC_JMP_SYS_INT128: // int $0x80 = Unix, 64-bit result - vg_assert(canonical->sysno >= 0); - canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->sysno); + vg_assert(canonical->canonical_sysno >= 0); + canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->canonical_sysno); break; case VEX_TRC_JMP_SYS_SYSENTER: // syscall = Unix, 32-bit result // OR Mach, 32-bit result - if (canonical->sysno >= 0) { + if (canonical->canonical_sysno >= 0) { // GrP fixme hack: 0xffff == I386_SYSCALL_NUMBER_MASK - canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->sysno + canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(canonical->canonical_sysno & 0xffff); } else { - canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->sysno); + canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->canonical_sysno); } break; case VEX_TRC_JMP_SYS_INT129: // int $0x81 = Mach, 32-bit result - vg_assert(canonical->sysno < 0); - canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->sysno); + vg_assert(canonical->canonical_sysno < 0); + canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MACH(-canonical->canonical_sysno); break; case VEX_TRC_JMP_SYS_INT130: // int $0x82 = mdep, 32-bit result - vg_assert(canonical->sysno >= 0); - canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(canonical->sysno); + vg_assert(canonical->canonical_sysno >= 0); + canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(canonical->canonical_sysno); break; default: vg_assert(0); @@ -845,8 +835,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, vg_assert(trc == VEX_TRC_JMP_SYS_SYSCALL); // GrP fixme hope syscalls aren't called with really shallow stacks... - canonical->sysno = gst->guest_RAX; - if (canonical->sysno != __NR_syscall) { + canonical->canonical_sysno = gst->guest_RAX; + if (canonical->canonical_sysno != __NR_syscall) { // stack[0] is return address canonical->arg1 = gst->guest_RDI; canonical->arg2 = gst->guest_RSI; @@ -863,8 +853,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, // DDD: the tool can't see that the params have been shifted! Can // lead to incorrect checking, I think, because the PRRAn/PSARn // macros will mention the pre-shifted args. - canonical->sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(gst->guest_RDI); - vg_assert(canonical->sysno != __NR_syscall); + canonical->canonical_sysno = VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(gst->guest_RDI); + vg_assert(canonical->canonical_sysno != __NR_syscall); canonical->arg1 = gst->guest_RSI; canonical->arg2 = gst->guest_RDX; canonical->arg3 = gst->guest_R10; // not rcx with syscall insn @@ -876,14 +866,14 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, PRINT("SYSCALL[%d,?](0) syscall(%s, ...); please stand by...\n", VG_(getpid)(), /*tid,*/ - VG_SYSNUM_STRING(canonical->sysno)); + VG_SYSNUM_STRING(canonical->canonical_sysno)); } - // no canonical->sysno adjustment needed + // no canonical->canonical_sysno adjustment needed #elif defined(VGP_s390x_linux) VexGuestS390XState* gst = (VexGuestS390XState*)gst_vanilla; - canonical->sysno = gst->guest_SYSNO; + canonical->canonical_sysno = gst->guest_SYSNO; canonical->arg1 = gst->guest_r2; canonical->arg2 = gst->guest_r3; canonical->arg3 = gst->guest_r4; @@ -895,7 +885,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_riscv64_linux) VexGuestRISCV64State* gst = (VexGuestRISCV64State*)gst_vanilla; - canonical->sysno = gst->guest_x17; /* a7 */ + canonical->canonical_sysno = gst->guest_x17; /* a7 */ canonical->arg1 = gst->guest_x10; /* a0 */ canonical->arg2 = gst->guest_x11; /* a1 */ canonical->arg3 = gst->guest_x12; /* a2 */ @@ -908,7 +898,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_x86_solaris) VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_ESP; - canonical->sysno = gst->guest_EAX; + canonical->canonical_sysno = gst->guest_EAX; /* stack[0] is a return address. */ canonical->arg1 = stack[1]; canonical->arg2 = stack[2]; @@ -932,8 +922,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, break; case VEX_TRC_JMP_SYS_INT210: /* int $0xD2 = fasttrap */ - canonical->sysno - = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->sysno); + canonical->canonical_sysno + = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->canonical_sysno); break; default: vg_assert(0); @@ -943,7 +933,7 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, #elif defined(VGP_amd64_solaris) VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_RSP; - canonical->sysno = gst->guest_RAX; + canonical->canonical_sysno = gst->guest_RAX; /* stack[0] is a return address. */ canonical->arg1 = gst->guest_RDI; canonical->arg2 = gst->guest_RSI; @@ -960,8 +950,8 @@ void getSyscallArgsFromGuestState ( /*OUT*/SyscallArgs* canonical, break; case VEX_TRC_JMP_SYS_INT210: /* int $0xD2 = fasttrap */ - canonical->sysno - = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->sysno); + canonical->canonical_sysno + = VG_SOLARIS_SYSCALL_CONSTRUCT_FASTTRAP(canonical->canonical_sysno); break; default: vg_assert(0); @@ -979,7 +969,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, { #if defined(VGP_x86_linux) VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla; - gst->guest_EAX = canonical->sysno; + gst->guest_EAX = canonical->canonical_sysno; gst->guest_EBX = canonical->arg1; gst->guest_ECX = canonical->arg2; gst->guest_EDX = canonical->arg3; @@ -989,7 +979,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_amd64_linux) VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla; - gst->guest_RAX = canonical->sysno; + gst->guest_RAX = canonical->canonical_sysno; gst->guest_RDI = canonical->arg1; gst->guest_RSI = canonical->arg2; gst->guest_RDX = canonical->arg3; @@ -999,7 +989,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_ppc32_linux) VexGuestPPC32State* gst = (VexGuestPPC32State*)gst_vanilla; - gst->guest_GPR0 = canonical->sysno; + gst->guest_GPR0 = canonical->canonical_sysno; gst->guest_GPR3 = canonical->arg1; gst->guest_GPR4 = canonical->arg2; gst->guest_GPR5 = canonical->arg3; @@ -1009,7 +999,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) VexGuestPPC64State* gst = (VexGuestPPC64State*)gst_vanilla; - gst->guest_GPR0 = canonical->sysno; + gst->guest_GPR0 = canonical->canonical_sysno; gst->guest_GPR3 = canonical->arg1; gst->guest_GPR4 = canonical->arg2; gst->guest_GPR5 = canonical->arg3; @@ -1023,22 +1013,21 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, UWord *stack = (UWord *)gst->guest_ESP; // stack[0] is a (fake) return address - switch (canonical->klass) { - case VG_FREEBSD_SYSCALL0: - gst->guest_EAX = __NR_syscall; - stack[1] = canonical->sysno; + switch (canonical->original_sysno) { + case __NR_syscall: + stack[1] = canonical->canonical_sysno; stack++; break; - case VG_FREEBSD_SYSCALL198: - gst->guest_EAX = __NR___syscall; - stack[1] = canonical->sysno; + case __NR___syscall: + stack[1] = canonical->canonical_sysno; stack += 2; break; default: - gst->guest_EAX = canonical->sysno; break; } + gst->guest_EAX = canonical->original_sysno; + stack[1] = canonical->arg1; stack[2] = canonical->arg2; stack[3] = canonical->arg3; @@ -1052,21 +1041,9 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_RSP; - // stack[0] is a (fake) return address - switch (canonical->klass) { - case VG_FREEBSD_SYSCALL0: - gst->guest_RAX = __NR_syscall; - break; - case VG_FREEBSD_SYSCALL198: - gst->guest_RAX = __NR___syscall; - break; - default: - gst->guest_RAX = canonical->sysno; - break; - } - - if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) { - gst->guest_RDI = canonical->sysno; + if (canonical->original_sysno == __NR_syscall || + canonical->original_sysno == __NR___syscall) { + gst->guest_RDI = canonical->canonical_sysno; gst->guest_RSI = canonical->arg1; gst->guest_RDX = canonical->arg2; gst->guest_R10 = canonical->arg3; @@ -1086,21 +1063,14 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, stack[2] = canonical->arg8; } + gst->guest_RAX = canonical->original_sysno; + #elif defined(VGP_arm64_freebsd) VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla; - switch (canonical->klass) { - case VG_FREEBSD_SYSCALL0: - gst->guest_X8 = __NR_syscall; - break; - case VG_FREEBSD_SYSCALL198: - gst->guest_X8 = __NR___syscall; - break; - default: - gst->guest_X8 = canonical->sysno; - break; - } - if (canonical->klass == VG_FREEBSD_SYSCALL0 || canonical->klass == VG_FREEBSD_SYSCALL198) { - gst->guest_X0 = canonical->sysno; + + if (canonical->original_sysno == __NR_syscall || + canonical->original_sysno == __NR___syscall) { + gst->guest_X0 = canonical->canonical_sysno; gst->guest_X1 = canonical->arg1; gst->guest_X2 = canonical->arg2; gst->guest_X3 = canonical->arg3; @@ -1118,9 +1088,11 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, gst->guest_X6 = canonical->arg7; } + gst->guest_X8 = canonical->original_sysno; + #elif defined(VGP_arm_linux) VexGuestARMState* gst = (VexGuestARMState*)gst_vanilla; - gst->guest_R7 = canonical->sysno; + gst->guest_R7 = canonical->canonical_sysno; gst->guest_R0 = canonical->arg1; gst->guest_R1 = canonical->arg2; gst->guest_R2 = canonical->arg3; @@ -1130,7 +1102,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_arm64_linux) VexGuestARM64State* gst = (VexGuestARM64State*)gst_vanilla; - gst->guest_X8 = canonical->sysno; + gst->guest_X8 = canonical->canonical_sysno; gst->guest_X0 = canonical->arg1; gst->guest_X1 = canonical->arg2; gst->guest_X2 = canonical->arg3; @@ -1142,7 +1114,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_ESP; - gst->guest_EAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->sysno); + gst->guest_EAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->canonical_sysno); // GrP fixme? gst->guest_TEMP_EFLAG_C = 0; // stack[0] is return address @@ -1159,7 +1131,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla; UWord *stack = (UWord *)gst->guest_RSP; - gst->guest_RAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->sysno); + gst->guest_RAX = VG_DARWIN_SYSNO_FOR_KERNEL(canonical->canonical_sysno); // GrP fixme? gst->guest_TEMP_EFLAG_C = 0; // stack[0] is return address @@ -1174,7 +1146,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_s390x_linux) VexGuestS390XState* gst = (VexGuestS390XState*)gst_vanilla; - gst->guest_SYSNO = canonical->sysno; + gst->guest_SYSNO = canonical->canonical_sysno; gst->guest_r2 = canonical->arg1; gst->guest_r3 = canonical->arg2; gst->guest_r4 = canonical->arg3; @@ -1185,7 +1157,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_mips32_linux) VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla; if (canonical->arg8 != __NR_syscall) { - gst->guest_r2 = canonical->sysno; + gst->guest_r2 = canonical->canonical_sysno; gst->guest_r4 = canonical->arg1; gst->guest_r5 = canonical->arg2; gst->guest_r6 = canonical->arg3; @@ -1196,7 +1168,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, } else { canonical->arg8 = 0; gst->guest_r2 = __NR_syscall; - gst->guest_r4 = canonical->sysno; + gst->guest_r4 = canonical->canonical_sysno; gst->guest_r5 = canonical->arg1; gst->guest_r6 = canonical->arg2; gst->guest_r7 = canonical->arg3; @@ -1208,7 +1180,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_nanomips_linux) VexGuestMIPS32State* gst = (VexGuestMIPS32State*)gst_vanilla; - gst->guest_r2 = canonical->sysno; + gst->guest_r2 = canonical->canonical_sysno; gst->guest_r4 = canonical->arg1; gst->guest_r5 = canonical->arg2; gst->guest_r6 = canonical->arg3; @@ -1219,7 +1191,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, gst->guest_r11 = canonical->arg8; #elif defined(VGP_mips64_linux) VexGuestMIPS64State* gst = (VexGuestMIPS64State*)gst_vanilla; - gst->guest_r2 = canonical->sysno; + gst->guest_r2 = canonical->canonical_sysno; gst->guest_r4 = canonical->arg1; gst->guest_r5 = canonical->arg2; gst->guest_r6 = canonical->arg3; @@ -1231,7 +1203,7 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, #elif defined(VGP_riscv64_linux) VexGuestRISCV64State* gst = (VexGuestRISCV64State*)gst_vanilla; - gst->guest_x17 = canonical->sysno; /* a7 */ + gst->guest_x17 = canonical->canonical_sysno; /* a7 */ gst->guest_x10 = canonical->arg1; /* a0 */ gst->guest_x11 = canonical->arg2; /* a1 */ gst->guest_x12 = canonical->arg3; /* a2 */ @@ -1244,9 +1216,9 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, UWord *stack = (UWord *)gst->guest_ESP; /* Fasttraps or anything else cannot go through this way. */ - vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->sysno) + vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->canonical_sysno) == VG_SOLARIS_SYSCALL_CLASS_CLASSIC); - gst->guest_EAX = canonical->sysno; + gst->guest_EAX = canonical->canonical_sysno; /* stack[0] is a return address. */ stack[1] = canonical->arg1; stack[2] = canonical->arg2; @@ -1262,9 +1234,9 @@ void putSyscallArgsIntoGuestState ( /*IN*/ SyscallArgs* canonical, UWord *stack = (UWord *)gst->guest_RSP; /* Fasttraps or anything else cannot go through this way. */ - vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->sysno) + vg_assert(VG_SOLARIS_SYSNO_CLASS(canonical->canonical_sysno) == VG_SOLARIS_SYSCALL_CLASS_CLASSIC); - gst->guest_RAX = canonical->sysno; + gst->guest_RAX = canonical->canonical_sysno; /* stack[0] is a return address. */ gst->guest_RDI = canonical->arg1; gst->guest_RSI = canonical->arg2; @@ -2089,7 +2061,7 @@ void bad_before ( ThreadId tid, /*OUT*/UWord* flags ) { VG_(dmsg)("WARNING: unhandled %s syscall: %s\n", - VG_PLATFORM, VG_SYSNUM_STRING(args->sysno)); + VG_PLATFORM, VG_SYSNUM_STRING(args->canonical_sysno)); if (VG_(clo_verbosity) > 1) { VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size)); } @@ -2178,7 +2150,7 @@ Bool VG_(is_in_kernel_restart_syscall) ( ThreadId tid ) Word VG_(is_in_syscall_no) (ThreadId tid ) { vg_assert(tid < VG_N_THREADS); - return syscallInfo[tid].orig_args.sysno; + return syscallInfo[tid].orig_args.canonical_sysno; } static void ensure_initialised ( void ) @@ -2200,7 +2172,8 @@ static void ensure_initialised ( void ) void VG_(client_syscall) ( ThreadId tid, UInt trc ) { - Word sysno; + Word canonical_sysno; + Word original_sysno; ThreadState* tst; const SyscallTableEntry* ent; SyscallArgLayout layout; @@ -2318,14 +2291,21 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Save the syscall number in the thread state in case the syscall is interrupted by a signal. */ - sysno = sci->orig_args.sysno; + canonical_sysno = sci->orig_args.canonical_sysno; +#if defined(VGO_freebsd) + original_sysno = sci->orig_args.original_sysno; +#else + /* + * When there is no "syscall syycall" the original + * and canonical sysno values are the same + */ + original_sysno = sci->orig_args.canonical_sysno; +#endif + -# if defined(VGO_freebsd) - tst->arch.vex.guest_SC_CLASS = sci->orig_args.klass; -# endif /* It's sometimes useful, as a crude debugging hack, to get a stack trace at each (or selected) syscalls. */ - if (0 && sysno == __NR_ioctl) { + if (0 && canonical_sysno == __NR_ioctl) { VG_(umsg)("\nioctl:\n"); VG_(get_and_pp_StackTrace)(tid, 10); VG_(umsg)("\n"); @@ -2341,7 +2321,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) because it only has a single syscall return convention and so there is no ambiguity involved in converting the post-signal machine state into a SysRes. */ - tst->arch.vex.guest_SC_CLASS = VG_DARWIN_SYSNO_CLASS(sysno); + tst->arch.vex.guest_SC_CLASS = VG_DARWIN_SYSNO_CLASS(canonical_sysno); # endif /* The default what-to-do-next thing is hand the syscall to the @@ -2355,7 +2335,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Fetch the syscall's handlers. If no handlers exist for this syscall, we are given dummy handlers which force an immediate return with ENOSYS. */ - ent = get_syscall_entry(sysno); + ent = get_syscall_entry(canonical_sysno); /* Fetch the layout information, which tells us where in the guest state the syscall args reside. This is a platform-dependent @@ -2363,7 +2343,8 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) checks (PRE_REG_READ calls) know which bits of the guest state they need to inspect. */ #if defined(VGP_amd64_freebsd) || defined (VGP_arm64_freebsd) - if (sci->orig_args.klass == VG_FREEBSD_SYSCALL0 || sci->orig_args.klass == VG_FREEBSD_SYSCALL198) { + if (original_sysno == __NR_syscall || + original_sysno == __NR___syscall) { syscall_syscall = True; } #endif @@ -2383,7 +2364,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) */ PRINT("SYSCALL[%d,%u](%s) ", - VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno)); + VG_(getpid)(), tid, VG_SYSNUM_STRING(canonical_sysno)); /* Do any pre-syscall actions */ if (VG_(needs).syscall_wrapper) { @@ -2396,7 +2377,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) tmpv[5] = sci->orig_args.arg6; tmpv[6] = sci->orig_args.arg7; tmpv[7] = sci->orig_args.arg8; - VG_TDICT_CALL(tool_pre_syscall, tid, sysno, + VG_TDICT_CALL(tool_pre_syscall, tid, canonical_sysno, &tmpv[0], sizeof(tmpv)/sizeof(tmpv[0])); } @@ -2407,7 +2388,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) &sci->args, &sci->status, &sci->flags ); /* If needed, gdbserver will report syscall entry to GDB */ - VG_(gdbserver_report_syscall)(True, sysno, tid); + VG_(gdbserver_report_syscall)(True, canonical_sysno, tid); /* The pre-handler may have modified: sci->args @@ -2420,7 +2401,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Now we proceed according to what the pre-handler decided. */ vg_assert(sci->status.what == SsHandToKernel || sci->status.what == SsComplete); - vg_assert(sci->args.sysno == sci->orig_args.sysno); + vg_assert(sci->args.canonical_sysno == sci->orig_args.canonical_sysno); if (sci->status.what == SsComplete && !sr_isError(sci->status.sres)) { /* The pre-handler completed the syscall itself, declaring @@ -2503,7 +2484,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Do the call, which operates directly on the guest state, not on our abstracted copies of the args/result. */ - do_syscall_for_client(sysno, tst, &mask); + do_syscall_for_client(original_sysno, tst, &mask); /* do_syscall_for_client may not return if the syscall was interrupted by a signal. In that case, flow of control is @@ -2531,7 +2512,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) /* Be decorative, if required. */ if (VG_(clo_trace_syscalls)) { PRINT("SYSCALL[%d,%u](%s) ... [async] --> %s", - VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno), + VG_(getpid)(), tid, VG_SYSNUM_STRING(canonical_sysno), VG_(sr_as_string)(sci->status.sres)); } @@ -2544,7 +2525,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) guest state. Indeed doing so could be construed as incorrect. */ SysRes sres - = VG_(do_syscall)(sysno, sci->args.arg1, sci->args.arg2, + = VG_(do_syscall)(canonical_sysno, sci->args.arg1, sci->args.arg2, sci->args.arg3, sci->args.arg4, sci->args.arg5, sci->args.arg6, sci->args.arg7, sci->args.arg8 ); @@ -2567,7 +2548,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) putSyscallStatusIntoGuestState( tid, &sci->status, &tst->arch.vex ); /* If needed, gdbserver will report syscall return to GDB */ - VG_(gdbserver_report_syscall)(False, sysno, tid); + VG_(gdbserver_report_syscall)(False, canonical_sysno, tid); /* Situation now: - the guest state is now correctly modified following the syscall @@ -2601,7 +2582,7 @@ void VG_(post_syscall) (ThreadId tid) const SyscallTableEntry* ent; SyscallStatus test_status; ThreadState* tst; - Word sysno; + Word canonical_sysno; /* Preliminaries */ vg_assert(VG_(is_valid_tid)(tid)); @@ -2627,12 +2608,12 @@ void VG_(post_syscall) (ThreadId tid) /* Get the system call number. Because the pre-handler isn't allowed to mess with it, it should be the same for both the original and potentially-modified args. */ - vg_assert(sci->args.sysno == sci->orig_args.sysno); - sysno = sci->args.sysno; + vg_assert(sci->args.canonical_sysno == sci->orig_args.canonical_sysno); + canonical_sysno = sci->args.canonical_sysno; getSyscallStatusFromGuestState( &test_status, &tst->arch.vex ); if (!(sci->flags & SfNoWriteResult)) { - vg_assert(eq_SyscallStatus( sysno, &sci->status, &test_status )); + vg_assert(eq_SyscallStatus( canonical_sysno, &sci->status, &test_status )); } /* Failure of the above assertion on Darwin can indicate a problem in the syscall wrappers that pre-fail or pre-succeed the @@ -2650,7 +2631,7 @@ void VG_(post_syscall) (ThreadId tid) - it exists, and - Success or (Failure and PostOnFail is set) */ - ent = get_syscall_entry(sysno); + ent = get_syscall_entry(canonical_sysno); if (ent->after && ((!sr_isError(sci->status.sres)) || (sr_isError(sci->status.sres) @@ -2678,7 +2659,7 @@ void VG_(post_syscall) (ThreadId tid) tmpv[6] = sci->orig_args.arg7; tmpv[7] = sci->orig_args.arg8; VG_TDICT_CALL(tool_post_syscall, tid, - sysno, + canonical_sysno, &tmpv[0], sizeof(tmpv)/sizeof(tmpv[0]), sci->status.sres); } diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c index e9f844e0d5..5abf6a992f 100644 --- a/coregrind/m_syswrap/syswrap-xen.c +++ b/coregrind/m_syswrap/syswrap-xen.c @@ -2519,7 +2519,7 @@ static void bad_before ( ThreadId tid, /*OUT*/UWord* flags ) { VG_(dmsg)("WARNING: unhandled hypercall: %s\n", - VG_SYSNUM_STRING(args->sysno)); + VG_SYSNUM_STRING(args->canonical_sysno)); if (VG_(clo_verbosity) > 1) { VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size)); } diff --git a/include/vki/vki-scnums-freebsd.h b/include/vki/vki-scnums-freebsd.h index 924434f3fc..83e4430c20 100644 --- a/include/vki/vki-scnums-freebsd.h +++ b/include/vki/vki-scnums-freebsd.h @@ -30,19 +30,6 @@ #include "config.h" #include <sys/syscall.h> -// this is the syscall format used by e.g., libc functions like 'write' -// this is the one used 99.999% of the time -// the two others are only for experimental or testing use -// (but we use them in the scalar tests). -#define VG_FREEBSD_SYSCALL_STD 0 -// this is the syscall format used by 'syscall' -#define VG_FREEBSD_SYSCALL0 1 -// this is the syscall format used by '__syscall' -// it is the same as VG_FREEBSD_SYSCALL0 except that -// it ensures that 64bit argument alignment is correct -// that makes no difference for amd64, x86 not sure -#define VG_FREEBSD_SYSCALL198 2 - // From sys/syscall.h // @todo PJF ugly leading double underscores |
|
From: Paul F. <pa...@so...> - 2025-11-06 17:44:58
|
https://sourceware.org/cgit/valgrind/commit/?id=f15425fa0a9c77e547712a0669e978763de31948 commit f15425fa0a9c77e547712a0669e978763de31948 Author: Paul Floyd <pj...@wa...> Date: Thu Nov 6 18:43:17 2025 +0100 doc: add client_syscall_arguments.txt to EXTRA_DIST Diff: --- docs/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Makefile.am b/docs/Makefile.am index 7e5ed389c5..b8a15e27f8 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -66,6 +66,7 @@ EXTRA_DIST = \ internals/Darwin-debug.txt \ internals/Darwin-notes.txt \ internals/SPEC-notes.txt \ + internals/client_syscall_arguments.txt \ internals/directory-structure.txt \ internals/git-HOWTO.txt \ internals/howto_BUILD_KDE42.txt \ |
|
From: Paul F. <pa...@so...> - 2025-11-06 07:35:38
|
https://sourceware.org/cgit/valgrind/commit/?id=85a06581cc9e725103a2dda0acfcf95b95944755 commit 85a06581cc9e725103a2dda0acfcf95b95944755 Author: Paul Floyd <pj...@wa...> Date: Thu Nov 6 08:33:42 2025 +0100 doc: add a text file describing client syscall argument handling To help understand all of the shuffling that gets done for "syscall syscall". Diff: --- docs/internals/client_syscall_arguments.txt | 112 ++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/docs/internals/client_syscall_arguments.txt b/docs/internals/client_syscall_arguments.txt new file mode 100644 index 0000000000..1ef113db84 --- /dev/null +++ b/docs/internals/client_syscall_arguments.txt @@ -0,0 +1,112 @@ +Client Syscall Arguments +======================== + +This document describes how Valgrind handles arguments for client syscalls. +Everything described here takes place in VG_(client_syscall), syswrap-main.c. + + +Data Structures +~~~~~~~~~~~~~~~ + +There are 3 data structures that get used during the argument handling. + +1. VexGuestArchState, the usual storage for registers. +2. SyscallArgLayout, contains info about where the arguments are. +3. SyscallArgs (two copies in SyscallInfo), contains the argument values. + +Flow +~~~~ + +The main steps in the function are to call the PRE syscall wrapper. +That may perform the syscall (or simulate the syscall) and it may +also mark the syscall as blocking. If the PRE did not mark the syscall +as completed it will proceed to either make a non-blocking or a blocking +call. Lastly the POST gets called, if required. + +All of the above can be complicated by the fact that some platforms have +a "syscall syscall". Most platforms have a libc function called "syscall()". +On some platforms libc shuffles the arguments and just performs the +requested syscall directly . Other platforms have a syscall for performing syscalls. +There may even be more than one such syscall. In these cases it is the kernel +that shuffles the arguments to pass them on to the appropriate +syscall. + +The main platforms that have a "syscall syscall" are Darwin and FreeBSD. +Linux mips32 also has some special handling for syscall syscall. + +In Valgrind when there is a "syscall syscall" we don't want to just pass +all of the parameters through. If we did that then "syscall syscall" PRE wrapper +would need to handle all other kinds of syscalls, probably by some kind +of second level of recursive call. This is not the approach that has been taken. +Instead the arguments get "canonicalised" so that the PRE sees "syscall(SYS_write)" +is if it were just a normal direct write syscall. + +The argument layout for such "syscall syscalls" is the same as normal syscalls +but offset by one in register/stack positions. The first argument will be that for +syscall or __syscall. The second argument will be the target normal syscall +followed by the target arguments. + + +Flow in Detail +~~~~~~~~~~~~~~ + +1. Get the canonical arguments. +Call getSyscallArgsFromGuestState() +This stores the canonical arguments (syscall syscall format gets shuffled) +in the SyscallArgs structure. + +2. Get the syscall argument layout +This just initialises the fields of the SyscallArgLayout structure. The layout +will be different depending if it is a normal syscall or a syscall syscall. +It cannot be canonicalised - we can shuffle around the values but we can't +shuffle around where they are stored. + +4. Call the syscall PRE wrapper +The argument values are passed in a pointer to SyscallArgs. The fields of that +structure are used by the ARGX and SARGX macros to access the argument values +in the wrapper. + +The argument layout is passed in a pointer to SyscallArgLayout. The fields of +this structure are used indirectly by the PRE_REG_READX macros (X being an +integer for the argument position) For each argument the PRE_REG_READX macro +uses a PRAX macro which in turn uses either PSRAn for stack accesses or +PRRAn for register accesses. In the case of amd64 the location of argument 6 +depends on whether it is a normal syscall or a syscall syscall. In the former +case it will be in a register. In the latter case it will be on the stack. +There is special handling for this case. + +If the syscall has not been completed by the PRE then either step 5 or step 6 +will be executed for blocking and non-blocking syscalls respectively. + +5. Perform a blocking syscall +This is the more complicated of the two as we need to release the global lock, +change to using the guest signal mask, do the syscall, restore the Valgrind +signal mask and request the global lock again. + +A call to putSyscallArgsIntoGuestState is made. The PRE may have changed +some of the arguments so we need to put the arguments back into +VexGuestArchState. + +The syscall (and the signal mask handling) is performed in a call to +do_syscall_for_client(). This takes the arguments other than the syscall number +from VexGuestArchState. + +6. Perform a non-blocking syscall. + +This is much simpler. It performs the syscall via VG_(do_syscall). +The arguments are passed via struct SyscallArgs (possibly modified by the PRE +wrapper). + +7. Call VG_(post_syscall)() +This will call the POST wrapper if required. + +Future Work +~~~~~~~~~~~ + +The flow would be simpler if do_syscall_for_client() used struct SyscallArgs +to get the arg values like VG_(do_syscall). That would avoid having to +put modified arguments back into the guest state. I have not checked, but +I am not certain that the modified guest state is not visible after the syscall. + +The handling of "syscall syscall" does an excessive amount of shuffling, +especially for the syscall number. I think that this can be simplified. |
|
From: Yu, M. <min...@wi...> - 2025-11-06 06:35:04
|
Ping. Thanks, On 9/30/25 17:19, mingli.yu--- via Valgrind-developers wrote: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > From: Mingli Yu <min...@wi...> > > Though the valgrind testing is extended to produce automake-style log into > test-suite-overall.log [1], it's better also print the test result to the > stdout. > > [1] https://sourceware.org/git/?p=valgrind.git;a=commitdiff;h=61e44a4aef8775b925a7a91f403ebd7f4f6670a4 > > Signed-off-by: Mingli Yu <min...@wi...> > --- > tests/vg_regtest.in | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in > index 945b4c161..2f5f3f678 100644 > --- a/tests/vg_regtest.in > +++ b/tests/vg_regtest.in > @@ -720,6 +720,7 @@ sub test_one_dir($$) > close(TSDIRLOG); > my $result = do_one_test($full_dir, $f); > print TSLOG scalar localtime, " result: $result $full_dir/$f.log\n"; > + print "$result: $full_dir/$f\n"; > $num_results{$result} ++; > if ($result ne "PASS") { > # transcribe .log file into the overall log. > @@ -823,6 +824,7 @@ while (1) { # we will exit after one loop, unless looptillfail > > my $result = do_one_test($dir, $file); > print TSLOG scalar localtime, " result: $result $dir/$file.log\n"; > + print "$result: $dir/$file\n"; > $num_results{$result} ++; > if ($result ne "PASS") { > # transcribe .log file into the overall log. > -- > 2.34.1 > > > > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers |
|
From: Paul F. <pa...@so...> - 2025-11-05 08:21:54
|
https://sourceware.org/cgit/valgrind/commit/?id=9d9a20925bf33157025aaca5ac048ac6adf3761f commit 9d9a20925bf33157025aaca5ac048ac6adf3761f Author: Paul Floyd <pj...@wa...> Date: Wed Nov 5 09:20:44 2025 +0100 FreeBSD arm64: reverse normal syscall and syscall syscall args Copied and pasted in the wrong order. Diff: --- coregrind/m_syswrap/syswrap-main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index ac2f161ec9..45ece95cbf 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -1923,6 +1923,17 @@ void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout, /*IN*/Bool syscall_s #elif defined(VGP_arm64_freebsd) if (syscall_syscall) + { + layout->o_sysno = OFFSET_arm64_X0; + layout->o_arg1 = OFFSET_arm64_X1; + layout->o_arg2 = OFFSET_arm64_X2; + layout->o_arg3 = OFFSET_arm64_X3; + layout->o_arg4 = OFFSET_arm64_X4; + layout->o_arg5 = OFFSET_arm64_X5; + layout->o_arg6 = OFFSET_arm64_X6; + layout->o_arg7 = OFFSET_arm64_X7; + } + else { layout->o_sysno = OFFSET_arm64_X8; layout->o_arg1 = OFFSET_arm64_X0; @@ -1934,17 +1945,6 @@ void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout, /*IN*/Bool syscall_s layout->o_arg7 = OFFSET_arm64_X6; layout->o_arg8 = OFFSET_arm64_X7; } - else - { - layout->o_sysno = OFFSET_arm64_X0; - layout->o_arg1 = OFFSET_arm64_X1; - layout->o_arg2 = OFFSET_arm64_X2; - layout->o_arg3 = OFFSET_arm64_X3; - layout->o_arg4 = OFFSET_arm64_X4; - layout->o_arg5 = OFFSET_arm64_X5; - layout->o_arg6 = OFFSET_arm64_X6; - layout->o_arg7 = OFFSET_arm64_X7; - } #elif defined(VGP_arm_linux) layout->o_sysno = OFFSET_arm_R7; |
|
From: Paul F. <pa...@so...> - 2025-11-04 20:40:23
|
https://sourceware.org/cgit/valgrind/commit/?id=e062c8b55d861d176de6958e106c831e300a8b1c commit e062c8b55d861d176de6958e106c831e300a8b1c Author: Paul Floyd <pj...@wa...> Date: Tue Nov 4 21:39:00 2025 +0100 FreeBSD: cleanup arg handling for syscalls syscall and __syscall This is with a view to using the same code for Darwin. Diff: --- coregrind/m_syswrap/syswrap-main.c | 115 +++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 62 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 884836c267..ac2f161ec9 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -1833,7 +1833,7 @@ void putSyscallStatusIntoGuestState ( /*IN*/ ThreadId tid, hardwired. */ static -void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout ) +void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout, /*IN*/Bool syscall_syscall ) { VG_(bzero_inline)(layout, sizeof(*layout)); @@ -1894,27 +1894,57 @@ void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout ) layout->s_arg8 = sizeof(UWord) * 8; #elif defined(VGP_amd64_freebsd) - layout->o_sysno = OFFSET_amd64_RAX; - layout->o_arg1 = OFFSET_amd64_RDI; - layout->o_arg2 = OFFSET_amd64_RSI; - layout->o_arg3 = OFFSET_amd64_RDX; - layout->o_arg4 = OFFSET_amd64_R10; - layout->o_arg5 = OFFSET_amd64_R8; - layout->o_arg6 = OFFSET_amd64_R9; - layout->s_arg7 = sizeof(UWord) * 1; - layout->s_arg8 = sizeof(UWord) * 2; - layout->arg6_is_reg = True; + if (syscall_syscall) + { + layout->o_sysno = OFFSET_amd64_RDI; + layout->o_arg1 = OFFSET_amd64_RSI; + layout->o_arg2 = OFFSET_amd64_RDX; + layout->o_arg3 = OFFSET_amd64_R10; + layout->o_arg4 = OFFSET_amd64_R8; + layout->o_arg5 = OFFSET_amd64_R9; + layout->s_arg6 = sizeof(UWord) * 1; + layout->s_arg7 = sizeof(UWord) * 2; + layout->s_arg8 = sizeof(UWord) * 3; + layout->arg6_is_reg = False; + } + else + { + layout->o_sysno = OFFSET_amd64_RAX; + layout->o_arg1 = OFFSET_amd64_RDI; + layout->o_arg2 = OFFSET_amd64_RSI; + layout->o_arg3 = OFFSET_amd64_RDX; + layout->o_arg4 = OFFSET_amd64_R10; + layout->o_arg5 = OFFSET_amd64_R8; + layout->o_arg6 = OFFSET_amd64_R9; + layout->s_arg7 = sizeof(UWord) * 1; + layout->s_arg8 = sizeof(UWord) * 2; + layout->arg6_is_reg = True; + } #elif defined(VGP_arm64_freebsd) - layout->o_sysno = OFFSET_arm64_X8; - layout->o_arg1 = OFFSET_arm64_X0; - layout->o_arg2 = OFFSET_arm64_X1; - layout->o_arg3 = OFFSET_arm64_X2; - layout->o_arg4 = OFFSET_arm64_X3; - layout->o_arg5 = OFFSET_arm64_X4; - layout->o_arg6 = OFFSET_arm64_X5; - layout->o_arg7 = OFFSET_arm64_X6; - layout->o_arg8 = OFFSET_arm64_X7; + if (syscall_syscall) + { + layout->o_sysno = OFFSET_arm64_X8; + layout->o_arg1 = OFFSET_arm64_X0; + layout->o_arg2 = OFFSET_arm64_X1; + layout->o_arg3 = OFFSET_arm64_X2; + layout->o_arg4 = OFFSET_arm64_X3; + layout->o_arg5 = OFFSET_arm64_X4; + layout->o_arg6 = OFFSET_arm64_X5; + layout->o_arg7 = OFFSET_arm64_X6; + layout->o_arg8 = OFFSET_arm64_X7; + } + else + { + layout->o_sysno = OFFSET_arm64_X0; + layout->o_arg1 = OFFSET_arm64_X1; + layout->o_arg2 = OFFSET_arm64_X2; + layout->o_arg3 = OFFSET_arm64_X3; + layout->o_arg4 = OFFSET_arm64_X4; + layout->o_arg5 = OFFSET_arm64_X5; + layout->o_arg6 = OFFSET_arm64_X6; + layout->o_arg7 = OFFSET_arm64_X7; + } #elif defined(VGP_arm_linux) layout->o_sysno = OFFSET_arm_R7; @@ -2044,36 +2074,6 @@ void getSyscallArgLayout ( /*OUT*/SyscallArgLayout* layout ) #endif } -#if defined(VGP_amd64_freebsd) || defined(VGP_arm64_freebsd) -static -void getSyscallArgLayout_0_198 ( /*OUT*/SyscallArgLayout* layout ) -{ -#if defined(VGP_amd64_freebsd) - VG_(bzero_inline)(layout, sizeof(*layout)); - layout->o_sysno = OFFSET_amd64_RDI; - layout->o_arg1 = OFFSET_amd64_RSI; - layout->o_arg2 = OFFSET_amd64_RDX; - layout->o_arg3 = OFFSET_amd64_R10; - layout->o_arg4 = OFFSET_amd64_R8; - layout->o_arg5 = OFFSET_amd64_R9; - layout->s_arg6 = sizeof(UWord) * 1; - layout->s_arg7 = sizeof(UWord) * 2; - layout->s_arg8 = sizeof(UWord) * 3; - layout->arg6_is_reg = False; -#else - layout->o_sysno = OFFSET_arm64_X0; - layout->o_arg1 = OFFSET_arm64_X1; - layout->o_arg2 = OFFSET_arm64_X2; - layout->o_arg3 = OFFSET_arm64_X3; - layout->o_arg4 = OFFSET_arm64_X4; - layout->o_arg5 = OFFSET_arm64_X5; - layout->o_arg6 = OFFSET_arm64_X6; - layout->o_arg7 = OFFSET_arm64_X7; -#endif -} -#endif - - /* --------------------------------------------------------------------- The main driver logic ------------------------------------------------------------------ */ @@ -2205,6 +2205,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) const SyscallTableEntry* ent; SyscallArgLayout layout; SyscallInfo* sci; + Bool syscall_syscall = False; ensure_initialised(); @@ -2362,21 +2363,11 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc ) checks (PRE_REG_READ calls) know which bits of the guest state they need to inspect. */ #if defined(VGP_amd64_freebsd) || defined (VGP_arm64_freebsd) - // PJF - somewhat unfortunate uglificaton of the code, but the current code handles two - // types of syscall with different register use. Mixing them up is not good. - // I've avoided modifying the existing function (I could have added - // a FreeBSD amd64-only flag to it for this purpose). if (sci->orig_args.klass == VG_FREEBSD_SYSCALL0 || sci->orig_args.klass == VG_FREEBSD_SYSCALL198) { - getSyscallArgLayout_0_198( &layout ); - } else { -#endif - - getSyscallArgLayout( &layout ); - -#if defined(VGP_amd64_freebsd) || defined(VGP_arm64_freebsd) + syscall_syscall = True; } #endif - + getSyscallArgLayout( &layout, syscall_syscall ); /* Make sure the tmp signal mask matches the real signal mask; sigsuspend may change this. */ |
|
From: Paul F. <pa...@so...> - 2025-11-04 19:39:21
|
https://sourceware.org/cgit/valgrind/commit/?id=1a60f23515367e99b1cc059d276ce4671a752d4d commit 1a60f23515367e99b1cc059d276ce4671a752d4d Author: Paul Floyd <pj...@wa...> Date: Tue Nov 4 20:36:45 2025 +0100 Darwin: add ML_(get_darwin_syscall_entry) There was a comment saying that exposing the table arrays and sizes should be fixed (all other OSes use a function). Now done. Taken from https://github.com/LouisBrunner/valgrind-macos Thanks, Louis Brunner. Diff: --- coregrind/m_syswrap/priv_types_n_macros.h | 7 ++--- coregrind/m_syswrap/syswrap-darwin.c | 47 +++++++++++++++++++++++++++---- coregrind/m_syswrap/syswrap-main.c | 23 +-------------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/coregrind/m_syswrap/priv_types_n_macros.h b/coregrind/m_syswrap/priv_types_n_macros.h index 0ce26bd33d..ff5d6a2de7 100644 --- a/coregrind/m_syswrap/priv_types_n_macros.h +++ b/coregrind/m_syswrap/priv_types_n_macros.h @@ -240,12 +240,9 @@ extern SyscallTableEntry* ML_(get_linux_syscall_entry)( UInt sysno ); #elif defined(VGO_darwin) -/* XXX: Darwin still uses the old scheme of exposing the table - array(s) and size(s) directly to syswrap-main.c. This should be - fixed. */ -extern const SyscallTableEntry ML_(syscall_table)[]; -extern const UInt ML_(syscall_table_size); +extern +const SyscallTableEntry* ML_(get_darwin_syscall_entry)( UInt sysno ); #elif defined(VGO_solaris) extern diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 62bd589ae2..4eec0eb36b 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -11368,14 +11368,49 @@ const SyscallTableEntry ML_(mdep_trap_table)[] = { #error unknown architecture #endif -const UInt ML_(syscall_table_size) = - sizeof(ML_(syscall_table)) / sizeof(ML_(syscall_table)[0]); +const SyscallTableEntry* ML_(get_darwin_syscall_entry) ( UInt sysno ) +{ + const UInt syscall_table_size = + sizeof(ML_(syscall_table)) / sizeof(ML_(syscall_table)[0]); + + const UInt mach_trap_table_size = + sizeof(ML_(mach_trap_table)) / sizeof(ML_(mach_trap_table)[0]); + + const UInt mdep_trap_table_size = + sizeof(ML_(mdep_trap_table)) / sizeof(ML_(mdep_trap_table)[0]); + + const SyscallTableEntry *table; + Int size; + + switch (VG_DARWIN_SYSNO_CLASS(sysno)) { + case VG_DARWIN_SYSCALL_CLASS_UNIX: + table = ML_(syscall_table); + size = syscall_table_size; + break; + case VG_DARWIN_SYSCALL_CLASS_MACH: + table = ML_(mach_trap_table); + size = mach_trap_table_size; + break; + case VG_DARWIN_SYSCALL_CLASS_MDEP: + table = ML_(mdep_trap_table); + size = mdep_trap_table_size; + break; + default: + vg_assert2(0, "invalid syscall class: %d (syscall: %d / %#x)\n", VG_DARWIN_SYSNO_CLASS(sysno), VG_DARWIN_SYSNO_INDEX(sysno), sysno); + break; + } -const UInt ML_(mach_trap_table_size) = - sizeof(ML_(mach_trap_table)) / sizeof(ML_(mach_trap_table)[0]); + sysno = VG_DARWIN_SYSNO_INDEX(sysno); + if (sysno < size) { + const SyscallTableEntry *sys = &table[sysno]; + if (!sys->before) + return NULL; /* no entry */ + return sys; + } -const UInt ML_(mdep_trap_table_size) = - sizeof(ML_(mdep_trap_table)) / sizeof(ML_(mdep_trap_table)[0]); + /* Can't find a wrapper. */ + return NULL; +} #endif // defined(VGO_darwin) diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 49c264c40e..884836c267 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -2119,28 +2119,7 @@ static const SyscallTableEntry* get_syscall_entry ( Int syscallno ) sys = ML_(get_freebsd_syscall_entry)( syscallno ); # elif defined(VGO_darwin) - Int idx = VG_DARWIN_SYSNO_INDEX(syscallno); - - switch (VG_DARWIN_SYSNO_CLASS(syscallno)) { - case VG_DARWIN_SYSCALL_CLASS_UNIX: - if (idx >= 0 && idx < ML_(syscall_table_size) && - ML_(syscall_table)[idx].before != NULL) - sys = &ML_(syscall_table)[idx]; - break; - case VG_DARWIN_SYSCALL_CLASS_MACH: - if (idx >= 0 && idx < ML_(mach_trap_table_size) && - ML_(mach_trap_table)[idx].before != NULL) - sys = &ML_(mach_trap_table)[idx]; - break; - case VG_DARWIN_SYSCALL_CLASS_MDEP: - if (idx >= 0 && idx < ML_(mdep_trap_table_size) && - ML_(mdep_trap_table)[idx].before != NULL) - sys = &ML_(mdep_trap_table)[idx]; - break; - default: - vg_assert(0); - break; - } + sys = ML_(get_darwin_syscall_entry)( syscallno ); # elif defined(VGO_solaris) sys = ML_(get_solaris_syscall_entry)(syscallno); |
|
From: Paul F. <pa...@so...> - 2025-11-04 07:31:18
|
https://sourceware.org/cgit/valgrind/commit/?id=b461657ef9f2f8c0d983070e84f5387d410303ed commit b461657ef9f2f8c0d983070e84f5387d410303ed Author: Paul Floyd <pj...@wa...> Date: Tue Nov 4 08:27:01 2025 +0100 Darwin: clean up use of Z-encoded libc component libraries in vg_replace_strmem.c Use macros, mainly for consistency. Not sure how these have evolved post OSX 10.13. Diff: --- include/pub_tool_redir.h | 17 ++++++++++------- shared/vg_replace_strmem.c | 38 +++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h index c19fd3d97e..043f8ac520 100644 --- a/include/pub_tool_redir.h +++ b/include/pub_tool_redir.h @@ -247,11 +247,11 @@ #else # define VG_Z_LIBC_SONAME libcZdsoZa // libc.so* #endif -#elif defined(VGO_darwin) && (DARWIN_VERS <= DARWIN_10_6) -# define VG_Z_LIBC_SONAME libSystemZdZaZddylib // libSystem.*.dylib +#elif defined(VGO_darwin) -#elif defined(VGO_darwin) && (DARWIN_VERS == DARWIN_10_7 \ - || DARWIN_VERS == DARWIN_10_8) +#if (DARWIN_VERS <= DARWIN_10_6) +# define VG_Z_LIBC_SONAME libSystemZdZaZddylib // libSystem.*.dylib +#elif (DARWIN_VERS == DARWIN_10_7 || DARWIN_VERS == DARWIN_10_8) # define VG_Z_LIBC_SONAME libsystemZucZaZddylib // libsystem_c*.dylib /* Note that the idea of a single name for the C library falls apart on more recent Darwins (10.8 and later) since the @@ -260,13 +260,16 @@ libsystem_platform.dylib. This makes VG_Z_LIBC_SONAME somewhat useless at least inside vg_replace_strmem.c, and that hardwires some dylib names directly, for OSX 10.9. */ - -#elif defined(VGO_darwin) && (DARWIN_VERS >= DARWIN_10_9) +#elif (DARWIN_VERS >= DARWIN_10_9) # define VG_Z_LIBC_SONAME libsystemZumallocZddylib // libsystem_malloc.dylib +#endif + +/* Not tested on systems older than OSX 10.13 */ +#define VG_Z_LIBSYSTEM_C_SONAME libsystemZucZddylib +#define VG_Z_LIBSYSTEM_PLATFORM_SONAME libsystemZuplatformZddylib #else # error "Unknown platform" - #endif /* --- Sonames of the GNU C++ library. --- */ diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 28fda80ee2..5ef4884efa 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -237,7 +237,7 @@ static inline void my_exit ( int x ) //STRRCHR(VG_Z_DYLD, rindex) STRRCHR(VG_Z_LIBC_SONAME, strrchr) # if DARWIN_VERS >= DARWIN_10_9 - STRRCHR(libsystemZucZddylib, strrchr) + STRRCHR(VG_Z_LIBSYSTEM_C_SONAME, strrchr) # endif #elif defined(VGO_solaris) @@ -290,15 +290,15 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRCHR(VG_Z_LIBC_SONAME, strchr) # if DARWIN_VERS == DARWIN_10_9 - STRCHR(libsystemZuplatformZddylib, _platform_strchr) + STRCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_strchr) # endif # if DARWIN_VERS >= DARWIN_10_10 /* _platform_strchr$VARIANT$Generic */ - STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Generic) + STRCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_strchr$VARIANT$Generic) /* _platform_strchr$VARIANT$Haswell */ - STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Haswell) + STRCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_strchr$VARIANT$Haswell) # endif - STRCHR(libsystemZuplatformZddylib, _platform_strchr$VARIANT$Base) + STRCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_strchr$VARIANT$Base) #elif defined(VGO_solaris) STRCHR(VG_Z_LIBC_SONAME, strchr) @@ -475,7 +475,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) # if DARWIN_VERS == DARWIN_10_9 - STRNLEN(libsystemZucZddylib, strnlen) + STRNLEN(VG_Z_LIBSYSTEM_C_SONAME, strnlen) # endif #elif defined(VGO_solaris) @@ -524,7 +524,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRLEN(VG_Z_LIBC_SONAME, strlen) # if DARWIN_VERS >= DARWIN_10_9 - STRLEN(libsystemZucZddylib, strlen) + STRLEN(VG_Z_LIBSYSTEM_C_SONAME, strlen) # endif #elif defined(VGO_solaris) @@ -573,7 +573,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRCPY(VG_Z_LIBC_SONAME, strcpy) # if DARWIN_VERS == DARWIN_10_9 - STRCPY(libsystemZucZddylib, strcpy) + STRCPY(VG_Z_LIBSYSTEM_C_SONAME, strcpy) # endif #elif defined(VGO_solaris) @@ -621,7 +621,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRNCPY(VG_Z_LIBC_SONAME, strncpy) # if DARWIN_VERS >= DARWIN_10_9 - STRNCPY(libsystemZucZddylib, strncpy) + STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, strncpy) # endif #elif defined(VGO_solaris) @@ -730,7 +730,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRNCMP(VG_Z_LIBC_SONAME, strncmp) # if DARWIN_VERS >= DARWIN_10_9 - STRNCMP(libsystemZuplatformZddylib, _platform_strncmp) + STRNCMP(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_strncmp) # endif #elif defined(VGO_solaris) @@ -957,7 +957,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) STRCMP(VG_Z_LIBC_SONAME, strcmp) # if DARWIN_VERS >= DARWIN_10_9 - STRCMP(libsystemZuplatformZddylib, _platform_strcmp) + STRCMP(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_strcmp) # endif #elif defined(VGO_solaris) @@ -993,18 +993,18 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) # if DARWIN_VERS == DARWIN_10_9 MEMCHR(VG_Z_DYLD, memchr) - MEMCHR(libsystemZuplatformZddylib, _platform_memchr) + MEMCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memchr) # endif # if DARWIN_VERS >= DARWIN_10_10 MEMCHR(VG_Z_DYLD, memchr) /* _platform_memchr$VARIANT$Generic */ - MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Generic) + MEMCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memchr$VARIANT$Generic) /* _platform_memchr$VARIANT$Haswell */ - MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Haswell) + MEMCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memchr$VARIANT$Haswell) # endif # if DARWIN_VERS >= DARWIN_10_12 /* _platform_memchr$VARIANT$Base */ - MEMCHR(libsystemZuplatformZddylib, _platform_memchr$VARIANT$Base) + MEMCHR(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memchr$VARIANT$Base) #endif #elif defined(VGO_solaris) @@ -1242,7 +1242,7 @@ static inline void my_exit ( int x ) #elif defined(VGO_darwin) # if DARWIN_VERS >= DARWIN_10_9 - MEMCMP(libsystemZuplatformZddylib, _platform_memcmp) + MEMCMP(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memcmp) # endif #elif defined(VGO_solaris) @@ -1432,7 +1432,7 @@ static inline void my_exit ( int x ) MEMMOVE(VG_Z_LIBC_SONAME, memmoveZDVARIANTZDsse42) /* memmove$VARIANT$sse42 */ # if DARWIN_VERS >= DARWIN_10_9 /* _platform_memmove$VARIANT$Ivybridge, Nehelem etc. */ - MEMMOVE(libsystemZuplatformZddylib, ZuplatformZumemmoveZDVARIANTZDZa) + MEMMOVE(VG_Z_LIBSYSTEM_PLATFORM_SONAME, ZuplatformZumemmoveZDVARIANTZDZa) # endif #elif defined(VGO_solaris) @@ -2383,7 +2383,7 @@ static inline void my_exit ( int x ) #if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris) MEMCCPY(VG_Z_LIBC_SONAME, memccpy) #elif defined(VGO_darwin) - MEMCCPY(libsystemZuplatformZddylib, _platform_memccpy) + MEMCCPY(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memccpy) #endif /*---------------------- wcpncpy ----------------------*/ @@ -2428,7 +2428,7 @@ static inline void my_exit ( int x ) #if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris) WCPNCPY(VG_Z_LIBC_SONAME, wcpncpy) #elif defined(VGO_darwin) - WCPNCPY(libsystemZucZddylib, wcpncpy) + WCPNCPY(VG_Z_LIBSYSTEM_C_SONAME, wcpncpy) #endif /*----------------------- wcscat ----------------------*/ |
|
From: Paul F. <pa...@so...> - 2025-11-04 06:31:34
|
https://sourceware.org/cgit/valgrind/commit/?id=8a5e8c6bb7c77a8b47005a6fe5bb479293b408a2 commit 8a5e8c6bb7c77a8b47005a6fe5bb479293b408a2 Author: Paul Floyd <pj...@wa...> Date: Tue Nov 4 07:30:42 2025 +0100 Darwin: fix redir for memccpy Diff: --- memcheck/tests/filter_libc_variants | 2 +- memcheck/tests/memccpy2.vgtest | 1 + shared/vg_replace_strmem.c | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/memcheck/tests/filter_libc_variants b/memcheck/tests/filter_libc_variants index dce64d4a71..bfffa84689 100755 --- a/memcheck/tests/filter_libc_variants +++ b/memcheck/tests/filter_libc_variants @@ -2,4 +2,4 @@ ./filter_stderr "$@" | -sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /' +sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /;s/ _platform_memccpy / memccpy /' diff --git a/memcheck/tests/memccpy2.vgtest b/memcheck/tests/memccpy2.vgtest index 29039f1537..988a8cb1c4 100644 --- a/memcheck/tests/memccpy2.vgtest +++ b/memcheck/tests/memccpy2.vgtest @@ -1,2 +1,3 @@ prog: memccpy2 vgopts: -q +stderr_filter: filter_libc_variants diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 6cc26d9a82..28fda80ee2 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -2380,8 +2380,10 @@ static inline void my_exit ( int x ) return NULL; \ } -#if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris) MEMCCPY(VG_Z_LIBC_SONAME, memccpy) +#elif defined(VGO_darwin) + MEMCCPY(libsystemZuplatformZddylib, _platform_memccpy) #endif /*---------------------- wcpncpy ----------------------*/ |
|
From: Paul F. <pa...@so...> - 2025-11-03 20:57:42
|
https://sourceware.org/cgit/valgrind/commit/?id=7b21f1225f51c1fbd7eed122eaa06bfd16809ba9 commit 7b21f1225f51c1fbd7eed122eaa06bfd16809ba9 Author: Paul Floyd <pj...@wa...> Date: Mon Nov 3 21:56:42 2025 +0100 Darwin: add redir for wcpncpy Diff: --- .gitignore | 2 +- shared/vg_replace_strmem.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fb2aec2427..cfd8c7bd8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1050,7 +1050,7 @@ /memcheck/tests/wcscat /memcheck/tests/weirdioctl /memcheck/tests/with space -/memcheck/tests/wcpncpy +/memcheck/tests/wcpncpy1 /memcheck/tests/wcsncpy /memcheck/tests/wmemcmp /memcheck/tests/wrap1 diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index aaa4092570..6cc26d9a82 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -2425,6 +2425,8 @@ static inline void my_exit ( int x ) #if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris) WCPNCPY(VG_Z_LIBC_SONAME, wcpncpy) +#elif defined(VGO_darwin) + WCPNCPY(libsystemZucZddylib, wcpncpy) #endif /*----------------------- wcscat ----------------------*/ |
|
From: Paul F. <pa...@so...> - 2025-11-03 20:49:41
|
https://sourceware.org/cgit/valgrind/commit/?id=d2bd46b27e5357b983388d081b559863d7f1be9d commit d2bd46b27e5357b983388d081b559863d7f1be9d Author: Paul Floyd <pj...@wa...> Date: Mon Nov 3 21:43:17 2025 +0100 regtest: rename memcheck wcpncpy The perl script filter_memcheck removes callstack elements that are not of interest and changes vg_replace_strmem.c/vg_replace_malloc.c line numbers to '...'. It protects lines containing the testcase name. When the testcase name is the same as the C function being tested that's not really what we want. My perl isn't really good enough to be able to only change the line numbers when it is a 'tool file'. Instead I'm renaming the testcase. Diff: --- memcheck/tests/Makefile.am | 4 ++-- memcheck/tests/wcpncpy.stderr.exp | 19 ------------------- memcheck/tests/wcpncpy.vgtest | 3 --- memcheck/tests/{wcpncpy.c => wcpncpy1.c} | 0 memcheck/tests/wcpncpy1.stderr.exp | 19 +++++++++++++++++++ memcheck/tests/wcpncpy1.vgtest | 3 +++ 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 755f422ee5..6343b1b7c8 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -461,7 +461,7 @@ EXTRA_DIST = \ vcpu_fnfns.stdout.exp-darwin vcpu_fnfns.stdout.exp-solaris \ vcpu_fnfns.stdout.exp-illumos \ vcpu_fnfns.stderr.exp vcpu_fnfns.vgtest \ - wcpncpy.stderr.exp wcpncpy.vgtest \ + wcpncpy1.stderr.exp wcpncpy1.vgtest \ wcs.vgtest wcs.stderr.exp wcs.stdout.exp \ wcscat.vgtest wcscat.stderr.exp wcscat.stdout.exp \ wcsncpy.vgtest wcsncpy.stderr.exp \ @@ -656,7 +656,7 @@ check_PROGRAMS += threadname endif if HAVE_WCPNCPY -check_PROGRAMS += wcpncpy +check_PROGRAMS += wcpncpy1 endif # are there still pre-C99 C compilers? diff --git a/memcheck/tests/wcpncpy.stderr.exp b/memcheck/tests/wcpncpy.stderr.exp deleted file mode 100644 index 0ff9e5c741..0000000000 --- a/memcheck/tests/wcpncpy.stderr.exp +++ /dev/null @@ -1,19 +0,0 @@ -Conditional jump or move depends on uninitialised value(s) - at 0x........: wcpncpy (vg_replace_strmem.c:2427) - by 0x........: main (wcpncpy.c:14) - -Invalid write of size 4 - at 0x........: wcpncpy (vg_replace_strmem.c:2427) - by 0x........: main (wcpncpy.c:27) - Address 0x........ is 20 bytes inside a block of size 22 alloc'd - at 0x........: malloc (vg_replace_malloc.c:...) - by 0x........: main (wcpncpy.c:10) - -Source and destination overlap in wcpncpy(0x........, 0x........) - at 0x........: wcpncpy (vg_replace_strmem.c:2427) - by 0x........: main (wcpncpy.c:35) - -Source and destination overlap in wcpncpy(0x........, 0x........) - at 0x........: wcpncpy (vg_replace_strmem.c:2427) - by 0x........: main (wcpncpy.c:43) - diff --git a/memcheck/tests/wcpncpy.vgtest b/memcheck/tests/wcpncpy.vgtest deleted file mode 100644 index f4edd4b8d5..0000000000 --- a/memcheck/tests/wcpncpy.vgtest +++ /dev/null @@ -1,3 +0,0 @@ -prereq: test -e ./wcpncpy -prog: wcpncpy -vgopts: -q diff --git a/memcheck/tests/wcpncpy.c b/memcheck/tests/wcpncpy1.c similarity index 100% rename from memcheck/tests/wcpncpy.c rename to memcheck/tests/wcpncpy1.c diff --git a/memcheck/tests/wcpncpy1.stderr.exp b/memcheck/tests/wcpncpy1.stderr.exp new file mode 100644 index 0000000000..1b7fd22b8a --- /dev/null +++ b/memcheck/tests/wcpncpy1.stderr.exp @@ -0,0 +1,19 @@ +Conditional jump or move depends on uninitialised value(s) + at 0x........: wcpncpy (vg_replace_strmem.c:...) + by 0x........: main (wcpncpy1.c:14) + +Invalid write of size 4 + at 0x........: wcpncpy (vg_replace_strmem.c:...) + by 0x........: main (wcpncpy1.c:27) + Address 0x........ is 20 bytes inside a block of size 22 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (wcpncpy1.c:10) + +Source and destination overlap in wcpncpy(0x........, 0x........) + at 0x........: wcpncpy (vg_replace_strmem.c:...) + by 0x........: main (wcpncpy1.c:35) + +Source and destination overlap in wcpncpy(0x........, 0x........) + at 0x........: wcpncpy (vg_replace_strmem.c:...) + by 0x........: main (wcpncpy1.c:43) + diff --git a/memcheck/tests/wcpncpy1.vgtest b/memcheck/tests/wcpncpy1.vgtest new file mode 100644 index 0000000000..052393a397 --- /dev/null +++ b/memcheck/tests/wcpncpy1.vgtest @@ -0,0 +1,3 @@ +prereq: test -e ./wcpncpy1 +prog: wcpncpy1 +vgopts: -q |
|
From: Paul F. <pa...@so...> - 2025-11-02 16:47:19
|
https://sourceware.org/cgit/valgrind/commit/?id=ba27d633e870caea84a6b27774c021922c573e0e commit ba27d633e870caea84a6b27774c021922c573e0e Author: Paul Floyd <pj...@wa...> Date: Sun Nov 2 17:45:36 2025 +0100 Bug 413369 - unhandled amd64-darwin syscall: unix:151 (getpgid) Diff: --- .gitignore | 1 + NEWS | 1 + coregrind/m_syswrap/syswrap-darwin.c | 6 +++--- none/tests/darwin/Makefile.am | 2 ++ none/tests/darwin/bug411369.c | 16 ++++++++++++++++ none/tests/darwin/bug411369.stderr.exp | 0 none/tests/darwin/bug411369.vgtest | 2 ++ 7 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 03eecd1ed6..fb2aec2427 100644 --- a/.gitignore +++ b/.gitignore @@ -1892,6 +1892,7 @@ /none/tests/darwin/bug228343 /none/tests/darwin/bug254164 /none/tests/darwin/bug390269 +/none/tests/darwin/bug411369 /none/tests/darwin/rlimit # /none/tests/linux/ diff --git a/NEWS b/NEWS index 526969ebfa..0941034a6d 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. +413369 unhandled amd64-darwin syscall: unix:151 (getpgid) 487055 memcheck/tests/x86-linux/scalar fails running in Docker 511329 Darwin and FreeBSD: Move setting of carry flag out of ML_(do_syscall_for_client_WRK) diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index de8c37fc3e..62bd589ae2 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -10652,8 +10652,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { GENXY(__NR_mincore, sys_mincore), GENXY(__NR_getgroups, sys_getgroups), // _____(__NR_setgroups), // 80 - GENX_(__NR_getpgrp, sys_getpgrp), - GENX_(__NR_setpgid, sys_setpgid), + GENX_(__NR_getpgrp, sys_getpgrp), + GENX_(__NR_setpgid, sys_setpgid), GENXY(__NR_setitimer, sys_setitimer), _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(84)), // old wait // _____(__NR_swapon), @@ -10722,7 +10722,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(148)), // old setquota _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(149)), // old qquota _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(150)), // old getsockname -// _____(__NR_getpgid), + GENX_(__NR_getpgid, sys_getpgid), // _____(__NR_setprivexec), GENXY(__NR_pread, sys_pread64), GENX_(__NR_pwrite, sys_pwrite64), diff --git a/none/tests/darwin/Makefile.am b/none/tests/darwin/Makefile.am index d19fc4aef3..085f049a81 100644 --- a/none/tests/darwin/Makefile.am +++ b/none/tests/darwin/Makefile.am @@ -9,6 +9,7 @@ EXTRA_DIST = \ bug228343.stderr.exp bug228343.stdout.exp bug228343.vgtest \ bug254164.stderr.exp bug254164.vgtest \ bug390269.stderr.exp bug390269.vgtest \ + bug411369.stderr.exp bug411369.vgtest \ rlimit.stderr.exp rlimit.vgtest check_PROGRAMS = \ @@ -17,6 +18,7 @@ check_PROGRAMS = \ bug228343 \ bug254164 \ bug390269 \ + bug411369 \ rlimit diff --git a/none/tests/darwin/bug411369.c b/none/tests/darwin/bug411369.c new file mode 100644 index 0000000000..ac49306711 --- /dev/null +++ b/none/tests/darwin/bug411369.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <unistd.h> + +int main() +{ + int pgid; + + if ((pgid = getpgid(0)) == -1) + perror("getpgid"); +/* + else + printf("pgid : %d\n", pgid); +*/ + return pgid; +} + diff --git a/none/tests/darwin/bug411369.stderr.exp b/none/tests/darwin/bug411369.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/darwin/bug411369.vgtest b/none/tests/darwin/bug411369.vgtest new file mode 100644 index 0000000000..b2b477f353 --- /dev/null +++ b/none/tests/darwin/bug411369.vgtest @@ -0,0 +1,2 @@ +prog: bug411369 +vgopts: -q |
|
From: Paul F. <pa...@so...> - 2025-11-01 19:09:57
|
https://sourceware.org/cgit/valgrind/commit/?id=ab5770e5c5d0d580b2c12e91d758ca12684b96f0 commit ab5770e5c5d0d580b2c12e91d758ca12684b96f0 Author: Paul Floyd <pj...@wa...> Date: Sat Nov 1 19:55:00 2025 +0100 And remove the one that I copied and pasted the wrong name Diff: --- .../duplicate_align_size_errors.stderr.out-darwin | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/memcheck/tests/duplicate_align_size_errors.stderr.out-darwin b/memcheck/tests/duplicate_align_size_errors.stderr.out-darwin deleted file mode 100644 index 93faa3d16a..0000000000 --- a/memcheck/tests/duplicate_align_size_errors.stderr.out-darwin +++ /dev/null @@ -1,22 +0,0 @@ -Invalid alignment value: 0 (should be non-zero and a power of 2) - at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (duplicate_align_size_errors.cpp:19) - -Invalid alignment value: 0 (should be non-zero and a power of 2) - at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) - by 0x........: main (duplicate_align_size_errors.cpp:20) - -Mismatched new/delete size value: 33 - at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (duplicate_align_size_errors.cpp:43) - Address 0x........ is 0 bytes inside a block of size 32 alloc'd - at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (duplicate_align_size_errors.cpp:42) - -Mismatched new[]/delete[] alignment alloc value: 64 dealloc value: 128 - at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (duplicate_align_size_errors.cpp:48) - Address 0x........ is 0 bytes inside a block of size 32 alloc'd - at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) - by 0x........: main (duplicate_align_size_errors.cpp:47) - |
|
From: Paul F. <pa...@so...> - 2025-11-01 18:53:19
|
https://sourceware.org/cgit/valgrind/commit/?id=d5bd1e62083bb6e75cf78b4aa80fb569c08277a8 commit d5bd1e62083bb6e75cf78b4aa80fb569c08277a8 Author: Paul Floyd <pj...@wa...> Date: Sat Nov 1 19:52:53 2025 +0100 Add missing expected Diff: --- .../duplicate_align_size_errors.stderr.exp-darwin | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/memcheck/tests/duplicate_align_size_errors.stderr.exp-darwin b/memcheck/tests/duplicate_align_size_errors.stderr.exp-darwin new file mode 100644 index 0000000000..93faa3d16a --- /dev/null +++ b/memcheck/tests/duplicate_align_size_errors.stderr.exp-darwin @@ -0,0 +1,22 @@ +Invalid alignment value: 0 (should be non-zero and a power of 2) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:19) + +Invalid alignment value: 0 (should be non-zero and a power of 2) + at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:20) + +Mismatched new/delete size value: 33 + at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:43) + Address 0x........ is 0 bytes inside a block of size 32 alloc'd + at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:42) + +Mismatched new[]/delete[] alignment alloc value: 64 dealloc value: 128 + at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:48) + Address 0x........ is 0 bytes inside a block of size 32 alloc'd + at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:47) + |
|
From: Paul F. <pa...@so...> - 2025-11-01 16:04:56
|
https://sourceware.org/cgit/valgrind/commit/?id=87631266a5375a5fad1e6e0cb20c93ed8b7ef43f commit 87631266a5375a5fad1e6e0cb20c93ed8b7ef43f Author: Paul Floyd <pj...@wa...> Date: Sat Nov 1 16:56:20 2025 +0100 Darwin regtest: add an expected for duplicate_align_size_errors Also start trying to del with some redir issues. For some libc functions the plain function gets replaced by a checked version (not sure if this is only for debug builds). For instance in /usr/include/secure/_string.h there are a load of macros that look like /* void *memccpy(void *dst, const void *src, int c, size_t n) */ __builtin___memccpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest)) To defeat these macros I've put the function name in parens. That hasn't solved the issue. In addition these seems to be an ifunc like mechanism that resolves calls to platform functions. For instance nm /usr/lib/system/*dylib | grep memcc 0000000000081e14 T ___memccpy_chk U __platform_memccpy I _memccpy (indirect for __platform_memccpy) 0000000000004eb4 T __platform_memccpy That matches what I see in lldb (memccpy then function lookup code then _platform_memccpy). Need to look at how indirects work. Diff: --- memcheck/tests/Makefile.am | 1 + .../duplicate_align_size_errors.stderr.out-darwin | 22 ++++++++++++++++++++++ memcheck/tests/memccpy2.c | 8 ++++---- memcheck/tests/overlap.c | 10 +++++----- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index fd3f89cd28..755f422ee5 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -168,6 +168,7 @@ EXTRA_DIST = \ cxx17_aligned_new.stdout.exp \ duplicate_align_size_errors.stderr.exp \ duplicate_align_size_errors.stderr.exp-memalign \ + duplicate_align_size_errors.stderr.exp-darwin \ duplicate_align_size_errors.vgtest \ sized_aligned_new_delete_args.stderr.exp \ sized_aligned_new_delete_args.vgtest \ diff --git a/memcheck/tests/duplicate_align_size_errors.stderr.out-darwin b/memcheck/tests/duplicate_align_size_errors.stderr.out-darwin new file mode 100644 index 0000000000..93faa3d16a --- /dev/null +++ b/memcheck/tests/duplicate_align_size_errors.stderr.out-darwin @@ -0,0 +1,22 @@ +Invalid alignment value: 0 (should be non-zero and a power of 2) + at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:19) + +Invalid alignment value: 0 (should be non-zero and a power of 2) + at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:20) + +Mismatched new/delete size value: 33 + at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:43) + Address 0x........ is 0 bytes inside a block of size 32 alloc'd + at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:42) + +Mismatched new[]/delete[] alignment alloc value: 64 dealloc value: 128 + at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:48) + Address 0x........ is 0 bytes inside a block of size 32 alloc'd + at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...) + by 0x........: main (duplicate_align_size_errors.cpp:47) + diff --git a/memcheck/tests/memccpy2.c b/memcheck/tests/memccpy2.c index 9473245817..be7808d5fd 100644 --- a/memcheck/tests/memccpy2.c +++ b/memcheck/tests/memccpy2.c @@ -8,9 +8,9 @@ int main(void) { char* astring = strdup("this is a string # with something to seek"); size_t len = strlen(astring); - memccpy(astring+10, astring, '#', len-10); + (memccpy)(astring+10, astring, '#', len-10); sprintf(astring, "this is a string # with something to seek"); - memccpy(astring, astring+10, '#', len); + (memccpy)(astring, astring+10, '#', len); sprintf(astring, "this is a string # with something to seek"); /* @@ -23,10 +23,10 @@ int main(void) assert(res && *res == 'g'); sprintf(astring, "this is a string # with something to seek"); /* length is 0, nothing copied, returns NULL */ - res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0); + res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0); assert(NULL == res); /* 'z' not found so 20 bytes copied, returns NULL */ - res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20); + res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20); assert(NULL == res); free(astring); } diff --git a/memcheck/tests/overlap.c b/memcheck/tests/overlap.c index d868886f38..649b1e34d3 100644 --- a/memcheck/tests/overlap.c +++ b/memcheck/tests/overlap.c @@ -42,16 +42,16 @@ int main(void) memcpy(x, x+20, 21); // overlap strncpy(x+20, x, 20); // ok - strncpy(x+20, x, 21); // overlap + (strncpy)(x+20, x, 21); // overlap strncpy(x, x+20, 20); // ok - strncpy(x, x+20, 21); // overlap + (strncpy)(x, x+20, 21); // overlap x[39] = '\0'; strcpy(x, x+20); // ok x[39] = 39; x[40] = '\0'; - strcpy(x, x+20); // overlap + (strcpy)(x, x+20); // overlap x[19] = '\0'; strcpy(x+20, x); // ok @@ -109,8 +109,8 @@ int main(void) always run forever, I think... */ for ( i = 0; i < 2; i++) - strncat(a+20, a, 21); // run twice to check 2nd error isn't shown - strncat(a, a+20, 21); + (strncat)(a+20, a, 21); // run twice to check 2nd error isn't shown + (strncat)(a, a+20, 21); /* This is ok, but once gave a warning when strncpy() was wrong, and used 'n' for the length, even when the src was shorter than 'n' */ |
|
From: Paul F. <pa...@so...> - 2025-11-01 12:38:35
|
https://sourceware.org/cgit/valgrind/commit/?id=5ef9990f8714b189e7f4770bb47627758397811d commit 5ef9990f8714b189e7f4770bb47627758397811d Author: Paul Floyd <pj...@wa...> Date: Sat Nov 1 13:37:28 2025 +0100 Darwin regtest: use -q in 2 tests with heap summary diffs Diff: --- memcheck/tests/bug155125.stderr.exp | 10 ---------- memcheck/tests/bug155125.vgtest | 1 + memcheck/tests/bug287260.stderr.exp | 10 ---------- memcheck/tests/bug287260.vgtest | 1 + 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/memcheck/tests/bug155125.stderr.exp b/memcheck/tests/bug155125.stderr.exp index ca0025db50..a9c0faf6cd 100644 --- a/memcheck/tests/bug155125.stderr.exp +++ b/memcheck/tests/bug155125.stderr.exp @@ -1,15 +1,5 @@ - Argument 'size' of function malloc has a fishy (possibly negative) value: -10 at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: leak_begin_01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 8901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 67890123456789012345678901234567890123456789_end (bug155125.c:4) by 0x........: main (bug155125.c:7) - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 0 allocs, 0 frees, 0 bytes allocated - -For a detailed leak analysis, rerun with: --leak-check=full - -For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/bug155125.vgtest b/memcheck/tests/bug155125.vgtest index d25f61e0ad..871699b4c2 100644 --- a/memcheck/tests/bug155125.vgtest +++ b/memcheck/tests/bug155125.vgtest @@ -1 +1,2 @@ prog: bug155125 +vgopts: -q diff --git a/memcheck/tests/bug287260.stderr.exp b/memcheck/tests/bug287260.stderr.exp index 6a3b8682b3..ea90ee3198 100644 --- a/memcheck/tests/bug287260.stderr.exp +++ b/memcheck/tests/bug287260.stderr.exp @@ -1,11 +1 @@ - 45 - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 0 allocs, 0 frees, 0 bytes allocated - -For a detailed leak analysis, rerun with: --leak-check=full - -For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/bug287260.vgtest b/memcheck/tests/bug287260.vgtest index 928ef80788..78a9af5c34 100644 --- a/memcheck/tests/bug287260.vgtest +++ b/memcheck/tests/bug287260.vgtest @@ -1 +1,2 @@ prog: bug287260 +vgopts: -q |
|
From: Paul F. <pa...@so...> - 2025-11-01 12:20:56
|
https://sourceware.org/cgit/valgrind/commit/?id=ad031f8edba0020878e44eb6902b323bab42074b commit ad031f8edba0020878e44eb6902b323bab42074b Author: Paul Floyd <pj...@wa...> Date: Sat Nov 1 13:20:04 2025 +0100 clang-tidy: fix some redundant cast warnings. Diff: --- coregrind/m_syswrap/syswrap-generic.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 37f312fe8f..6050f5b65d 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -3381,7 +3381,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, PRE_MEM_READ(str2, arg_2_check, sizeof(Addr)); /* argv[0] should not be NULL and valid. */ - if (ML_(safe_to_deref)((HChar **) (Addr)arg_2_check, sizeof(HChar *))) { + if (ML_(safe_to_deref)((HChar **)arg_2_check, sizeof(HChar *))) { Addr argv0 = *(Addr*)arg_2_check; PRE_MEM_RASCIIZ( str3, argv0 ); /* The rest of argv can be NULL or a valid string pointer. */ @@ -3400,7 +3400,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, str3[VG_(strlen)(str)] = '\0'; if (arg_3 != 0) { /* At least the terminating NULL must be addressable. */ - if (!ML_(safe_to_deref)((HChar **) (Addr)arg_3, sizeof(HChar *))) { + if (!ML_(safe_to_deref)((HChar **)arg_3, sizeof(HChar *))) { SET_STATUS_Failure(VKI_EFAULT); return; } @@ -3429,11 +3429,11 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, // debug-only printing if (0) { - VG_(printf)("pathname = %p(%s)\n", (void*)(Addr)pathname, (HChar*)(Addr)pathname); + VG_(printf)("pathname = %p(%s)\n", (void*)pathname, (HChar*)pathname); if (arg_2) { VG_(printf)("arg_2 = "); Int q; - HChar** vec = (HChar**)(Addr)arg_2; + HChar** vec = (HChar**)arg_2; for (q = 0; vec[q]; q++) VG_(printf)("%p(%s) ", vec[q], vec[q]); VG_(printf)("\n"); @@ -3445,10 +3445,10 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, // Decide whether or not we want to follow along { // Make 'child_argv' be a pointer to the child's arg vector // (skipping the exe name) - const HChar** child_argv = (const HChar**)(Addr)arg_2; + const HChar** child_argv = (const HChar**)arg_2; if (child_argv && child_argv[0] == NULL) child_argv = NULL; - trace_this_child = VG_(should_we_trace_this_child)( (HChar*)(Addr)pathname, + trace_this_child = VG_(should_we_trace_this_child)( (HChar*)pathname, child_argv ); } @@ -3456,7 +3456,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, // ok, etc. We allow setuid executables to run only in the case when // we are not simulating them, that is, they to be run natively. setuid_allowed = trace_this_child ? False : True; - res = VG_(pre_exec_check)((const HChar *)(Addr)pathname, NULL, setuid_allowed); + res = VG_(pre_exec_check)((const HChar *)pathname, NULL, setuid_allowed); if (sr_isError(res)) { SET_STATUS_Failure( sr_Err(res) ); return; @@ -3473,7 +3473,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, } /* After this point, we can't recover if the execve fails. */ - VG_(debugLog)(1, "syswrap", "Exec of %s\n", (HChar*)(Addr)pathname); + VG_(debugLog)(1, "syswrap", "Exec of %s\n", (HChar*)pathname); // Terminate gdbserver if it is active. @@ -3509,7 +3509,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, } } else { - path = (HChar*)(Addr)pathname; + path = (HChar*)pathname; } // Set up the child's environment. @@ -3526,7 +3526,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, if (arg_3 == 0) { envp = NULL; } else { - envp = VG_(env_clone)( (HChar**)(Addr)arg_3 ); + envp = VG_(env_clone)( (HChar**)arg_3 ); if (envp == NULL) goto hosed; VG_(env_remove_valgrind_env_stuff)( envp, True /*ro_strings*/, NULL ); } @@ -3545,7 +3545,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, // are omitted. // if (!trace_this_child) { - argv = (HChar**)(Addr)arg_2; + argv = (HChar**)arg_2; } else { vg_assert( VG_(args_for_valgrind) ); vg_assert( VG_(args_for_valgrind_noexecpass) >= 0 ); @@ -3560,7 +3560,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, // name of client exe tot_args++; // args for client exe, skipping [0] - arg2copy = (HChar**)(Addr)arg_2; + arg2copy = (HChar**)arg_2; if (arg2copy && arg2copy[0]) { for (i = 1; arg2copy[i]; i++) tot_args++; @@ -3576,7 +3576,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, continue; argv[j++] = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i ); } - argv[j++] = (HChar*)(Addr)pathname; + argv[j++] = (HChar*)pathname; if (arg2copy && arg2copy[0]) for (i = 1; arg2copy[i]; i++) argv[j++] = arg2copy[i]; @@ -3650,7 +3650,7 @@ void handle_pre_sys_execve(ThreadId tid, SyscallStatus *status, Addr pathname, vg_assert(FAILURE); VG_(message)(Vg_UserMsg, "execve(%#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %#" FMT_REGWORD "x) failed, errno %lu\n", - pathname, (HChar*)(Addr)pathname, arg_2, arg_3, ERR); + pathname, (HChar*)pathname, arg_2, arg_3, ERR); VG_(message)(Vg_UserMsg, "EXEC FAILED: I can't recover from " "execve() failing, so I'm dying.\n"); VG_(message)(Vg_UserMsg, "Add more stringent tests in PRE(sys_execve), " |
|
From: Paul F. <pa...@so...> - 2025-11-01 12:19:44
|
https://sourceware.org/cgit/valgrind/commit/?id=723f23f9797cdf3c5e060f51600a77c74fb38620 commit 723f23f9797cdf3c5e060f51600a77c74fb38620 Author: Paul Floyd <pj...@wa...> Date: Sat Nov 1 13:19:11 2025 +0100 Darwin suppression: add a leak suppression for fwrite Diff: --- darwin17.supp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/darwin17.supp b/darwin17.supp index 503e7f2ee2..c701782af8 100644 --- a/darwin17.supp +++ b/darwin17.supp @@ -198,6 +198,17 @@ fun:_ZN4dyld24initializeMainExecutableEv } +{ + OSX1013:22-Leak + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:__smakebuf + fun:__swsetup + fun:__sfvwrite + fun:fwrite +} + ############################################ ## Non-leak errors |
|
From: Paul F. <pa...@so...> - 2025-10-30 21:03:20
|
https://sourceware.org/cgit/valgrind/commit/?id=78ea7c823789e59c0881eb9eb1582e3f3e48dd0d commit 78ea7c823789e59c0881eb9eb1582e3f3e48dd0d Author: Paul Floyd <pj...@wa...> Date: Thu Oct 30 22:01:44 2025 +0100 Darwin regtest: another leaky xml test and a suppression test The suppression test needed to use the same lable for Darwin and other OSes. Diff: --- memcheck/tests/posix_memalign_supp.supp | 2 +- memcheck/tests/posix_memalign_xml.vgtest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/memcheck/tests/posix_memalign_supp.supp b/memcheck/tests/posix_memalign_supp.supp index 23572e40f1..b0e59a1af5 100644 --- a/memcheck/tests/posix_memalign_supp.supp +++ b/memcheck/tests/posix_memalign_supp.supp @@ -15,7 +15,7 @@ # Darwin uses zones { - posix_memalign zero size + posix_memalign size Memcheck:UnsafeZeroSize fun:malloc_zone_memalign fun:posix_memalign diff --git a/memcheck/tests/posix_memalign_xml.vgtest b/memcheck/tests/posix_memalign_xml.vgtest index db119d9528..eb587be174 100644 --- a/memcheck/tests/posix_memalign_xml.vgtest +++ b/memcheck/tests/posix_memalign_xml.vgtest @@ -1,3 +1,3 @@ prog: posix_memalign vgopts: --freelist-vol=100000 --freelist-big-blocks=0 --xml=yes --xml-fd=2 --log-file=/dev/null -stderr_filter: filter_xml +stderr_filter: filter_xml_leak |
|
From: Paul F. <pa...@so...> - 2025-10-30 20:33:10
|
https://sourceware.org/cgit/valgrind/commit/?id=8aaa1412415f0ee367fd950e199276082833cba1 commit 8aaa1412415f0ee367fd950e199276082833cba1 Author: Paul Floyd <pj...@wa...> Date: Thu Oct 30 21:29:28 2025 +0100 Darwin regtest: various filters Use -q to hide Darwin leaks in HEAP SUMMARY The pcmpgt test uses uint64_t whish is unsigned long long on Darwin but unsigned long on all other amd64 OSes Swap malloc_zone_memalign with posix_memalign Diff: --- memcheck/tests/amd64/Makefile.am | 2 +- memcheck/tests/amd64/bug492210_1.vgtest | 1 + memcheck/tests/amd64/bug492210_2.vgtest | 1 + memcheck/tests/amd64/filter_malloc_zone | 4 ++++ memcheck/tests/amd64/filter_pcmpgt | 7 +++++++ memcheck/tests/amd64/pcmpgt.vgtest | 2 +- memcheck/tests/amd64/sh-mem-vec128-plo-no.vgtest | 3 ++- memcheck/tests/amd64/sh-mem-vec128-plo-yes.vgtest | 3 ++- .../tests/common/sh-mem-vec128-plo-no.stderr.exp-64bit-le | 11 ----------- .../tests/common/sh-mem-vec128-plo-yes.stderr.exp-64bit-le | 11 ----------- 10 files changed, 19 insertions(+), 26 deletions(-) diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index 98f3f78fa1..4b25e1dcfc 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/Makefile.tool-tests.am -dist_noinst_SCRIPTS = filter_stderr +dist_noinst_SCRIPTS = filter_stderr filter_malloc_zone filter_pcmpgt INSN_TESTS = insn_basic insn_mmx insn_sse insn_sse2 insn_fpu diff --git a/memcheck/tests/amd64/bug492210_1.vgtest b/memcheck/tests/amd64/bug492210_1.vgtest index e80be84ec8..9a50eaf72a 100644 --- a/memcheck/tests/amd64/bug492210_1.vgtest +++ b/memcheck/tests/amd64/bug492210_1.vgtest @@ -1,3 +1,4 @@ +prereq: test -e bug492210 prog: bug492210 vgopts: -q diff --git a/memcheck/tests/amd64/bug492210_2.vgtest b/memcheck/tests/amd64/bug492210_2.vgtest index 1c4e3614f8..159e836bf2 100644 --- a/memcheck/tests/amd64/bug492210_2.vgtest +++ b/memcheck/tests/amd64/bug492210_2.vgtest @@ -1,3 +1,4 @@ +prereq: test -e bug492210 prog: bug492210 vgopts: -q --expensive-definedness-checks=yes diff --git a/memcheck/tests/amd64/filter_malloc_zone b/memcheck/tests/amd64/filter_malloc_zone new file mode 100755 index 0000000000..442d2c46f5 --- /dev/null +++ b/memcheck/tests/amd64/filter_malloc_zone @@ -0,0 +1,4 @@ +#! /bin/sh + +./filter_stderr "$@" | +sed 's/malloc_zone_memalign/posix_memalign/' diff --git a/memcheck/tests/amd64/filter_pcmpgt b/memcheck/tests/amd64/filter_pcmpgt new file mode 100755 index 0000000000..8243e1bf4a --- /dev/null +++ b/memcheck/tests/amd64/filter_pcmpgt @@ -0,0 +1,7 @@ +#! /bin/sh + +../filter_allocs "$@" | + +# on Darwin "uint64_t" becomes unsigned long long +# on other platforms it is unsigned long +sed 's/unsigned long long/unsigned long/' diff --git a/memcheck/tests/amd64/pcmpgt.vgtest b/memcheck/tests/amd64/pcmpgt.vgtest index 15e0d76051..6b7deafe62 100644 --- a/memcheck/tests/amd64/pcmpgt.vgtest +++ b/memcheck/tests/amd64/pcmpgt.vgtest @@ -1,3 +1,3 @@ prog: pcmpgt amd64 prereq: test -e pcmpgt -stderr_filter: ../filter_allocs +stderr_filter: filter_pcmpgt diff --git a/memcheck/tests/amd64/sh-mem-vec128-plo-no.vgtest b/memcheck/tests/amd64/sh-mem-vec128-plo-no.vgtest index 160b95b28b..e167b251bb 100644 --- a/memcheck/tests/amd64/sh-mem-vec128-plo-no.vgtest +++ b/memcheck/tests/amd64/sh-mem-vec128-plo-no.vgtest @@ -1,3 +1,4 @@ prog: sh-mem-vec128 args: -q -vgopts: --partial-loads-ok=no +vgopts: --partial-loads-ok=no -q +stderr_filter: filter_malloc_zone diff --git a/memcheck/tests/amd64/sh-mem-vec128-plo-yes.vgtest b/memcheck/tests/amd64/sh-mem-vec128-plo-yes.vgtest index 76585dd373..c4216eb2cf 100644 --- a/memcheck/tests/amd64/sh-mem-vec128-plo-yes.vgtest +++ b/memcheck/tests/amd64/sh-mem-vec128-plo-yes.vgtest @@ -1,3 +1,4 @@ prog: sh-mem-vec128 args: -q -vgopts: --partial-loads-ok=yes +vgopts: --partial-loads-ok=yes -q +stderr_filter: filter_malloc_zone diff --git a/memcheck/tests/common/sh-mem-vec128-plo-no.stderr.exp-64bit-le b/memcheck/tests/common/sh-mem-vec128-plo-no.stderr.exp-64bit-le index 5edfff1a5d..e778627240 100644 --- a/memcheck/tests/common/sh-mem-vec128-plo-no.stderr.exp-64bit-le +++ b/memcheck/tests/common/sh-mem-vec128-plo-no.stderr.exp-64bit-le @@ -1,4 +1,3 @@ - sh-mem-vec128: config: little-endian, 64-bit word size 20537 136 171 75 38 63 139 23 5 110 66 421 194 86 232 115 @@ -529,13 +528,3 @@ Invalid read of size 16 dddddddddddddddd - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 33 allocs, 33 frees, 82,048 bytes allocated - -For a detailed leak analysis, rerun with: --leak-check=full - -Use --track-origins=yes to see where uninitialised values come from -For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 66 errors from 66 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/common/sh-mem-vec128-plo-yes.stderr.exp-64bit-le b/memcheck/tests/common/sh-mem-vec128-plo-yes.stderr.exp-64bit-le index d05ac5e826..86abd93cce 100644 --- a/memcheck/tests/common/sh-mem-vec128-plo-yes.stderr.exp-64bit-le +++ b/memcheck/tests/common/sh-mem-vec128-plo-yes.stderr.exp-64bit-le @@ -1,4 +1,3 @@ - sh-mem-vec128: config: little-endian, 64-bit word size 20537 136 171 75 38 63 139 23 5 110 66 421 194 86 232 115 @@ -436,13 +435,3 @@ Invalid read of size 16 dddddddddddddddd - -HEAP SUMMARY: - in use at exit: 0 bytes in 0 blocks - total heap usage: 33 allocs, 33 frees, 82,048 bytes allocated - -For a detailed leak analysis, rerun with: --leak-check=full - -Use --track-origins=yes to see where uninitialised values come from -For lists of detected and suppressed errors, rerun with: -s -ERROR SUMMARY: 51 errors from 51 contexts (suppressed: 0 from 0) |