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
(102) |
Dec
(70) |
|
From: Paul F. <pa...@so...> - 2025-12-20 18:45:16
|
https://sourceware.org/cgit/valgrind/commit/?id=acd5cb6c8d7d38c86103494a8c0f934da1d97f4a commit acd5cb6c8d7d38c86103494a8c0f934da1d97f4a Author: Paul Floyd <pj...@wa...> Date: Sat Dec 20 19:44:39 2025 +0100 Darwin: revert a bit of overzealous merging Diff: --- coregrind/fixup_macho_loadcmds.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/coregrind/fixup_macho_loadcmds.c b/coregrind/fixup_macho_loadcmds.c index 0031177ee9..a6699baed4 100644 --- a/coregrind/fixup_macho_loadcmds.c +++ b/coregrind/fixup_macho_loadcmds.c @@ -117,18 +117,10 @@ #include <mach-o/fat.h> #include <mach/i386/thread_status.h> -/* Get hold of DARWIN_VERS, and check it has a sane value. */ +/* Check that DARWIN_VERS is defined */ #include "config.h" -#if DARWIN_VERS != DARWIN_10_5 && DARWIN_VERS != DARWIN_10_6 \ - && DARWIN_VERS != DARWIN_10_7 && DARWIN_VERS != DARWIN_10_8 \ - && DARWIN_VERS != DARWIN_10_9 && DARWIN_VERS != DARWIN_10_10 \ - && DARWIN_VERS != DARWIN_10_11 && DARWIN_VERS != DARWIN_10_12 \ - && DARWIN_VERS != DARWIN_10_13 && DARWIN_VERS != DARWIN_10_14 \ - && DARWIN_VERS != DARWIN_10_15 && DARWIN_VERS != DARWIN_11_00 \ - && DARWIN_VERS != DARWIN_12_00 && DARWIN_VERS != DARWIN_13_00 \ - && DARWIN_VERS != DARWIN_14_00 && DARWIN_VERS != DARWIN_15_00 \ - && DARWIN_VERS != DARWIN_15_04 && DARWIN_VERS != DARWIN_26_00 -# error "Unknown DARWIN_VERS value. This file only compiles on Darwin." +#if !defined(DARWIN_VERS) +# error "DARWIN_VERS not defind. This file only compiles on Darwin." #endif @@ -581,7 +573,7 @@ void modify_macho_loadcmds ( HChar* filename, seg__pagezero->vmaddr = 0; # endif - out: + out: if (ii.img) unmap_image(&ii); } |
|
From: Paul F. <pa...@so...> - 2025-12-20 17:52:46
|
https://sourceware.org/cgit/valgrind/commit/?id=876baafa315b5b2c82d972a12916e51811e5da6a commit 876baafa315b5b2c82d972a12916e51811e5da6a Author: Paul Floyd <pj...@wa...> Date: Sat Dec 20 18:51:43 2025 +0100 Darwin: fix a compiler warning Make a function static since it's only used in the one compilation unit. Diff: --- coregrind/m_mach/dyld_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/m_mach/dyld_cache.c b/coregrind/m_mach/dyld_cache.c index 953cccd5fb..8c5b9a3b1d 100644 --- a/coregrind/m_mach/dyld_cache.c +++ b/coregrind/m_mach/dyld_cache.c @@ -211,7 +211,7 @@ Addr VG_(dyld_cache_get_slide)(void) { return dyld_cache.slide; } -int ensure_init(void) { +static int ensure_init(void) { if (dyld_cache.header != NULL) { return 1; } |
|
From: Paul F. <pa...@so...> - 2025-12-20 14:48:59
|
https://sourceware.org/cgit/valgrind/commit/?id=eab939e9c9a8893556b83f68424d087bbafeb5d9 commit eab939e9c9a8893556b83f68424d087bbafeb5d9 Author: Paul Floyd <pj...@wa...> Date: Sat Dec 20 13:01:26 2025 +0100 Bug 513533 - Support macOS 11.0 (Big Sur) Most of the work for this was done by Louis Brunner. Thanks Louis. Diff: --- NEWS | 8 +- configure.ac | 4 + coregrind/Makefile.am | 1 + coregrind/fixup_macho_loadcmds.c | 24 +- coregrind/m_debuginfo/debuginfo.c | 60 +++ coregrind/m_debuginfo/image.c | 54 ++- coregrind/m_debuginfo/priv_storage.h | 6 + coregrind/m_initimg/initimg-darwin.c | 54 ++- coregrind/m_mach/dyld_cache.c | 504 ++++++++++++++++++++++++ coregrind/m_mach/priv_dyld_internals.h | 146 +++++++ coregrind/m_main.c | 12 + coregrind/m_replacemalloc/vg_replace_malloc.c | 33 +- coregrind/m_syswrap/priv_syswrap-darwin.h | 21 +- coregrind/m_syswrap/syswrap-darwin.c | 154 +++++++- coregrind/pub_core_debuginfo.h | 4 + coregrind/pub_core_initimg.h | 3 + darwin-drd.supp | 7 + darwin-helgrind.supp | 14 + darwin.supp | 27 ++ helgrind/tests/Makefile.am | 1 + helgrind/tests/filter_darwin.awk | 152 +++++++ helgrind/tests/filter_stderr.in | 3 +- include/vki/vki-darwin.h | 11 + include/vki/vki-scnums-darwin.h | 14 + memcheck/mc_main.c | 4 +- memcheck/tests/Makefile.am | 1 + memcheck/tests/memalign_args.stderr.exp-darwin3 | 11 + none/tests/darwin/apple-main-arg.c | 12 +- none/tests/filter_fdleak | 17 +- 29 files changed, 1320 insertions(+), 42 deletions(-) diff --git a/NEWS b/NEWS index 6360e83a5b..51f0b301a8 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,7 @@ PPC32/Linux, PPC64BE/Linux, PPC64LE/Linux, S390X/Linux, MIPS32/Linux, MIPS64/Linux, RISCV64/Linux, ARM/Android, ARM64/Android, MIPS32/Android, X86/Android, X86/Solaris, AMD64/Solaris, X86/macOS, AMD64/macOS. X86/FreeBSD, AMD64/FreeBSD and ARM64/FreeBSD. There is preliminary support -for nanoMIPS/Linux. macOS is supported up to version 10.15 Catalina. +for nanoMIPS/Linux. macOS is supported up to version 11 Big Sur (amd64 only). * ==================== CORE CHANGES =================== @@ -14,7 +14,11 @@ for nanoMIPS/Linux. macOS is supported up to version 10.15 Catalina. s390x: Machine models older than z196 are no longer supported. -Initial support for macOS 10.14 Mojave has been added. +Support for the following macOS versions has been added +10,13 High Sierra (bug fixes) +10.14 Mojave +10.15 Calalina +11.0 Big Sur * ==================== TOOL CHANGES =================== diff --git a/configure.ac b/configure.ac index 55d26b2a51..528e44b300 100644 --- a/configure.ac +++ b/configure.ac @@ -550,6 +550,10 @@ case "${host_os}" in AC_MSG_RESULT([Darwin 19.x (${kernel}) / macOS 10.15 Catalina]) DARWIN_VERS=$DARWIN_10_15 ;; + 20.*) + AC_MSG_RESULT([Darwin 20.x (${kernel}) / macOS 11 Big Sur]) + DARWIN_VERS=$DARWIN_11_00 + ;; *) AC_MSG_RESULT([unsupported (${darwin_platform} ${kernel})]) AC_MSG_ERROR([Valgrind works on Darwin 12.x-19.x (Mac OS X 10.8-10.11, macOS 10.12-10.15)]) diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 90d921db28..f94aaf471b 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -433,6 +433,7 @@ COREGRIND_SOURCES_COMMON = \ m_mach/mach_traps-x86-darwin.S \ m_mach/mach_traps-amd64-darwin.S \ m_mach/mig_strncpy.c \ + m_mach/dyld_cache.c \ m_replacemalloc/replacemalloc_core.c \ m_scheduler/sched-lock.c \ m_scheduler/sched-lock-generic.c \ diff --git a/coregrind/fixup_macho_loadcmds.c b/coregrind/fixup_macho_loadcmds.c index b751829fbd..0031177ee9 100644 --- a/coregrind/fixup_macho_loadcmds.c +++ b/coregrind/fixup_macho_loadcmds.c @@ -117,10 +117,18 @@ #include <mach-o/fat.h> #include <mach/i386/thread_status.h> -/* Check that DARWIN_VERS is defined */ +/* Get hold of DARWIN_VERS, and check it has a sane value. */ #include "config.h" -#if !defined(DARWIN_VERS) -# error "DARWIN_VERS not defind. This file only compiles on Darwin." +#if DARWIN_VERS != DARWIN_10_5 && DARWIN_VERS != DARWIN_10_6 \ + && DARWIN_VERS != DARWIN_10_7 && DARWIN_VERS != DARWIN_10_8 \ + && DARWIN_VERS != DARWIN_10_9 && DARWIN_VERS != DARWIN_10_10 \ + && DARWIN_VERS != DARWIN_10_11 && DARWIN_VERS != DARWIN_10_12 \ + && DARWIN_VERS != DARWIN_10_13 && DARWIN_VERS != DARWIN_10_14 \ + && DARWIN_VERS != DARWIN_10_15 && DARWIN_VERS != DARWIN_11_00 \ + && DARWIN_VERS != DARWIN_12_00 && DARWIN_VERS != DARWIN_13_00 \ + && DARWIN_VERS != DARWIN_14_00 && DARWIN_VERS != DARWIN_15_00 \ + && DARWIN_VERS != DARWIN_15_04 && DARWIN_VERS != DARWIN_26_00 +# error "Unknown DARWIN_VERS value. This file only compiles on Darwin." #endif @@ -267,7 +275,7 @@ static Int map_image_aboard ( /*OUT*/ImageInfo* ii, HChar* filename ) { struct fat_header* fh_be; struct fat_header fh; struct mach_header_64* mh; - + // Assume initially that we have a thin image, and update // these if it turns out to be fat. ii->macho_img = ii->img; @@ -290,7 +298,7 @@ static Int map_image_aboard ( /*OUT*/ImageInfo* ii, HChar* filename ) + fh.nfat_arch * sizeof(struct fat_arch)) fail("Invalid Mach-O file (1 too small)."); - for (f = 0, arch_be = (struct fat_arch *)(fh_be+1); + for (f = 0, arch_be = (struct fat_arch *)(fh_be+1); f < fh.nfat_arch; f++, arch_be++) { Int cputype; @@ -573,7 +581,7 @@ void modify_macho_loadcmds ( HChar* filename, seg__pagezero->vmaddr = 0; # endif - out: + out: if (ii.img) unmap_image(&ii); } @@ -606,7 +614,7 @@ int main ( int argc, char** argv ) if (argc != 4) fail("args: -stack_addr-arg -stack_size-arg " - "name-of-tool-executable-to-modify"); + "name-of-tool-executable-to-modify"); r= sscanf(argv[1], "0x%llx", &req_stack_addr); if (r != 1) fail("invalid stack_addr arg"); @@ -621,7 +629,7 @@ int main ( int argc, char** argv ) if (!is_plausible_tool_exe_name(argv[3])) fail("implausible tool exe name -- not of the form *-{x86,amd64}-darwin"); - fprintf(stderr, "fixup_macho_loadcmds: examining tool exe: %s\n", + fprintf(stderr, "fixup_macho_loadcmds: examining tool exe: %s\n", argv[3] ); modify_macho_loadcmds( argv[3], req_stack_addr - req_stack_size, req_stack_size ); diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 66430668b5..6ed649bc27 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -326,6 +326,10 @@ DebugInfo* alloc_DebugInfo( const HChar* filename ) di->ddump_frames = VG_(clo_debug_dump_frames); } +#if DARWIN_VERS >= DARWIN_11_00 + di->from_memory = False; +#endif + return di; } @@ -1880,6 +1884,62 @@ void VG_(di_notify_pdb_debuginfo)( Int fd_obj, Addr avma_obj, #endif /* defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) */ +#if defined(VGO_darwin) && DARWIN_VERS >= DARWIN_11_00 +// Special version of VG_(di_notify_mmap) specifically to read debug info from the DYLD Shared Cache (DSC) +// We only use this on macOS 11.0 and later, because Apple stopped shipping dylib on-disk then. + +ULong VG_(di_notify_dsc)( const HChar* filename, Addr header, SizeT len ) +{ + DebugInfo* di; + Int rw_load_count; + const Bool debug = VG_(debugLog_getLevel)() >= 3; + + if (debug) + VG_(dmsg)("di_notify_dsc-1: %s at %#lx-%#lx\n", filename, header, header+len); + + if (!ML_(check_macho_and_get_rw_loads_from_memory)( (const void*) header, len, &rw_load_count )) + return 0; + + /* See if we have a DebugInfo for this filename. If not, + create one. */ + di = find_or_create_DebugInfo_for( filename ); + vg_assert(di); + + di->from_memory = True; + + if (di->have_dinfo) { + if (debug) + VG_(dmsg)("di_notify_dsc-2x: " + "ignoring mapping because we already read debuginfo " + "for DebugInfo* %p\n", di); + return 0; + } + + if (debug) + VG_(dmsg)("di_notify_dsc-2: " + "noting details in DebugInfo* at %p\n", di); + + /* Note the details about the mapping. */ + DebugInfoMapping map; + map.avma = header; + map.size = len; + map.foff = 0; + map.rx = True; + map.rw = False; + map.ro = False; + VG_(addToXA)(di->fsm.maps, &map); + + /* Update flags about what kind of mappings we've already seen. */ + di->fsm.have_rx_map |= True; + + vg_assert(!di->have_dinfo); + + if (debug) + VG_(dmsg)("di_notify_dsc-3: " + "achieved accept state for %s\n", filename); + return di_notify_ACHIEVE_ACCEPT_STATE ( di ); +} +#endif /*------------------------------------------------------------*/ /*--- ---*/ diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c index 21deabb356..7b5847820c 100644 --- a/coregrind/m_debuginfo/image.c +++ b/coregrind/m_debuginfo/image.c @@ -139,8 +139,8 @@ static Bool is_sane_CEnt ( const HChar* who, const DiImage* img, UInt i ) if (!(ce->used <= ce->size)) goto fail; if (ce->fromC) { // ce->size can be anything, but ce->used must be either the - // same or zero, in the case that it hasn't been set yet. - // Similarly, ce->off must either be above the real_size + // same or zero, in the case that it hasn't been set yet. + // Similarly, ce->off must either be above the real_size // threshold, or zero if it hasn't been set yet. if (!(ce->off >= img->real_size || ce->off == 0)) goto fail; if (!(ce->off + ce->used <= img->size)) goto fail; @@ -432,7 +432,7 @@ static Bool parse_Frame_asciiz ( const Frame* fr, const HChar* tag, static Bool parse_Frame_le64_le64_le64_bytes ( const Frame* fr, const HChar* tag, /*OUT*/ULong* n1, /*OUT*/ULong* n2, /*OUT*/ULong* n3, - /*OUT*/UChar** data, /*OUT*/ULong* n_data + /*OUT*/UChar** data, /*OUT*/ULong* n_data ) { vg_assert(VG_(strlen)(tag) == 4); @@ -581,13 +581,15 @@ static void set_CEnt ( const DiImage* img, UInt entNo, DiOffT off ) UInt delay = now - t_last; t_last = now; nread += len; - VG_(printf)("XXXXXXXX (tot %'llu) read %'lu offset %'llu delay %'u\n", + VG_(printf)("XXXXXXXX (tot %'llu) read %'lu offset %'llu delay %'u\n", nread, len, off, delay); } if (img->source.is_local) { // Simple: just read it - + if (img->source.fd == -1) { + VG_(memcpy)(&ce->data[0], ((const char *)img->source.session_id) + off, len); + } else { // PJF not quite so simple - see // https://bugs.kde.org/show_bug.cgi?id=480405 // if img->source.fd was opened with O_DIRECT the memory needs @@ -610,6 +612,7 @@ static void set_CEnt ( const DiImage* img, UInt entNo, DiOffT off ) } #endif vg_assert(!sr_isError(sr)); + } } else { // Not so simple: poke the server vg_assert(img->source.session_id > 0); @@ -671,7 +674,7 @@ static void set_CEnt ( const DiImage* img, UInt entNo, DiOffT off ) end_of_else_clause: {} } - + ce->off = off; ce->used = len; ce->fromC = False; @@ -888,7 +891,7 @@ DiImage* ML_(img_from_local_file)(const HChar* fullpath) || /* size is unrepresentable as a SizeT */ size != (DiOffT)(SizeT)(size)) { VG_(close)(sr_Res(fd)); - return NULL; + return NULL; } DiImage* img = ML_(dinfo_zalloc)("di.image.ML_iflf.1", sizeof(DiImage)); @@ -958,6 +961,39 @@ DiImage* ML_(img_from_fd)(Int fd, const HChar* fullpath) return img; } +/* Create an image from a place in memory, this is to support certain use cases (DSC on macOS) + where images are already loaded in memory without changing every usage of DiImage. */ +DiImage* ML_(img_from_memory)(Addr a, SizeT size, const HChar* fullpath) +{ + if (size == 0 || size == DiOffT_INVALID + || /* size is unrepresentable as a SizeT */ + size != (DiOffT)(SizeT)(size)) { + return NULL; + } + + DiImage* img = ML_(dinfo_zalloc)("di.image.ML_iflf.1", sizeof(DiImage)); + img->source.is_local = True; + img->source.fd = -1; + img->source.session_id = a; // FIXME: hacky, but avoids a new variable + img->size = size; + img->real_size = size; + img->ces_used = 0; + img->source.name = ML_(dinfo_strdup)("di.image.ML_iflf.2", fullpath); + img->cslc = NULL; + img->cslc_size = 0; + img->cslc_used = 0; + + /* Force the zeroth entry to be the first chunk of the file. + That's likely to be the first part that's requested anyway, and + loading it at this point forcing img->cent[0] to always be + non-empty, thereby saving us an is-it-empty check on the fast + path in get(). */ + UInt entNo = alloc_CEnt(img, CACHE_ENTRY_SIZE, False/*!fromC*/); + vg_assert(entNo == 0); + set_CEnt(img, 0, 0); + + return img; +} /* Create an image from a file on a remote debuginfo server. This is @@ -984,7 +1020,7 @@ DiImage* ML_(img_from_di_server)(const HChar* filename, if (!set_blocking(sd)) return NULL; Int one = 1; - Int sr = VG_(setsockopt)(sd, VKI_IPPROTO_TCP, VKI_TCP_NODELAY, + Int sr = VG_(setsockopt)(sd, VKI_IPPROTO_TCP, VKI_TCP_NODELAY, &one, sizeof(one)); vg_assert(sr == 0); @@ -1116,9 +1152,11 @@ void ML_(img_done)(DiImage* img) { vg_assert(img != NULL); if (img->source.is_local) { + if (img->source.fd != -1) { /* Close the file; nothing else to do. */ vg_assert(img->source.session_id == 0); VG_(close)(img->source.fd); + } } else { /* Close the socket. The server can detect this and will scrub the connection when it happens, so there's no need to tell it diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h index c38dfd76f7..cd1ac3431e 100644 --- a/coregrind/m_debuginfo/priv_storage.h +++ b/coregrind/m_debuginfo/priv_storage.h @@ -1094,6 +1094,12 @@ struct _DebugInfo { This helps performance a lot during ML_(addLineInfo) etc., which can easily be invoked hundreds of thousands of times. */ DebugInfoMapping* last_rx_map; + +#if DARWIN_VERS >= DARWIN_11_00 + /* Indicate that this debug info was loaded from memory (i.e. DSC) + instead than from a file. This means that some data might be missing (e.g. rw data). */ + Bool from_memory; +#endif }; /* --------------------- functions --------------------- */ diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c index c15c023723..4a8e8a0d78 100644 --- a/coregrind/m_initimg/initimg-darwin.c +++ b/coregrind/m_initimg/initimg-darwin.c @@ -43,12 +43,12 @@ #include "pub_core_mallocfree.h" #include "pub_core_machine.h" #include "pub_core_ume.h" +#include "pub_core_mach.h" #include "pub_core_options.h" #include "pub_core_tooliface.h" /* VG_TRACK */ #include "pub_core_threadstate.h" /* ThreadArchState */ #include "pub_core_pathscan.h" /* find_executable */ #include "pub_core_initimg.h" /* self */ -#include "pub_core_mach.h" /*====================================================================*/ @@ -98,9 +98,14 @@ static void load_client ( /*OUT*/ExeInfo* info, Also, remove any binding for VALGRIND_LAUNCHER=. The client should not be able to see this. + Before macOS 11: Also, add DYLD_SHARED_REGION=avoid, because V doesn't know how to process the dyld shared cache file. + Since macOS 11: + Use DYLD_SHARED_REGION=use because system libraries aren't provided outside the cache anymore. + This means we need to start processing the dyld shared cache file. + Also, change VYLD_* (mangled by launcher) back to DYLD_*. If this needs to handle any more variables it should be hacked @@ -111,7 +116,11 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) const HChar* preload_core = "vgpreload_core"; const HChar* ld_preload = "DYLD_INSERT_LIBRARIES="; const HChar* dyld_cache = "DYLD_SHARED_REGION="; +#if DARWIN_VERS >= DARWIN_11_00 + const HChar* dyld_cache_value= "use"; +#else const HChar* dyld_cache_value= "avoid"; +#endif const HChar* v_launcher = VALGRIND_LAUNCHER "="; Int ld_preload_len = VG_(strlen)( ld_preload ); Int dyld_cache_len = VG_(strlen)( dyld_cache ); @@ -194,7 +203,7 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) *cpp = cp; - ld_preload_done = True; + dyld_cache_done = True; } } @@ -371,8 +380,18 @@ Addr setup_client_stack( void* init_sp, auxsize += 2 * sizeof(HChar **); if (info->executable_path) { stringsize += 1 + VG_(strlen)(info->executable_path); +#if SDK_VERS >= SDK_10_14_6 + stringsize += 16; // executable_path= +#endif } +#if defined(VGA_arm64) + // This is required so that dyld can load our dylib specified in DYLD_INSERT_LIBRARIES +#define EXTRA_APPLE_ARG "arm64e_abi=all" + stringsize += VG_(strlen)(EXTRA_APPLE_ARG) + 1; + auxsize += sizeof(Word); +#endif + /* Darwin mach_header */ if (info->dynamic) auxsize += sizeof(Word); @@ -387,7 +406,7 @@ Addr setup_client_stack( void* init_sp, auxsize + /* auxv */ VG_ROUNDUP(stringsize, sizeof(Word)); /* strings (aligned) */ - if (0) VG_(printf)("stacksize = %d\n", stacksize); + if (0) VG_(printf)("stacksize = %u\n", stacksize); /* client_SP is the client's stack pointer */ client_SP = clstack_end + 1 - stacksize; @@ -409,10 +428,10 @@ Addr setup_client_stack( void* init_sp, VG_(clstk_end) = clstack_end; if (0) - VG_(printf)("stringsize=%d auxsize=%d stacksize=%d maxsize=0x%x\n" + VG_(printf)("stringsize=%u auxsize=%u stacksize=%u maxsize=0x%x\n" "clstack_start %p\n" "clstack_end %p\n", - stringsize, auxsize, stacksize, (Int)clstack_max_size, + stringsize, auxsize, stacksize, (UInt)clstack_max_size, (void*)clstack_start, (void*)clstack_end); /* ==================== allocate space ==================== */ @@ -451,11 +470,25 @@ Addr setup_client_stack( void* init_sp, *ptr = (Addr)copy_str(&strtab, *cpp); *ptr++ = 0; - /* --- executable_path + NULL --- */ - if (info->executable_path) + /* --- executable_path --- */ + if (info->executable_path) { +#if SDK_VERS >= SDK_10_14_6 + Int executable_path_len = VG_(strlen)(info->executable_path) + 16 + 1; + HChar *executable_path = VG_(malloc)("initimg-darwin.scs.1", executable_path_len); + VG_(snprintf)(executable_path, executable_path_len, "executable_path=%s", info->executable_path); + *ptr++ = (Addr)copy_str(&strtab, executable_path); + VG_(free)(executable_path); +#else *ptr++ = (Addr)copy_str(&strtab, info->executable_path); - else - *ptr++ = 0; +#endif + } + // FIXME PJF there was an extra *ptr++ = 0; in an else here + // there is a good chance that executable_path is never NULL so itr was nevwer used + +#if defined(VGA_arm64) + *ptr++ = (Addr)copy_str(&strtab, EXTRA_APPLE_ARG); +#endif + *ptr++ = 0; vg_assert((strtab-stringbase) == stringsize); @@ -470,7 +503,7 @@ Addr setup_client_stack( void* init_sp, } HChar resolved_name[VKI_PATH_MAX]; VG_(realpath)(exe_name, resolved_name); - VG_(resolved_exename) = VG_(strdup)("initimg-darwin.sre.1", resolved_name); + VG_(resolved_exename) = VG_(strdup)("initimg-darwin.scs.2", resolved_name); } /* client_SP is pointing at client's argc/argv */ @@ -675,3 +708,4 @@ void VG_(ii_finalise_image)( IIFinaliseImageInfo iifii ) /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ + diff --git a/coregrind/m_mach/dyld_cache.c b/coregrind/m_mach/dyld_cache.c new file mode 100644 index 0000000000..953cccd5fb --- /dev/null +++ b/coregrind/m_mach/dyld_cache.c @@ -0,0 +1,504 @@ + +/*--------------------------------------------------------------------*/ +/*--- DYLD Cache dyld_cache.c ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (c) 2020-2025 Louis Brunner <lou...@gm...> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +// While dyld_caching as existed for longer than that +// we have used DYLD_SHARED_REGION=avoid in the past +// +// Starting with macOS 11 (Big Sur), it isn't an option anymore +// as some dylib are not provided in file format anymore +#if defined(VGO_darwin) && DARWIN_VERS >= DARWIN_11_00 + +#include "pub_core_debuginfo.h" // VG_(di_notify_dsc) +#include "pub_core_debuglog.h" // VG_(debugLog) +#include "pub_core_mach.h" // VG_(dyld_cache_*) +#include "pub_core_syscall.h" // VG_(do_syscall1) +#include "pub_core_libcbase.h" // VG_(strncmp) +#include "pub_core_libcprint.h" // VG_(dmsg) +#include "pub_core_libcfile.h" // VG_(stat) +#include "vki/vki-scnums-darwin.h" // __NR_shared_region_check_np +#include "priv_dyld_internals.h" // CACHE_MAGIC_*, dyld_cache_header, etc + +// Required by private headers underneath +#include "pub_core_libcassert.h" // vg_assert +#include "pub_core_threadstate.h" // ThreadState + +// FIXME: probably shouldn't include this directly? +#include "m_syswrap/priv_syswrap-generic.h" // ML_(notify_core_and_tool_of_mmap) + +#include <mach-o/loader.h> +#include <mach-o/fat.h> + +// Only supported on macOS 11 onwards which is 64bit only +# define MACH_HEADER mach_header_64 +# define MAGIC MH_MAGIC_64 + +static void output_text_debug_info(const dyld_cache_image_text_info* textInfo); +static void output_debug_info(const dyld_cache_header* dyld_cache); + +typedef struct { + const dyld_cache_header* header; + Addr slide; + Bool tried; +} DYLDCache; + +static DYLDCache dyld_cache = { + .header = NULL, + .slide = 0, + .tried = False, +}; + +static Addr calculate_relative(const dyld_cache_header * header, Addr offset) { + return (Addr)header + offset; +} + +static Addr calculate_unslid(Addr addr) { + return addr + dyld_cache.slide; +} + +static int try_to_init_header(Addr address) { + const dyld_cache_header* header = (const dyld_cache_header *) address; + + if ( +#if defined(VGA_amd64) + VG_(strcmp)(header->magic, CACHE_MAGIC_x86_64) != 0 + && VG_(strcmp)(header->magic, CACHE_MAGIC_x86_64_HASWELL) != 0 +#elif defined(VGA_arm64) + VG_(strcmp)(header->magic, CACHE_MAGIC_arm64) != 0 + && VG_(strcmp)(header->magic, CACHE_MAGIC_arm64e) != 0 +#else + 0 +#error "unknown architecture" +#endif + ) { + VG_(debugLog)(2, "dyld_cache", "ERROR: incompatible shared dyld cache (%s)\n", header->magic); + return 0; + } + + if (header->mappingCount < 1) { + VG_(debugLog)(2, "dyld_cache", "ERROR: no mappings in the dyld cache\n"); + return 0; + } + + VG_(debugLog)(2, "dyld_cache", "shared dyld cache format: %d / %#x\n", header->formatVersion, header->mappingOffset); + output_debug_info(header); + + const dyld_cache_mapping_info* mappings = (const dyld_cache_mapping_info*)(calculate_relative(header, header->mappingOffset)); + for (int i = 0; i < header->mappingCount; ++i) { + const dyld_cache_mapping_info* mapping = &mappings[i]; + Addr map_addr = calculate_unslid(mapping->address); + VG_(debugLog)(5, "dyld_cache", + "mapping[%d]{\n" + " .address: %#lx,\n" + " .size: %llu (%#llx),\n" + " .fileOffset: %#lx,\n" + " .maxProt: %#x,\n" + " .initProt: %#x,\n" + "}\n", + i, + map_addr, + mapping->size, + mapping->size, + calculate_relative(header, mapping->fileOffset), + mapping->maxProt, + mapping->initProt + ); + ML_(notify_core_and_tool_of_mmap)(map_addr, mapping->size, mapping->initProt, VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS, -1, 0); + } + + if (dyld_cache.header->mappingOffset >= __offsetof(dyld_cache_header, dynamicDataMaxSize) && header->dynamicDataMaxSize > 0) { + ML_(notify_core_and_tool_of_mmap)(calculate_relative(header, header->dynamicDataOffset), header->dynamicDataMaxSize, VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS, -1, 0); + } + + return 1; +} + +static int try_to_init(void) { + // Read address of the shared cache which is mapped in our address space + // and tell Valgrind about it so we avoid false-positives and massive suppression files + { + Addr cache_address; + if (sr_Res(VG_(do_syscall1)(__NR_shared_region_check_np, (UWord)&cache_address)) != 0) { + VG_(debugLog)(2, "dyld_cache", "ERROR: could not get shared dyld cache address\n"); + return 0; + } + VG_(debugLog)(2, "dyld_cache", "shared dyld cache found: %#lx\n", cache_address); + + // FIXME: should be after `try_to_init_header` but we also need the slide calculate _before_ + dyld_cache.header = (const dyld_cache_header *) cache_address; + const dyld_cache_mapping_info* mappings = (const dyld_cache_mapping_info*)(calculate_relative(dyld_cache.header, dyld_cache.header->mappingOffset)); + dyld_cache.slide = cache_address - mappings[0].address; + VG_(debugLog)(2, "dyld_cache", "dyld cache slide: %#lx\n", dyld_cache.slide); + + if (!try_to_init_header(cache_address)) { + return 0; + } + + if (dyld_cache.header->mappingOffset >= __offsetof(dyld_cache_header, subCacheArrayCount)) { + Bool sub_cache_v2 = dyld_cache.header->mappingOffset > __offsetof(dyld_cache_header, cacheSubType); + Addr sub_caches = calculate_relative(dyld_cache.header, dyld_cache.header->subCacheArrayOffset); + + for (int i = 0; i < dyld_cache.header->subCacheArrayCount; ++i) { + Addr sub_cache_addr; + + VG_(debugLog)(2, "dyld_cache", "found sub cache %d (v2: %d)\n", i, sub_cache_v2); + + if (sub_cache_v2) { + const dyld_subcache_entry* sub_cache = &((const dyld_subcache_entry*) sub_caches)[i]; + const uint8_t* u = sub_cache->uuid; + sub_cache_addr = calculate_relative(dyld_cache.header, sub_cache->cacheVMOffset); + VG_(debugLog)(5, "dyld_cache", + "sub_cache_v2[%d]{\n" + " .uuid: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x,\n" + " .cacheVMOffset: %#lx,\n" + " .fileSuffix: %s,\n" + "}\n", + i, + u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], u[8], u[9], u[10], u[11], u[12], u[13], u[14], u[15], + sub_cache_addr, + sub_cache->fileSuffix + ); + + } else { + const dyld_subcache_entry_v1* sub_cache = &((const dyld_subcache_entry_v1*) sub_caches)[i]; + const uint8_t* u = sub_cache->uuid; + sub_cache_addr = calculate_relative(dyld_cache.header, sub_cache->cacheVMOffset); + VG_(debugLog)(5, "dyld_cache", + "sub_cache_v1[%d]{\n" + " .uuid: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x,\n" + " .cacheVMOffset: %#lx,\n" + "}\n", + i, + u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], u[8], u[9], u[10], u[11], u[12], u[13], u[14], u[15], + sub_cache_addr + ); + } + + if (!try_to_init_header(sub_cache_addr)) { + return 0; + } + } + } + } + + return 1; +} + +Addr VG_(dyld_cache_get_slide)(void) { + return dyld_cache.slide; +} + +int ensure_init(void) { + if (dyld_cache.header != NULL) { + return 1; + } + + // FIXME: unlikely race condition? + if (dyld_cache.tried) { + return 0; + } + dyld_cache.tried = True; + + if (!try_to_init()) { + VG_(dmsg)( + "WARNING: could not read from dyld shared cache (DSC)\n" + "Some reports (especially memory leaks) might be missing or incorrect (false-positives)\n" + ); + return 0; + } + // We currently detect if dyld is loading/using a library by checking if stat64 fails. + // However, dyld doesn't seem to call stat64 for all of them anymore. + // All arm64 binaries are executables but some x86 ones might not be so let's avoid them just to be safe. + VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_kernel.dylib"); + VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_pthread.dylib"); + VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_platform.dylib"); + + return 1; +} + +void VG_(dyld_cache_init)(const HChar* tool) { + // drd crashes if you map memory segments in m_main + if (VG_(strcmp)(tool, "drd") == 0) { + return; + } + + ensure_init(); +} + +int VG_(dyld_cache_might_be_in)(const HChar* path) { + // If not init'd, there is no point + if (!ensure_init()) { + return 0; + } + + if (VG_(strncmp)(path, "/usr/lib/", 9) == 0) { + return 1; + } + if (VG_(strncmp)(path, "/System/Library/", 16) == 0) { + return 1; + } + // FIXME: more flexible heuristics around extensions? + return 0; +} + +static struct MACH_HEADER* find_image_text(const dyld_cache_header* header, const char* path, SizeT* len) { + vg_assert(len); + *len = 0; + + const dyld_cache_image_text_info* textInfos = (const dyld_cache_image_text_info*) calculate_relative(header, header->imagesTextOffset); + + for (int i = 0; i < header->imagesTextCount; ++i) { + const dyld_cache_image_text_info* textInfo = &textInfos[i]; + const char* imagePath = (const char*) calculate_relative(header, textInfo->pathOffset); + + if (VG_(strcmp)(imagePath, path) == 0) { + output_text_debug_info(textInfo); + *len = textInfo->textSegmentSize; + return (struct MACH_HEADER*) calculate_unslid(textInfo->loadAddress); + } + } + + return NULL; +} + +int VG_(dyld_cache_load_library)(const HChar* path) { + struct MACH_HEADER *image = NULL; + ULong res = 0; + SizeT len = 0; + + if (VG_(strstr)(path, "/PrivateFrameworks/") != NULL) { + return 0; + } + + // If not init'd, there is no point trying + if (!ensure_init()) { + return 0; + } + + VG_(debugLog)(2, "dyld_cache", "potential dylib to check in the cache: %s\n", path); + + image = find_image_text(dyld_cache.header, path, &len); + if (image == NULL) { + VG_(debugLog)(2, "dyld_cache", "image not found: %s\n", path); + return 0; + } + + if (image->magic != MAGIC) { + VG_(debugLog)(2, "dyld_cache", "image not mach-o (%#x): %s\n", image->magic, path); + return 0; + } + + VG_(debugLog)(2, "dyld_cache", "image (%p) is valid, forwarding to debuginfo: %s\n", image, path); + res = VG_(di_notify_dsc)(path, (Addr)image, len); + if (res == 0) { + VG_(debugLog)(2, "dyld_cache", "failed to load debuginfo from: %s\n", path); + return 0; + } + + VG_(debugLog)(2, "dyld_cache", "image fully loaded: %s\n", path); + + return 1; +} + +static void output_text_debug_info(const dyld_cache_image_text_info* textInfo) { + const uint8_t* u = textInfo->uuid; + VG_(debugLog)(5, "dyld_cache", + "image_text_info{\n" + " .uuid: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x,\n" + " .loadAddress: %#llx,\n" + " .textSegmentSize: %u,\n" + " .pathOffset: %#x,\n" + "}\n", + u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], u[8], + u[9], u[10], u[11], u[12], u[13], u[14], u[15], + textInfo->loadAddress, + textInfo->textSegmentSize, + textInfo->pathOffset + ); +} + +static void output_debug_info(const dyld_cache_header* cache) { + const uint8_t* u1 = cache->uuid; + const uint8_t* u2 = cache->symbolFileUUID; + VG_(debugLog)(5, "dyld_cache", + "shared dyld content: {\n" + " .magic: %s,\n" + " .mappingOffset: %#x,\n" + " .mappingCount: %u,\n" + " .imagesOffsetOld: %#x,\n" + " .imagesCountOld: %u,\n" + " .dyldBaseAddress: %#llx,\n" + " .codeSignatureOffset: %#llx,\n" + " .codeSignatureSize: %llu,\n" + " .slideInfoOffsetUnused: %#llx,\n" + " .slideInfoSizeUnused: %llu,\n" + " .localSymbolsOffset: %#llx,\n" + " .localSymbolsSize: %llu,\n" + " .uuid: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x,\n" + " .cacheType: %llu,\n" + " .branchPoolsOffset: %#x,\n" + " .branchPoolsCount: %u,\n" + " .dyldInCacheMH: %#llx,\n" + " .dyldInCacheEntry: %#llx,\n" + " .imagesTextOffset: %#llx,\n" + " .imagesTextCount: %llu,\n" + " .patchInfoAddr: %#llx,\n" + " .patchInfoSize: %llu,\n" + " .otherImageGroupAddrUnused: %#llx,\n" + " .otherImageGroupSizeUnused: %llu,\n" + " .progClosuresAddr: %#llx,\n" + " .progClosuresSize: %llu,\n" + " .progClosuresTrieAddr: %#llx,\n" + " .progClosuresTrieSize: %llu,\n" + " .platform: %#x,\n" + " .formatVersion: %#x,\n" + " .dylibsExpectedOnDisk: %d,\n" + " .simulator: %d,\n" + " .locallyBuiltCache: %d,\n" + " .builtFromChainedFixups: %d,\n" + " .padding: %d,\n" + " .sharedRegionStart: %#llx,\n" + " .sharedRegionSize: %llu,\n" + " .maxSlide: %#llx,\n" + " .dylibsImageArrayAddr: %#llx,\n" + " .dylibsImageArraySize: %llu,\n" + " .dylibsTrieAddr: %#llx,\n" + " .dylibsTrieSize: %llu,\n" + " .otherImageArrayAddr: %#llx,\n" + " .otherImageArraySize: %llu,\n" + " .otherTrieAddr: %#llx,\n" + " .otherTrieSize: %llu,\n" + " .mappingWithSlideOffset: %#x,\n" + " .mappingWithSlideCount: %u,\n" + " .dylibsPBLStateArrayAddrUnused: %llu,\n" + " .dylibsPBLSetAddr: %llx,\n" + " .programsPBLSetPoolAddr: %#llx,\n" + " .programsPBLSetPoolSize: %llu,\n" + " .programTrieAddr: %#llx,\n" + " .programTrieSize: %u,\n" + " .osVersion: %#x,\n" + " .altPlatform: %#x,\n" + " .altOsVersion: %#x,\n" + " .swiftOptsOffset: %#llx,\n" + " .swiftOptsSize: %llu,\n" + " .subCacheArrayOffset: %#x,\n" + " .subCacheArrayCount: %u,\n" + " .symbolFileUUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x,\n" + " .rosettaReadOnlyAddr: %#llx,\n" + " .rosettaReadOnlySize: %llu,\n" + " .rosettaReadWriteAddr: %#llx,\n" + " .rosettaReadWriteSize: %llu,\n" + " .imagesOffset: %#x,\n" + " .imagesCount: %u,\n" + " .cacheSubType: %#x,\n" + " .objcOptsOffset: %#llx,\n" + " .objcOptsSize: %llu,\n" + " .cacheAtlasOffset: %#llx,\n" + " .cacheAtlasSize: %llu,\n" + " .dynamicDataOffset: %#llx,\n" + " .dynamicDataMaxSize: %llu,\n" + "}\n", + cache->magic, + cache->mappingOffset, + cache->mappingCount, + cache->imagesOffsetOld, + cache->imagesCountOld, + cache->dyldBaseAddress, + cache->codeSignatureOffset, + cache->codeSignatureSize, + cache->slideInfoOffsetUnused, + cache->slideInfoSizeUnused, + cache->localSymbolsOffset, + cache->localSymbolsSize, + u1[0], u1[1], u1[2], u1[3], u1[4], u1[5], u1[6], u1[7], u1[8], + u1[9], u1[10], u1[11], u1[12], u1[13], u1[14], u1[15], + cache->cacheType, + cache->branchPoolsOffset, + cache->branchPoolsCount, + cache->dyldInCacheMH, + cache->dyldInCacheEntry, + cache->imagesTextOffset, + cache->imagesTextCount, + cache->patchInfoAddr, + cache->patchInfoSize, + cache->otherImageGroupAddrUnused, + cache->otherImageGroupSizeUnused, + cache->progClosuresAddr, + cache->progClosuresSize, + cache->progClosuresTrieAddr, + cache->progClosuresTrieSize, + cache->platform, + (UInt)cache->formatVersion, + cache->dylibsExpectedOnDisk, + cache->simulator, + cache->locallyBuiltCache, + cache->builtFromChainedFixups, + cache->padding, + cache->sharedRegionStart, + cache->sharedRegionSize, + cache->maxSlide, + cache->dylibsImageArrayAddr, + cache->dylibsImageArraySize, + cache->dylibsTrieAddr, + cache->dylibsTrieSize, + cache->otherImageArrayAddr, + cache->otherImageArraySize, + cache->otherTrieAddr, + cache->otherTrieSize, + cache->mappingWithSlideOffset, + cache->mappingWithSlideCount, + cache->dylibsPBLStateArrayAddrUnused, + cache->dylibsPBLSetAddr, + cache->programsPBLSetPoolAddr, + cache->programsPBLSetPoolSize, + cache->programTrieAddr, + cache->programTrieSize, + cache->osVersion, + cache->altPlatform, + cache->altOsVersion, + cache->swiftOptsOffset, + cache->swiftOptsSize, + cache->subCacheArrayOffset, + cache->subCacheArrayCount, + u2[0], u2[1], u2[2], u2[3], u2[4], u2[5], u2[6], u2[7], u2[8], + u2[9], u2[10], u2[11], u2[12], u2[13], u2[14], u2[15], + cache->rosettaReadOnlyAddr, + cache->rosettaReadOnlySize, + cache->rosettaReadWriteAddr, + cache->rosettaReadWriteSize, + cache->imagesOffset, + cache->imagesCount, + cache->cacheSubType, + cache->objcOptsOffset, + cache->objcOptsSize, + cache->cacheAtlasOffset, + cache->cacheAtlasSize, + cache->dynamicDataOffset, + cache->dynamicDataMaxSize + ); +} + +#endif diff --git a/coregrind/m_mach/priv_dyld_internals.h b/coregrind/m_mach/priv_dyld_internals.h new file mode 100644 index 0000000000..32c31f9f95 --- /dev/null +++ b/coregrind/m_mach/priv_dyld_internals.h @@ -0,0 +1,146 @@ +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (c) 2020-2025 Louis Brunner <lou...@gm...> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ +#ifndef __PRIV_DYLD_INTERNALS_H +#define __PRIV_DYLD_INTERNALS_H + +#if defined(VGO_darwin) + +// This file contains a bunch of structure defined in Apple's dyld + +// From Apple's `dyld/dyld/SharedCacheRuntime.cpp` +#define CACHE_MAGIC_x86_64 "dyld_v1 x86_64" +#define CACHE_MAGIC_x86_64_HASWELL "dyld_v1 x86_64h" +#define CACHE_MAGIC_arm64 "dyld_v1 arm64" +#define CACHE_MAGIC_arm64e "dyld_v1 arm64e" + +// From Apple's `dyld/cache-builder/dyld_cache_format.h` +typedef struct { + char magic[16]; // e.g. "dyld_v0 i386" + uint32_t mappingOffset; // file offset to first dyld_cache_mapping_info + uint32_t mappingCount; // number of dyld_cache_mapping_info entries + uint32_t imagesOffsetOld; // UNUSED: moved to imagesOffset to prevent older dsc_extarctors from crashing + uint32_t imagesCountOld; // UNUSED: moved to imagesCount to prevent older dsc_extarctors from crashing + uint64_t dyldBaseAddress; // base address of dyld when cache was built + uint64_t codeSignatureOffset; // file offset of code signature blob + uint64_t codeSignatureSize; // size of code signature blob (zero means to end of file) + uint64_t slideInfoOffsetUnused; // unused. Used to be file offset of kernel slid info + uint64_t slideInfoSizeUnused; // unused. Used to be size of kernel slid info + uint64_t localSymbolsOffset; // file offset of where local symbols are stored + uint64_t localSymbolsSize; // size of local symbols information + uint8_t uuid[16]; // unique value for each shared cache file + uint64_t cacheType; // 0 for development, 1 for production, 2 for multi-cache + uint32_t branchPoolsOffset; // file offset to table of uint64_t pool addresses + uint32_t branchPoolsCount; // number of uint64_t entries + uint64_t dyldInCacheMH; // (unslid) address of mach_header of dyld in cache + uint64_t dyldInCacheEntry; // (unslid) address of entry point (_dyld_start) of dyld in cache + uint64_t imagesTextOffset; // file offset to first dyld_cache_image_text_info + uint64_t imagesTextCount; // number of dyld_cache_image_text_info entries + uint64_t patchInfoAddr; // (unslid) address of dyld_cache_patch_info + uint64_t patchInfoSize; // Size of all of the patch information pointed to via the dyld_cache_patch_info + uint64_t otherImageGroupAddrUnused; // unused + uint64_t otherImageGroupSizeUnused; // unused + uint64_t progClosuresAddr; // (unslid) address of list of program launch closures + uint64_t progClosuresSize; // size of list of program launch closures + uint64_t progClosuresTrieAddr; // (unslid) address of trie of indexes into program launch closures + uint64_t progClosuresTrieSize; // size of trie of indexes into program launch closures + uint32_t platform; // platform number (macOS=1, etc) + uint32_t formatVersion : 8, // dyld3::closure::kFormatVersion + dylibsExpectedOnDisk : 1, // dyld should expect the dylib exists on disk and to compare inode/mtime to see if cache is valid + simulator : 1, // for simulator of specified platform + locallyBuiltCache : 1, // 0 for B&I built cache, 1 for locally built cache + builtFromChainedFixups : 1, // some dylib in cache was built using chained fixups, so patch tables must be used for overrides + padding : 20; // TBD + uint64_t sharedRegionStart; // base load address of cache if not slid + uint64_t sharedRegionSize; // overall size required to map the cache and all subCaches, if any + uint64_t maxSlide; // runtime slide of cache can be between zero and this value + uint64_t dylibsImageArrayAddr; // (unslid) address of ImageArray for dylibs in this cache + uint64_t dylibsImageArraySize; // size of ImageArray for dylibs in this cache + uint64_t dylibsTrieAddr; // (unslid) address of trie of indexes of all cached dylibs + uint64_t dylibsTrieSize; // size of trie of cached dylib paths + uint64_t otherImageArrayAddr; // (unslid) address of ImageArray for dylibs and bundles with dlopen closures + uint64_t otherImageArraySize; // size of ImageArray for dylibs and bundles with dlopen closures + uint64_t otherTrieAddr; // (unslid) address of trie of indexes of all dylibs and bundles with dlopen closures + uint64_t otherTrieSize; // size of trie of dylibs and bundles with dlopen closures + uint32_t mappingWithSlideOffset; // file offset to first dyld_cache_mapping_and_slide_info + uint32_t mappingWithSlideCount; // number of dyld_cache_mapping_and_slide_info entries + uint64_t dylibsPBLStateArrayAddrUnused; // unused + uint64_t dylibsPBLSetAddr; // (unslid) address of PrebuiltLoaderSet of all cached dylibs + uint64_t programsPBLSetPoolAddr; // (unslid) address of pool of PrebuiltLoaderSet for each program + uint64_t programsPBLSetPoolSize; // size of pool of PrebuiltLoaderSet for each program + uint64_t programTrieAddr; // (unslid) address of trie mapping program path to PrebuiltLoaderSet + uint32_t programTrieSize; + uint32_t osVersion; // OS Version of dylibs in this cache for the main platform + uint32_t altPlatform; // e.g. iOSMac on macOS + uint32_t altOsVersion; // e.g. 14.0 for iOSMac + uint64_t swiftOptsOffset; // VM offset from cache_header* to Swift optimizations header + uint64_t swiftOptsSize; // size of Swift optimizations header + uint32_t subCacheArrayOffset; // file offset to first dyld_subcache_entry + uint32_t subCacheArrayCount; // number of subCache entries + uint8_t symbolFileUUID[16]; // unique value for the shared cache file containing unmapped local symbols + uint64_t rosettaReadOnlyAddr; // (unslid) address of the start of where Rosetta can add read-only/executable data + uint64_t rosettaReadOnlySize; // maximum size of the Rosetta read-only/executable region + uint64_t rosettaReadWriteAddr; // (unslid) address of the start of where Rosetta can add read-write data + uint64_t rosettaReadWriteSize; // maximum size of the Rosetta read-write region + uint32_t imagesOffset; // file offset to first dyld_cache_image_info + uint32_t imagesCount; // number of dyld_cache_image_info entries + uint32_t cacheSubType; // 0 for development, 1 for production, when cacheType is multi-cache(2) + uint64_t objcOptsOffset; // VM offset from cache_header* to ObjC optimizations header + uint64_t objcOptsSize; // size of ObjC optimizations header + uint64_t cacheAtlasOffset; // VM offset from cache_header* to embedded cache atlas for process introspection + uint64_t cacheAtlasSize; // size of embedded cache atlas + uint64_t dynamicDataOffset; // VM offset from cache_header* to the location of dyld_cache_dynamic_data_header + uint64_t dynamicDataMaxSize; // maximum size of space reserved from dynamic data +} dyld_cache_header; + +// From Apple's `dyld/cache-builder/dyld_cache_format.h` +typedef struct { + uint64_t address; + uint64_t size; + uint64_t fileOffset; + uint32_t maxProt; + uint32_t initProt; +} dyld_cache_mapping_info; + +// From Apple's `dyld/cache-builder/dyld_cache_format.h` +typedef struct { + uint8_t uuid[16]; // The UUID of the subCache file + uint64_t cacheVMOffset; // The offset of this subcache from the main cache base address + char fileSuffix[32]; // The file name suffix of the subCache file e.g. ".25.data", ".03.development" +} dyld_subcache_entry; + +// From Apple's `dyld/cache-builder/dyld_cache_format.h` +typedef struct { + uint8_t uuid[16]; // The UUID of the subCache file + uint64_t cacheVMOffset; // The offset of this subcache from the main cache base address +} dyld_subcache_entry_v1; + +// From Apple's `dyld/cache-builder/dyld_cache_format.h` +typedef struct { + uuid_t uuid; + uint64_t loadAddress; // unslid address of start of __TEXT + uint32_t textSegmentSize; + uint32_t pathOffset; // offset from start of cache file +} dyld_cache_image_text_info; + +#endif + +#endif diff --git a/coregrind/m_main.c b/coregrind/m_main.c index ecd159e973..0bd929d0cc 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -1970,6 +1970,18 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp ) VG_(init_Threads)(); + //-------------------------------------------------------------- + // Initialize the dyld cache, which is required with macOS 11 (Big Sur) and onwards + // as some system libraries aren't provided on the disk anymore + // p: none + // Note: some tools don't like to start mapping memory right way, so we do it lazily in those cases. + //-------------------------------------------------------------- +# if defined(VGO_darwin) && DARWIN_VERS >= DARWIN_11_00 + if (the_iifii.dynamic) { + VG_(dyld_cache_init)(VG_(clo_toolname)); + } +# endif + //-------------------------------------------------------------- // Initialise the scheduler (phase 1) [generates tid_main] // p: none, afaics diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 7d92450c4e..12b01f678d 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -455,6 +455,19 @@ extern int * __error(void) __attribute__((weak)); ALLOC_or_NULL(SO_SYN_MALLOC, malloc, malloc); ZONEALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_zone_malloc, malloc); ZONEALLOC_or_NULL(SO_SYN_MALLOC, malloc_zone_malloc, malloc); +#if DARWIN_VERS >= DARWIN_15_00 +#if defined(VGA_arm64) + // on arm64, malloc_type_malloc is used for malloc, new and new[] + // __typed_operator_new_impl[abi:ne180100]@libc++abi.dylib calls it for new and new[] + // all other usages (Swift, ObjC, C) it calls it for malloc + // this matters as we need to put the right tag in the allocation + // otherwise the tool might report a mismatch between allocation func and free func + TYPE_ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_type_malloc); +#else + ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_type_malloc, malloc); +#endif + ZONEALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_type_zone_malloc, malloc); +#endif #elif defined(VGO_solaris) ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc); @@ -943,6 +956,8 @@ extern int * __error(void) __attribute__((weak)); #elif defined(VGO_darwin) FREE(VG_Z_LIBC_SONAME, free, free ); FREE(SO_SYN_MALLOC, free, free ); + FREE(VG_Z_LIBC_SONAME, vfree, free ); + FREE(SO_SYN_MALLOC, vfree, free ); ZONEFREE(VG_Z_LIBC_SONAME, malloc_zone_free, free ); ZONEFREE(SO_SYN_MALLOC, malloc_zone_free, free ); @@ -2156,8 +2171,9 @@ extern int * __error(void) __attribute__((weak)); POSIX_MEMALIGN(SO_SYN_MALLOC, posix_memalign); #elif defined(VGO_darwin) -#if (DARWIN_VERSIO >= DARWIN_10_6) +#if (DARWIN_VERS >= DARWIN_10_6) POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign); + POSIX_MEMALIGN(SO_SYN_MALLOC, posix_memalign); #endif #elif defined(VGO_solaris) @@ -2326,7 +2342,7 @@ extern int * __error(void) __attribute__((weak)); ALIGNED_ALLOC(SO_SYN_MALLOC, aligned_alloc); #elif defined(VGO_darwin) - //ALIGNED_ALLOC(VG_Z_LIBC_SONAME, aligned_alloc); + ALIGNED_ALLOC(VG_Z_LIBC_SONAME, aligned_alloc); #elif defined(VGO_solaris) ALIGNED_ALLOC(VG_Z_LIBC_SONAME, aligned_alloc); @@ -2495,6 +2511,17 @@ static size_t my_malloc_size ( void* zone, void* ptr ) return res; } +#define ZONE_DESTROY(soname, fnname) \ + \ + void VG_REPLACE_FUNCTION_EZU(10291,soname,fnname)(void* zone); \ + void VG_REPLACE_FUNCTION_EZU(10291,soname,fnname)(void* zone) \ + { \ + TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(zone); \ + } + +ZONE_DESTROY(VG_Z_LIBC_SONAME, malloc_zone_destroy); +ZONE_DESTROY(SO_SYN_MALLOC, malloc_zone_destroy); + /* Note that the (void*) casts below are a kludge which stops compilers complaining about the fact that the replacement functions aren't really of the right type. */ @@ -2507,7 +2534,7 @@ static vki_malloc_zone_t vg_default_zone = { (void*)VG_REPLACE_FUNCTION_EZU(10130,VG_Z_LIBC_SONAME,malloc_zone_valloc), (void*)VG_REPLACE_FUNCTION_EZU(10040,VG_Z_LIBC_SONAME,malloc_zone_free), (void*)VG_REPLACE_FUNCTION_EZU(10080,VG_Z_LIBC_SONAME,malloc_zone_realloc), - NULL, // GrP fixme: destroy + (void*)VG_REPLACE_FUNCTION_EZU(10291,VG_Z_LIBC_SONAME,malloc_zone_destroy), "ValgrindMallocZone", NULL, // batch_malloc NULL, // batch_free diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index 7ffc4f88f3..f30136e291 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -362,7 +362,9 @@ DECL_TEMPLATE(darwin, gettid); // 286 // NYI mkfifo_extended 291 // NYI mkdir_extended 292 // NYI identitysvc 293 -// NYI shared_region_check_np 294 +#if DARWIN_VERS >= DARWIN_11_00 +DECL_TEMPLATE(darwin, shared_region_check_np); // 294 +#endif // NYI shared_region_map_np 295 #if DARWIN_VERS >= DARWIN_10_6 // NYI vm_pressure_monitor 296 @@ -540,7 +542,9 @@ DECL_TEMPLATE(darwin, fileport_makeport); // 430 // NYI pid_shutdown_sockets 436 #endif /* DARWIN_VERS >= DARWIN_10_10 */ // old old shared_region_slide_np 437 -// NYI shared_region_map_and_slide_np // 438 +#if DARWIN_VERS >= DARWIN_11_00 +DECL_TEMPLATE(darwin, shared_region_map_and_slide_np); // 438 +#endif // NYI kas_info // 439 // NYI memorystatus_control // 440 DECL_TEMPLATE(darwin, guarded_open_np); // 441 @@ -655,6 +659,19 @@ DECL_TEMPLATE(darwin, abort_with_payload); // 521 // NYI log_data // 533 // NYI memorystatus_available_memory // 534 #endif +#if DARWIN_VERS >= DARWIN_11_00 +DECL_TEMPLATE(darwin, objc_bp_assist_cfg_np); // 535 +// NYI shared_region_map_and_slide_2_np // 536 +// NYI pivot_root // 537 +// NYI task_inspect_for_pid // 538 +DECL_TEMPLATE(darwin, task_read_for_pid); // 539 +// NYI sys_preadv // 540 +// NYI sys_pwritev // 541 +// NYI sys_preadv_nocancel // 542 +// NYI sys_pwritev_nocancel // 543 +DECL_TEMPLATE(darwin, ulock_wait2); // 544 +// NYI proc_info_extended_id // 545 +#endif // Mach message helpers DECL_TEMPLATE(darwin, mach_port_set_context); diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 09c1338cfa..25ac11eac3 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -44,6 +44,7 @@ #include "pub_core_libcprint.h" #include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" +#include "pub_core_mach.h" // VG_(dyld_cache_*) #include "pub_core_machine.h" // VG_(get_SP) #include "pub_core_mallocfree.h" #include "pub_core_options.h" @@ -3312,10 +3313,34 @@ PRE(stat64) PRE_REG_READ2(long, "stat", const char *,path, struct stat64 *,buf); PRE_MEM_RASCIIZ("stat64(path)", ARG1); PRE_MEM_WRITE( "stat64(buf)", ARG2, sizeof(struct vki_stat64) ); + +#if DARWIN_VERS >= DARWIN_11_00 + // Starting with macOS 11.0, some system libraries are not provided on the disk but only though + // shared dyld cache, thus we try to detect if dyld tried (and failed) to load a dylib, + // in which case we do the same thing as dyld and load the info from the cache directly + // + // This is our entry point for checking a particular dylib: if it looks like one, + // we want to see the error result, if any, and subsequently check the cache + if (ARG1 != 0 && VG_(dyld_cache_might_be_in)((HChar *)ARG1)) { + *flags |= SfPostOnFail; + } +#endif } POST(stat64) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) ); + if (SUCCESS) { + POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) ); + } + +#if DARWIN_VERS >= DARWIN_11_00 + if (SUCCESS || (FAILURE && ERR == VKI_ENOENT)) { + // It failed and `SfPostOnFail` was set, thus this is probably a dylib, + // try to load it from cache which will call VG_(di_notify_mmap) like the previous versions did + if (VG_(dyld_cache_load_library)((HChar *)ARG1)) { + ML_(sync_mappings)("after", "stat64", 0); + } + } +#endif } PRE(lstat64) @@ -11082,6 +11107,109 @@ POST(kernelrpc_mach_port_type_trap) #endif /* DARWIN_VERS >= DARWIN_10_15 */ + +/* --------------------------------------------------------------------- + Added for macOS 11.0 (Big Sur) + ------------------------------------------------------------------ */ + +#if DARWIN_VERS >= DARWIN_11_00 + +#define DYLD_VM_END_MWL (-1ull) + +PRE(shared_region_check_np) +{ + // Special value used by dyld to forbid further uses of map_with_linking_np on macOS 13+ + Bool special_call = DARWIN_VERS >= DARWIN_13_00 && ARG1 == DYLD_VM_END_MWL; + + if (special_call) { + PRINT("shared_region_check_np(disable_map_with_linking)"); + } else { + PRINT("shared_region_check_np(%#lx)", ARG1); + } + PRE_REG_READ1(kern_return_t, "shared_region_check_np", uint64_t*, start_address); + + if (!special_call) { + PRE_MEM_WRITE("shared_region_check_np(start_address)", ARG1, sizeof(uint64_t)); +} +} + +POST(shared_region_check_np) +{ + Bool special_call = DARWIN_VERS >= DARWIN_13_00 && ARG1 == DYLD_VM_END_MWL; + + if (special_call) { + return; + } + + if (RES == 0) { + POST_MEM_WRITE(ARG1, sizeof(uint64_t)); + PRINT("shared dyld cache %#llx", *((uint64_t*) ARG1)); + } +} + +PRE(shared_region_map_and_slide_np) +{ + PRINT("shared_region_map_and_slide_np(%ld, %lu, %#lx, %lu, %#lx, %lu)", SARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(kern_return_t, "shared_region_map_and_slide_np", + int, fd, uint32_t, count, const struct shared_file_mapping_np*, mappings, + uint32_t, slide, uint64_t*, slide_start, uint32_t, slide_size); +} + +PRE(task_read_for_pid) +{ + PRINT("task_read_for_pid(%s, %ld, %#lx)", name_for_port(ARG1), SARG2, ARG3); + PRE_REG_READ3(kern_return_t, "task_read_for_pid", mach_port_name_t, target_tport, int, pid, mach_port_name_t*, t); + + if (ARG3 != 0) { + PRE_MEM_WRITE("task_read_for_pid(t)", ARG3, sizeof(mach_port_name_t)); + } +} + +POST(task_read_for_pid) +{ + if (RES == 0 && ARG3 != 0) { + POST_MEM_WRITE(ARG3, sizeof(mach_port_name_t)); + PRINT("-> t:%s", name_for_port(*(mach_port_name_t*)ARG3)); + } +} + +PRE(ulock_wait2) +{ + PRINT("ulock_wait2(%ld, %#lx, %ld, %#lx, %ld)", + SARG1, ARG2, SARG3, ARG4, SARG5); + PRE_REG_READ5(int, "ulock_wait2", + uint32_t, operation, void*, addr, uint64_t, value, + uint32_t, timeout, uint64_t, value2); + Int value_size = 4; + if (ARG1 == VKI_UL_COMPARE_AND_WAIT64 + || ARG1 == VKI_UL_COMPARE_AND_WAIT64_SHARED + || ARG1 == VKI_UL_COMPARE_AND_WAIT_SHARED) { + value_size = 8; + } + if (ARG2 != 0) { + PRE_MEM_READ("ulock_wait2(addr)", ARG2, value_size); + *flags |= SfMayBlock; + } else { + SET_STATUS_Failure( VKI_EINVAL ); + } +} + +#if defined(VGA_arm64) +PRE(sys_crossarch_trap) +{ + PRINT("sys_crossarch_trap(%lu)", ARG1); + PRE_REG_READ1(kern_return_t, "sys_crossarch_trap", uint32_t, name); +} + +PRE(objc_bp_assist_cfg_np) +{ + PRINT("objc_bp_assist_cfg_np(%#lx, %#lx)", ARG1, ARG2); +} +#endif + +#endif /* DARWIN_VERS >= DARWIN_11_00 */ + + /* --------------------------------------------------------------------- syscall tables ------------------------------------------------------------------ */ @@ -11433,7 +11561,9 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_mkfifo_extended), // _____(__NR_mkdir_extended), // _____(__NR_identitysvc), -// _____(__NR_shared_region_check_np), +#if DARWIN_VERS >= DARWIN_11_00 + MACXY(__NR_shared_region_check_np, shared_region_check_np), // 294 +#endif // _____(__NR_shared_region_map_np), #if DARWIN_VERS >= DARWIN_10_6 // _____(__NR_vm_pressure_mon... [truncated message content] |
|
From: Paul F. <pa...@so...> - 2025-12-19 11:34:43
|
https://sourceware.org/cgit/valgrind/commit/?id=2fd107444decbcc777790b448c39e5f7036f4748 commit 2fd107444decbcc777790b448c39e5f7036f4748 Author: Paul Floyd <pj...@wa...> Date: Fri Dec 19 12:33:50 2025 +0100 regtest: filter leaks from memcheck threadname_xml and update expected Diff: --- memcheck/tests/threadname_xml.stderr.exp | 2 -- memcheck/tests/threadname_xml.vgtest | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/memcheck/tests/threadname_xml.stderr.exp b/memcheck/tests/threadname_xml.stderr.exp index 1671b50a26..0b693ec02f 100644 --- a/memcheck/tests/threadname_xml.stderr.exp +++ b/memcheck/tests/threadname_xml.stderr.exp @@ -304,8 +304,6 @@ <heap_summary>...</heap_summary> -<leak_summary>...</leak_summary> - <errorcounts> <pair> <count>...</count> diff --git a/memcheck/tests/threadname_xml.vgtest b/memcheck/tests/threadname_xml.vgtest index 8a352da985..eba971a920 100644 --- a/memcheck/tests/threadname_xml.vgtest +++ b/memcheck/tests/threadname_xml.vgtest @@ -1,4 +1,4 @@ prereq: test -e ./threadname && ! ../../tests/os_test illumos prog: threadname vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null -stderr_filter: filter_xml +stderr_filter: filter_xml_leak |
|
From: Paul F. <pa...@so...> - 2025-12-19 06:08:52
|
https://sourceware.org/cgit/valgrind/commit/?id=d101bbd76e7c5b6078431ff0eca53b6b3d8c9250 commit d101bbd76e7c5b6078431ff0eca53b6b3d8c9250 Author: Paul Floyd <pj...@wa...> Date: Fri Dec 19 07:07:12 2025 +0100 regtest: change memcheck threadname_xml prereq This was using test -u which doesn't work on Darwin so I changed that to -e. Diff: --- memcheck/tests/threadname_xml.vgtest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memcheck/tests/threadname_xml.vgtest b/memcheck/tests/threadname_xml.vgtest index 5d3acea6f8..8a352da985 100644 --- a/memcheck/tests/threadname_xml.vgtest +++ b/memcheck/tests/threadname_xml.vgtest @@ -1,4 +1,4 @@ -prereq: test -u ./threadname && ! ../../tests/os_test illumos +prereq: test -e ./threadname && ! ../../tests/os_test illumos prog: threadname vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null stderr_filter: filter_xml |
|
From: Paul F. <pa...@so...> - 2025-12-19 06:02:24
|
https://sourceware.org/cgit/valgrind/commit/?id=8a95c48c80de40199eba5d8e6119f27bb84a50b9 commit 8a95c48c80de40199eba5d8e6119f27bb84a50b9 Author: Paul Floyd <pj...@wa...> Date: Fri Dec 19 06:58:51 2025 +0100 Bug 258140 - Valgrind on OS X always reports some memory "still reachable" Just needed one more suppression for the minimal test in the bugzilla item. I expect that there will be a seemingly endless number of leaks in Darwin (different libs, later versions). Diff: --- NEWS | 1 + darwin.supp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b8e15e0df2..6360e83a5b 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,7 @@ than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. 228343 none/tests/darwin/bug228343 fails on OS X +258140 Valgrind on OS X always reports some memory "still reachable" 413369 unhandled amd64-darwin syscall: unix:151 (getpgid) 487055 memcheck/tests/x86-linux/scalar fails running in Docker 509562 s390x: Define minimum required machine model diff --git a/darwin.supp b/darwin.supp index 1f693d6b22..f256a3a068 100644 --- a/darwin.supp +++ b/darwin.supp @@ -783,8 +783,16 @@ # I suppose that this is deliberate # and that Apple know what they are doing? { - masOS1015:__chkstk_darwin_probe + macOS1015:__chkstk_darwin_probe Memcheck:Addr8 fun:__chkstk_darwin_probe } +{ + macOS1015:_mh_execute_header + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_mh_execute_header +} + |
|
From: Paul F. <pa...@so...> - 2025-12-18 07:39:51
|
https://sourceware.org/cgit/valgrind/commit/?id=f20461ab7764226e9eb71cf07a93b931a55d2cac commit f20461ab7764226e9eb71cf07a93b931a55d2cac Author: Paul Floyd <pj...@wa...> Date: Thu Dec 18 08:36:25 2025 +0100 Darwin and FreeBSD: and the two platforms to the check that 32bit executables can be built I don't think that I've ever tested this on a FreeBSD amd64 install without 32bit support. This check is required on Darwin 19 and later. Diff: --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1a374999bd..55d26b2a51 100644 --- a/configure.ac +++ b/configure.ac @@ -682,7 +682,7 @@ esac # does not support building 32 bit programs case "$ARCH_MAX-$VGCONF_OS" in - amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris) + amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris|amd64-darwin|amd64-freebsd) AC_MSG_CHECKING([for 32 bit build support]) safe_CFLAGS=$CFLAGS CFLAGS="-m32" |
|
From: Paul F. <pa...@so...> - 2025-12-18 07:31:57
|
https://sourceware.org/cgit/valgrind/commit/?id=4edf31a38f01c860b3d1677c79784f25f941bb0d commit 4edf31a38f01c860b3d1677c79784f25f941bb0d Author: Paul Floyd <pj...@wa...> Date: Thu Dec 18 08:30:07 2025 +0100 configure.ac: tabs to spaces in block setting PLATFORM PRI and SEC variables It was a mix of tabs and spaces, hard to read without the right tab width setting. Diff: --- configure.ac | 64 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index 81e7178b53..1a374999bd 100644 --- a/configure.ac +++ b/configure.ac @@ -765,83 +765,83 @@ case "$ARCH_MAX-$VGCONF_OS" in x86-linux) VGCONF_ARCH_PRI="x86" VGCONF_ARCH_SEC="" - VGCONF_PLATFORM_PRI_CAPS="X86_LINUX" - VGCONF_PLATFORM_SEC_CAPS="" + VGCONF_PLATFORM_PRI_CAPS="X86_LINUX" + VGCONF_PLATFORM_SEC_CAPS="" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" valt_load_address_sec_norml="0xUNSET" valt_load_address_sec_inner="0xUNSET" AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) - ;; + ;; amd64-linux) valt_load_address_sec_norml="0xUNSET" valt_load_address_sec_inner="0xUNSET" - if test x$vg_cv_only64bit = xyes; then + if test x$vg_cv_only64bit = xyes; then VGCONF_ARCH_PRI="amd64" VGCONF_ARCH_SEC="" - VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX" - VGCONF_PLATFORM_SEC_CAPS="" + VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX" + VGCONF_PLATFORM_SEC_CAPS="" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" - elif test x$vg_cv_only32bit = xyes; then - VGCONF_ARCH_PRI="x86" + elif test x$vg_cv_only32bit = xyes; then + VGCONF_ARCH_PRI="x86" VGCONF_ARCH_SEC="" - VGCONF_PLATFORM_PRI_CAPS="X86_LINUX" - VGCONF_PLATFORM_SEC_CAPS="" + VGCONF_PLATFORM_PRI_CAPS="X86_LINUX" + VGCONF_PLATFORM_SEC_CAPS="" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" - else + else VGCONF_ARCH_PRI="amd64" VGCONF_ARCH_SEC="x86" - VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX" - VGCONF_PLATFORM_SEC_CAPS="X86_LINUX" + VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX" + VGCONF_PLATFORM_SEC_CAPS="X86_LINUX" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" valt_load_address_sec_norml="0x58000000" valt_load_address_sec_inner="0x38000000" - fi + fi AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) - ;; + ;; ppc32-linux) VGCONF_ARCH_PRI="ppc32" VGCONF_ARCH_SEC="" - VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX" - VGCONF_PLATFORM_SEC_CAPS="" + VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX" + VGCONF_PLATFORM_SEC_CAPS="" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" valt_load_address_sec_norml="0xUNSET" valt_load_address_sec_inner="0xUNSET" AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) - ;; + ;; ppc64be-linux) valt_load_address_sec_norml="0xUNSET" valt_load_address_sec_inner="0xUNSET" - if test x$vg_cv_only64bit = xyes; then - VGCONF_ARCH_PRI="ppc64be" + if test x$vg_cv_only64bit = xyes; then + VGCONF_ARCH_PRI="ppc64be" VGCONF_ARCH_SEC="" - VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX" - VGCONF_PLATFORM_SEC_CAPS="" + VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX" + VGCONF_PLATFORM_SEC_CAPS="" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" - elif test x$vg_cv_only32bit = xyes; then - VGCONF_ARCH_PRI="ppc32" + elif test x$vg_cv_only32bit = xyes; then + VGCONF_ARCH_PRI="ppc32" VGCONF_ARCH_SEC="" - VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX" - VGCONF_PLATFORM_SEC_CAPS="" + VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX" + VGCONF_PLATFORM_SEC_CAPS="" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" - else - VGCONF_ARCH_PRI="ppc64be" + else + VGCONF_ARCH_PRI="ppc64be" VGCONF_ARCH_SEC="ppc32" - VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX" - VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX" + VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX" + VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX" valt_load_address_pri_norml="0x58000000" valt_load_address_pri_inner="0x38000000" valt_load_address_sec_norml="0x58000000" valt_load_address_sec_inner="0x38000000" - fi + fi AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) - ;; + ;; ppc64le-linux) # Little Endian is only supported on PPC64 valt_load_address_sec_norml="0xUNSET" |
|
From: Paul F. <pa...@so...> - 2025-12-18 07:00:37
|
https://sourceware.org/cgit/valgrind/commit/?id=6f1b1f3d7d00f45bacebc2bfae667fc0ff8a461b commit 6f1b1f3d7d00f45bacebc2bfae667fc0ff8a461b Author: Paul Floyd <pj...@wa...> Date: Thu Dec 18 07:59:38 2025 +0100 Bug 513522 - m_libcassert.c: 'ordered comparison of pointer with integer zero' compiler warning Diff: --- NEWS | 2 ++ coregrind/m_libcassert.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 06bf59ebbf..b8e15e0df2 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. 512037 malloc trace does not print free size or alignment 512571 regtest problems with darwin dsymuti 513257 Add missing syswraps for lsm_list_modules +513522 m_libcassert.c: 'ordered comparison of pointer with integer zero' + compiler warning To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index 35a988c65d..e757aa59e1 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -500,7 +500,7 @@ static void report_and_quit ( const HChar* report, False, // exited_threads startRegsIN); - if (VG_(debugLog_getLevel) > 0) { + if (VG_(debugLog_getLevel)() > 0) { VG_(am_show_nsegments) (1, "report_and_quit"); (void) VG_(am_do_sync_check) ("report_and_quit", __FILE__, __LINE__); } |
|
From: Florian K. <fk...@so...> - 2025-12-17 22:32:28
|
https://sourceware.org/cgit/valgrind/commit/?id=1d4182eed4dd25d7f2a0004f46e51b7a00ca5d5a commit 1d4182eed4dd25d7f2a0004f46e51b7a00ca5d5a Author: Florian Krohm <fl...@ei...> Date: Wed Dec 17 22:31:41 2025 +0000 s390 disasm-test: Add constraint for VPDI insn. Diff: --- none/tests/s390x/disasm-test/disasm-test.post.exp | 4 ++-- none/tests/s390x/disasm-test/opcode.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/none/tests/s390x/disasm-test/disasm-test.post.exp b/none/tests/s390x/disasm-test/disasm-test.post.exp index 0f31f36ca6..bd87908551 100644 --- a/none/tests/s390x/disasm-test/disasm-test.post.exp +++ b/none/tests/s390x/disasm-test/disasm-test.post.exp @@ -1,4 +1,4 @@ -Total: 148776 tests generated -Total: 148684 insns verified +Total: 148764 tests generated +Total: 148672 insns verified Total: 0 disassembly mismatches Total: 92 specification exceptions diff --git a/none/tests/s390x/disasm-test/opcode.c b/none/tests/s390x/disasm-test/opcode.c index 86cd642f3f..3623e8ecb4 100644 --- a/none/tests/s390x/disasm-test/opcode.c +++ b/none/tests/s390x/disasm-test/opcode.c @@ -1236,7 +1236,7 @@ static const char *opcodes[] = { "vpks v1,v2,v3,m4:{1..3},m5:{0,1}", // no spec. exception for m5 "vpkls v1,v2,v3,m4:{1..3},m5:{0,1}", // no spec. exception for m5 "vperm v1,v2,v3,v4", - "vpdi v1,v2,v3,m4", + "vpdi v1,v2,v3,m4:{0,1,4,5}", // no spec. exception for m4 // "vrep v1,v3,i2:u16,m4:{0..3}", "vrepi v1,i2:s16,m3:{0..3}", "vscef v1,d12(v2,b2),m3:{0..3}", |
|
From: Paul F. <pa...@so...> - 2025-12-17 18:45:06
|
https://sourceware.org/cgit/valgrind/commit/?id=d3cd66160c7e62f611c23a5916b6025a835e857f commit d3cd66160c7e62f611c23a5916b6025a835e857f Author: Paul Floyd <pj...@wa...> Date: Sun Dec 14 21:04:08 2025 +0100 Darwin: add macOS 10.15 support == 721 tests, 46 stderr failures, 6 stdout failures, 0 stderrB failures, 0 stdoutB failures, 4 post failures == A couple more failures in none (empty-exe and scripts/shell). Otherwise quite like macOS 10.14. Much of the code merged from Louis Brunner's git repo. Many thanks once again Louis. Diff: --- NEWS | 2 +- configure.ac | 6 +- coregrind/Makefile.am | 1 + coregrind/m_debuginfo/debuginfo.c | 20 ++- coregrind/m_debuginfo/readmacho.c | 6 +- coregrind/m_initimg/initimg-darwin.c | 9 +- coregrind/m_mach/mig_strncpy.c | 121 +++++++++++++++++ coregrind/m_syswrap/priv_syswrap-darwin.h | 11 ++ coregrind/m_syswrap/syswrap-darwin.c | 144 ++++++++++++++++++++- darwin-drd.supp | 21 +++ darwin-helgrind.supp | 26 ++++ darwin.supp | 43 ++---- include/vki/vki-darwin.h | 3 + include/vki/vki-scnums-darwin.h | 11 ++ massif/tests/alloc-fns-A.vgtest | 2 + massif/tests/alloc-fns-B.vgtest | 2 + massif/tests/basic.vgtest | 2 + massif/tests/basic2.vgtest | 2 + massif/tests/big-alloc.vgtest | 2 + massif/tests/bug469146.vgtest | 2 + massif/tests/culling1.stderr.exp | 5 + massif/tests/culling1.vgtest | 2 + massif/tests/culling2.stderr.exp | 5 + massif/tests/culling2.vgtest | 2 + massif/tests/custom_alloc.vgtest | 2 + massif/tests/deep-A.vgtest | 2 + massif/tests/deep-B.stderr.exp | 5 + massif/tests/deep-B.vgtest | 2 + massif/tests/deep-C.stderr.exp | 5 + massif/tests/deep-C.vgtest | 2 + massif/tests/deep-D.vgtest | 2 + massif/tests/filter_ignore_fn | 6 +- massif/tests/ignored.vgtest | 2 + massif/tests/ignoring.vgtest | 2 + massif/tests/inlinfomalloc.vgtest | 2 + massif/tests/insig.vgtest | 2 + massif/tests/long-names.vgtest | 2 + massif/tests/long-time.vgtest | 2 + massif/tests/new-cpp.vgtest | 2 + massif/tests/null.vgtest | 2 + massif/tests/one.vgtest | 2 + massif/tests/overloaded-new.vgtest | 2 + massif/tests/peak.vgtest | 2 + massif/tests/peak2.stderr.exp | 5 + massif/tests/peak2.vgtest | 2 + massif/tests/realloc.stderr.exp | 5 + massif/tests/realloc.vgtest | 2 + massif/tests/thresholds_0_0.vgtest | 2 + massif/tests/thresholds_0_10.vgtest | 2 + massif/tests/thresholds_10_0.vgtest | 2 + massif/tests/thresholds_10_10.vgtest | 2 + massif/tests/thresholds_5_0.vgtest | 2 + massif/tests/thresholds_5_10.vgtest | 2 + massif/tests/zero1.vgtest | 2 + massif/tests/zero2.vgtest | 2 + memcheck/tests/Makefile.am | 2 + .../duplicate_align_size_errors.stderr.exp-darwin2 | 27 ++++ memcheck/tests/memalign_args.stderr.exp-darwin2 | 12 ++ 58 files changed, 529 insertions(+), 40 deletions(-) diff --git a/NEWS b/NEWS index 53768ece3f..06bf59ebbf 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,7 @@ PPC32/Linux, PPC64BE/Linux, PPC64LE/Linux, S390X/Linux, MIPS32/Linux, MIPS64/Linux, RISCV64/Linux, ARM/Android, ARM64/Android, MIPS32/Android, X86/Android, X86/Solaris, AMD64/Solaris, X86/macOS, AMD64/macOS. X86/FreeBSD, AMD64/FreeBSD and ARM64/FreeBSD. There is preliminary support -for nanoMIPS/Linux. macOS is supported up to version 10.14 Mojave. +for nanoMIPS/Linux. macOS is supported up to version 10.15 Catalina. * ==================== CORE CHANGES =================== diff --git a/configure.ac b/configure.ac index 5deb338fa3..81e7178b53 100644 --- a/configure.ac +++ b/configure.ac @@ -546,9 +546,13 @@ case "${host_os}" in AC_MSG_RESULT([Darwin 18.x (${kernel}) / macOS 10.14 Mojave]) DARWIN_VERS=$DARWIN_10_14 ;; + 19.*) + AC_MSG_RESULT([Darwin 19.x (${kernel}) / macOS 10.15 Catalina]) + DARWIN_VERS=$DARWIN_10_15 + ;; *) AC_MSG_RESULT([unsupported (${darwin_platform} ${kernel})]) - AC_MSG_ERROR([Valgrind works on Darwin 10.x-25.x (Mac OS X 10.8-10.11, macOS 10.12-10.13)]) + AC_MSG_ERROR([Valgrind works on Darwin 12.x-19.x (Mac OS X 10.8-10.11, macOS 10.12-10.15)]) ;; esac diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 65369ebcd2..90d921db28 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -432,6 +432,7 @@ COREGRIND_SOURCES_COMMON = \ m_mach/mach_msg.c \ m_mach/mach_traps-x86-darwin.S \ m_mach/mach_traps-amd64-darwin.S \ + m_mach/mig_strncpy.c \ m_replacemalloc/replacemalloc_core.c \ m_scheduler/sched-lock.c \ m_scheduler/sched-lock-generic.c \ diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 3daa38a3a9..66430668b5 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -555,9 +555,26 @@ static Bool ranges_overlap (Addr s1, SizeT len1, Addr s2, SizeT len2 ) /* Do the basic mappings of the two DebugInfos overlap in any way? */ static Bool do_DebugInfos_overlap ( const DebugInfo* di1, const DebugInfo* di2 ) { - Word i, j; vg_assert(di1); vg_assert(di2); +#if defined(VGO_darwin) && DARWIN_VERS >= DARWIN_10_15 + // FIXME: This is probably wrong but the other methods returns too many false positives + // as it doesn't account for munmap being called on one of these maps. + // dyld will mmap and then munmap every library ro_map at the same address thus every library shows + // an overlap and only the last is retained, making most debug UNKNOW_FUNCTION UNKNOWN_OBJECT. + // Seeing how discard_syms_in_range relies exclusively on text_* to check conflicts, let's do the same here + + // Sanity check needed by discard_DebugInfos_which_overlap_with + if (di1 == di2) { + return True; + } + if (!di1->text_present || !di2->text_present) { + return False; + } + return ranges_overlap(di1->text_avma, di1->text_size, di2->text_avma, di2->text_size); +#else + Word i, j; + for (i = 0; i < VG_(sizeXA)(di1->fsm.maps); i++) { const DebugInfoMapping* map1 = VG_(indexXA)(di1->fsm.maps, i); for (j = 0; j < VG_(sizeXA)(di2->fsm.maps); j++) { @@ -569,6 +586,7 @@ static Bool do_DebugInfos_overlap ( const DebugInfo* di1, const DebugInfo* di2 ) } return False; +#endif } diff --git a/coregrind/m_debuginfo/readmacho.c b/coregrind/m_debuginfo/readmacho.c index 2c59d09deb..6224feea38 100644 --- a/coregrind/m_debuginfo/readmacho.c +++ b/coregrind/m_debuginfo/readmacho.c @@ -92,8 +92,8 @@ static Int count_rw_loads(const struct load_command* macho_load_commands, unsign if (lc->cmd == LC_SEGMENT_CMD) { const struct SEGMENT_COMMAND* sc = (const struct SEGMENT_COMMAND*)lc; if (sc->initprot == 3 && sc->filesize -#if DARWIN_VERS >= DARWIN_13_00 -// FIXME: somehow __DATA_CONST appears as rw- in most binaries in macOS 13 and later (not sure when that started) +#if DARWIN_VERS >= DARWIN_10_15 +// FIXME: somehow __DATA_CONST appears as rw- in most binaries in macOS 10.15 // so we ignore it otherwise some binaries don't get symbols && VG_(strcmp)(sc->segname, "__DATA_CONST") != 0 #endif @@ -1010,7 +1010,7 @@ Bool ML_(read_macho_debug_info)( struct _DebugInfo* di ) di->data_present = True; di->data_svma = (Addr)seg.vmaddr; di->data_avma = rw_map->avma; -#if defined(VGA_arm64) +#if defined(VGO_darwin) && (DARWIN_VERS >= DARWIN_10_15) // FIXME: the same mmap contains both __DATA_CONST, __DATA and __DATA_DIRTY // this means that symbols in __DATA/__DATA_DIRTY are offset by the size of __DATA_CONST // not sure when this started to be an issue so I am going to gate this under arm64 for now diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c index d4257c9544..c15c023723 100644 --- a/coregrind/m_initimg/initimg-darwin.c +++ b/coregrind/m_initimg/initimg-darwin.c @@ -160,7 +160,11 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) /* Allocate a new space */ ret = VG_(malloc) ("initimg-darwin.sce.3", +#if DARWIN_VERS >= DARWIN_10_15 + sizeof(HChar *) * (envc+3+1)); /* 3 new entries + NULL */ +#else sizeof(HChar *) * (envc+2+1)); /* 2 new entries + NULL */ +#endif /* copy it over */ for (cpp = ret; *origenv; ) @@ -211,7 +215,10 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname) ret[envc++] = cp; } - +#if DARWIN_VERS >= DARWIN_10_15 + // pthread really wants a non-zero value for ptr_munge + ret[envc++] = VG_(strdup)("initimg-darwin.sce.6", "PTHREAD_PTR_MUNGE_TOKEN=0x00000001"); +#endif /* ret[0 .. envc-1] is live now. */ /* Find and remove a binding for VALGRIND_LAUNCHER. */ diff --git a/coregrind/m_mach/mig_strncpy.c b/coregrind/m_mach/mig_strncpy.c new file mode 100644 index 0000000000..9e07e8c85c --- /dev/null +++ b/coregrind/m_mach/mig_strncpy.c @@ -0,0 +1,121 @@ +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (c) 2020-2025 Louis Brunner <lou...@gm...> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ +/* + * This file contains mig_strncpy and mig_strncpy_zerofill reimplemented + * from comments left by Joshua Block in the original file + * `xnu/libsyscall/mach/mig_strncpy.c` + * + * Here they are for reference: + */ +/* + * mig_strncpy.c - by Joshua Block + * + * mig_strncpy -- Bounded string copy. Does what the library routine strncpy + * OUGHT to do: Copies the (null terminated) string in src into dest, a + * buffer of length len. Assures that the copy is still null terminated + * and doesn't overflow the buffer, truncating the copy if necessary. + * + * Parameters: + * + * dest - Pointer to destination buffer. + * + * src - Pointer to source string. + * + * len - Length of destination buffer. + * + * Result: + * length of string copied, INCLUDING the trailing 0. + * + * mig_strncpy_zerofill -- Bounded string copy. Does what the + * library routine strncpy OUGHT to do: Copies the (null terminated) + * string in src into dest, a buffer of length len. Assures that + * the copy is still null terminated and doesn't overflow the buffer, + * truncating the copy if necessary. If the string in src is smaller + * than given length len, it will zero fill the remaining bytes in dest. + * + * Parameters: + * + * dest - Pointer to destination buffer. + * + * src - Pointer to source string. + * + * len - Length of destination buffer. + * + * Result: + * length of string copied, INCLUDING the trailing 0. + */ + +#if defined(VGO_darwin) + +#include <mach/mig_errors.h> + +int mig_strncpy(char *dest, const char *src, int len) +{ + int i; + int src_len; + + for (src_len = 0; src[src_len]; ++src_len); + + if (len > src_len) { + for (i = 0; i < src_len; ++i) { + dest[i] = src[i]; + } + dest[i] = '\0'; + return i + 1; + } + + for (i = 0; i < len; ++i) { + dest[i] = src[i]; + } + dest[i - 1] = '\0'; + return i; +} + +int mig_strncpy_zerofill(char *dest, const char *src, int len) +{ + int i; + int src_len; + + for (src_len = 0; src[src_len]; ++src_len); + + if (len > src_len) { + for (i = 0; i < src_len; ++i) { + dest[i] = src[i]; + } + for (; i < len; ++i) { + dest[i] = '\0'; + } + return len; + } + + for (i = 0; i < len; ++i) { + dest[i] = src[i]; + } + dest[i - 1] = '\0'; + return len; +} + +#endif // defined(VGO_darwin) + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index a96ce36b49..7ffc4f88f3 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -650,6 +650,11 @@ DECL_TEMPLATE(darwin, abort_with_payload); // 521 // NYI kqueue_workloop_ctl // 530 // NYI __mach_bridge_remote_time // 531 #endif /* DARWIN_VERS >= DARWIN_10_14 */ +#if DARWIN_VERS >= DARWIN_10_15 +// NYI coalition_ledger // 532 +// NYI log_data // 533 +// NYI memorystatus_available_memory // 534 +#endif // Mach message helpers DECL_TEMPLATE(darwin, mach_port_set_context); @@ -794,6 +799,12 @@ DECL_TEMPLATE(darwin, swtch_pri); DECL_TEMPLATE(darwin, kernelrpc_mach_port_get_attributes_trap); #endif /* DARWIN_VERS >= DARWIN_10_14 */ +#if DARWIN_VERS >= DARWIN_10_15 +DECL_TEMPLATE(darwin, task_restartable_ranges_register); +DECL_TEMPLATE(darwin, kernelrpc_mach_port_type_trap); +DECL_TEMPLATE(darwin, kernelrpc_mach_port_request_notification_trap); +#endif /* DARWIN_VERS >= DARWIN_10_15 */ + // Machine-dependent traps DECL_TEMPLATE(darwin, thread_fast_set_cthread_self); diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 80bd013f36..09c1338cfa 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -1779,6 +1779,9 @@ static const HChar *name_for_fcntl(UWord cmd) { # endif # if DARWIN_VERS >= DARWIN_10_14 F(F_CHECK_LV); +# endif +# if DARWIN_VERS >= DARWIN_10_15 + F(F_SPECULATIVE_READ); # endif default: return "UNKNOWN"; @@ -1985,6 +1988,29 @@ PRE(fcntl) break; # endif +# if DARWIN_VERS >= DARWIN_10_15 + case VKI_F_SPECULATIVE_READ: /* Synchronous advisory read fcntl for regular and compressed file */ + PRINT("fcntl ( %lu, %s, %#lx )", ARG1, name_for_fcntl(ARG2), ARG3); + PRE_REG_READ3(long, "fcntl", + unsigned int, fd, unsigned int, cmd, + fspecread_t *, args); + + { + fspecread_t *fspecread = (fspecread_t *)ARG3; + PRE_FIELD_READ( "fcntl(VKI_F_SPECULATIVE_READ, fspecread->fsr_flags)", + fspecread->fsr_flags); + PRE_FIELD_READ( "fcntl(VKI_F_SPECULATIVE_READ, fspecread->fsr_offset)", + fspecread->fsr_offset); + PRE_FIELD_READ( "fcntl(VKI_F_SPECULATIVE_READ, fspecread->fsr_length)", + fspecread->fsr_length); + + if (fspecread->fsr_offset < 0 || fspecread->fsr_length < 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + } + break; +# endif + default: PRINT("fcntl ( %lu, %lu [??] )", ARG1, ARG2); log_decaying("UNKNOWN fcntl %lu!", ARG2); @@ -3399,8 +3425,13 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, { ATTR_CMN_OWNERID, sizeof(uid_t) }, { ATTR_CMN_GRPID, sizeof(gid_t) }, { ATTR_CMN_ACCESSMASK, sizeof(uint32_t) }, +#if DARWIN_VERS >= DARWIN_10_15 + { ATTR_CMN_GEN_COUNT, sizeof(uint32_t) }, + { ATTR_CMN_DOCUMENT_ID, sizeof(uint32_t) }, +#else { ATTR_CMN_NAMEDATTRCOUNT, sizeof(uint32_t) }, { ATTR_CMN_NAMEDATTRLIST, -1 }, +#endif { ATTR_CMN_FLAGS, sizeof(uint32_t) }, { ATTR_CMN_USERACCESS, sizeof(uint32_t) }, { ATTR_CMN_EXTENDED_SECURITY, -1 }, @@ -3413,6 +3444,10 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, #endif #if DARWIN_VERS >= DARWIN_10_8 { ATTR_CMN_ADDEDTIME, -1 }, +#endif +#if DARWIN_VERS >= DARWIN_10_15 + { ATTR_CMN_ERROR, sizeof(uint32_t) }, + { ATTR_CMN_DATA_PROTECT_FLAGS, sizeof(uint32_t) }, #endif { 0, 0 } }; @@ -3439,6 +3474,10 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, { ATTR_VOL_CAPABILITIES, sizeof(vol_capabilities_attr_t) }, #if DARWIN_VERS >= DARWIN_10_6 { ATTR_VOL_UUID, sizeof(uuid_t) }, +#endif +#if DARWIN_VERS >= DARWIN_10_15 + { ATTR_VOL_QUOTA_SIZE, sizeof(off_t) }, + { ATTR_VOL_RESERVED_SIZE, sizeof(off_t) }, #endif { ATTR_VOL_ATTRIBUTES, sizeof(vol_attributes_attr_t) }, { 0, 0 } @@ -3448,6 +3487,11 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, { ATTR_DIR_LINKCOUNT, sizeof(uint32_t) }, { ATTR_DIR_ENTRYCOUNT, sizeof(uint32_t) }, { ATTR_DIR_MOUNTSTATUS, sizeof(uint32_t) }, +#if DARWIN_VERS >= DARWIN_10_15 + { ATTR_DIR_ALLOCSIZE, sizeof(off_t) }, + { ATTR_DIR_IOBLOCKSIZE, sizeof(uint32_t) }, + { ATTR_DIR_DATALENGTH, sizeof(off_t) }, +#endif { 0, 0 } }; static const attrspec fileattr[] = { @@ -3473,6 +3517,16 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, // This order is important. { ATTR_FORK_TOTALSIZE, sizeof(off_t) }, { ATTR_FORK_ALLOCSIZE, sizeof(off_t) }, +#if DARWIN_VERS >= DARWIN_10_15 + { ATTR_CMNEXT_RELPATH, sizeof(struct attrreference) }, + { ATTR_CMNEXT_PRIVATESIZE, sizeof(off_t) }, + { ATTR_CMNEXT_LINKID, sizeof(uint64_t) }, + { ATTR_CMNEXT_NOFIRMLINKPATH, sizeof(struct attrreference) }, + { ATTR_CMNEXT_REALDEVID, sizeof(uint32_t) }, + { ATTR_CMNEXT_REALFSID, sizeof(fsid_t) }, + { ATTR_CMNEXT_CLONEID, sizeof(uint64_t) }, + { ATTR_CMNEXT_EXT_FLAGS, sizeof(uint64_t) }, +#endif { 0, 0 } }; @@ -8643,6 +8697,12 @@ PRE(mach_msg_task) CALL_PRE(mach_vm_purgable_control); return; +#if DARWIN_VERS >= DARWIN_10_15 + case 8000: + CALL_PRE(task_restartable_ranges_register); + return; +#endif + default: // unknown message to task self log_decaying("UNKNOWN task message [id %d, to %s, reply 0x%x]", @@ -10949,6 +11009,79 @@ PRE(kernelrpc_mach_port_get_attributes_trap) } } #endif /* DARWIN_VERS >= DARWIN_10_14 */ + + +/* --------------------------------------------------------------------- + Added for macOS 10.15 (Catalina) + ------------------------------------------------------------------ */ + +#if DARWIN_VERS >= DARWIN_10_15 + +PRE(task_restartable_ranges_register) +{ + PRINT("task_restartable_ranges_register(%s, %#lx, %ld)", name_for_port(ARG1), ARG2, SARG3); +} + +POST(task_restartable_ranges_register) +{ +#pragma pack(4) + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } Reply; +#pragma pack() + + Reply *reply = (Reply *)ARG1; + + if (!reply->RetCode) { + } else { + PRINT("mig return %d", reply->RetCode); + } +} + +PRE(kernelrpc_mach_port_request_notification_trap) +{ + PRINT("kernelrpc_mach_port_request_notification_trap(%s, %s, %ld, %ld, %s, %ld, %#lx)", + name_for_port(ARG1), name_for_port(ARG2), SARG3, SARG4, name_for_port(ARG5), SARG6, ARG7); + PRE_REG_READ7(kern_return_t, "kernelrpc_mach_port_request_notification_trap", + ipc_space_t, task, mach_port_name_t, name, mach_msg_id_t, msgid, + mach_port_mscount_t, sync, mach_port_name_t, notify, mach_msg_type_name_t, notifyPoly, + mach_port_name_t*, previous); + if (ARG7 != 0) { + PRE_MEM_WRITE("kernelrpc_mach_port_request_notification_trap(previous)", ARG7, sizeof(mach_port_name_t)); + } +} + +POST(kernelrpc_mach_port_request_notification_trap) +{ + if (RES == 0 && ARG7 != 0) { + POST_MEM_WRITE(ARG7, sizeof(mach_port_name_t)); + PRINT("-> previous:%s", name_for_port(*(mach_port_name_t*)ARG7)); + } +} + +PRE(kernelrpc_mach_port_type_trap) +{ + PRINT("kernelrpc_mach_port_type_trap(%s, %s, %#lx)", + name_for_port(ARG1), name_for_port(ARG2), ARG3); + PRE_REG_READ3(kern_return_t, "kernelrpc_mach_port_type_trap", + ipc_space_t, task, mach_port_name_t, name, mach_port_type_t*, ptype); + if (ARG3 != 0) { + PRE_MEM_WRITE("kernelrpc_mach_port_type_trap(ptype)", ARG3, sizeof(mach_port_type_t)); + } +} + +POST(kernelrpc_mach_port_type_trap) +{ + if (RES == 0 && ARG3 != 0) { + POST_MEM_WRITE(ARG3, sizeof(mach_port_type_t)); + PRINT("-> ptype:%#x", *(mach_port_type_t*)ARG3); + } +} + +#endif /* DARWIN_VERS >= DARWIN_10_15 */ + /* --------------------------------------------------------------------- syscall tables ------------------------------------------------------------------ */ @@ -11576,7 +11709,11 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_kqueue_workloop_ctl), // 530 // _____(__NR___mach_bridge_remote_time), // 531 #endif - +#if DARWIN_VERS >= DARWIN_10_15 +// _____(__NR_coalition_ledger), // 532 +// _____(__NR_log_data), // 533 +// _____(__NR_memorystatus_available_memory), // 534 +#endif MACX_(__NR_darwin_fake_sigreturn, fake_sigreturn) }; @@ -11744,8 +11881,13 @@ const SyscallTableEntry ML_(mach_trap_table)[] = { _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(73)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(74)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(75)), +#if DARWIN_VERS >= DARWIN_10_15 + MACXY(__NR_kernelrpc_mach_port_type_trap, kernelrpc_mach_port_type_trap), + MACXY(__NR_kernelrpc_mach_port_request_notification_trap, kernelrpc_mach_port_request_notification_trap), +#else _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(76)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(77)), +#endif _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(78)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(79)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(80)), // -80 diff --git a/darwin-drd.supp b/darwin-drd.supp index 39f9b9b638..35f036ca06 100644 --- a/darwin-drd.supp +++ b/darwin-drd.supp @@ -420,3 +420,24 @@ ... fun:_ZN4dyld4loadEPKcRKNS_11LoadContextERj } + +{ + macOS1015:_CFInitialize + drd:ConflictingAccess + ... + fun:__CFInitialize +} + +{ + macOS1015:cache_validate_item + drd:ConflictingAccess + ... + fun:cache_validate_item +} + +{ + macOS1015:ds_user_byuid + drd:ConflictingAccess + ... + fun:ds_user_byuid +} diff --git a/darwin-helgrind.supp b/darwin-helgrind.supp index e4f628997a..1bd4175235 100644 --- a/darwin-helgrind.supp +++ b/darwin-helgrind.supp @@ -190,3 +190,29 @@ ... fun:_objc_msgSend_uncached } + +{ + macOS1015:NXMapInsert + Helgrind:Race + fun:NXMapInsert +} + +{ + macOS1015:notify_monitor_file + Helgrind:Race + fun:notify_monitor_file +} + +{ + macOS1015:_xpc_asprintf + Helgrind:Race + ... + fun:_xpc_asprintf +} + +{ + macOS1015:lookUpImpOrForward + Helgrind:Race + ... + fun:lookUpImpOrForward +} diff --git a/darwin.supp b/darwin.supp index 1fd1948115..1f693d6b22 100644 --- a/darwin.supp +++ b/darwin.supp @@ -54,21 +54,9 @@ { OSX1013:6-Leak Memcheck:Leak - match-leak-kinds: reachable - fun:malloc_zone_?alloc - ... - fun:map_images_nolock - fun:map_2_images -} - -{ - OSX1013:7-Leak - Memcheck:Leak - match-leak-kinds: possible - fun:malloc_zone_?alloc + match-leak-kinds: all ... fun:map_images_nolock - fun:map_2_images } { @@ -740,15 +728,6 @@ fun:NXCreate*TableFromZone } -{ - OSX1013:map_images-2 - Memcheck:Leak - match-leak-kinds: possible - fun:calloc - fun:map_images_nolock - fun:map_images -} - { OSX1013:map_images-3 Memcheck:Leak @@ -756,18 +735,11 @@ fun:calloc fun:_ZL12realizeClassP10objc_class } -{ - OSX1013:map_images-4 - Memcheck:Leak - match-leak-kinds: indirect - fun:malloc_zone_malloc - ... - fun:map_images_nolock -} + { OSX1013:map_images-5 Memcheck:Leak - match-leak-kinds: indirect + match-leak-kinds: all fun:malloc_zone_calloc fun:*NXHash* } @@ -807,3 +779,12 @@ fun:malloc_zone_calloc fun:_NXHashRehashToCapacity } + +# I suppose that this is deliberate +# and that Apple know what they are doing? +{ + masOS1015:__chkstk_darwin_probe + Memcheck:Addr8 + fun:__chkstk_darwin_probe +} + diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h index 5e381ab4c6..5acd38a4f5 100644 --- a/include/vki/vki-darwin.h +++ b/include/vki/vki-darwin.h @@ -411,6 +411,9 @@ typedef uint32_t vki_u32; #if DARWIN_VERS >= DARWIN_10_14 # define VKI_F_CHECK_LV F_CHECK_LV #endif +#if DARWIN_VERS >= DARWIN_10_15 +# define VKI_F_SPECULATIVE_READ F_SPECULATIVE_READ +#endif #define VKI_F_FULLFSYNC F_FULLFSYNC #define VKI_F_PATHPKG_CHECK F_PATHPKG_CHECK #define VKI_F_FREEZE_FS F_FREEZE_FS diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index 70b110e816..3f378d3018 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -218,6 +218,11 @@ #define __NR_host_create_mach_voucher_trap VG_DARWIN_SYSCALL_CONSTRUCT_MACH(70) #endif +#if DARWIN_VERS >= DARWIN_10_15 +#define __NR_kernelrpc_mach_port_type_trap VG_DARWIN_SYSCALL_CONSTRUCT_MACH(76) +#define __NR_kernelrpc_mach_port_request_notification_trap VG_DARWIN_SYSCALL_CONSTRUCT_MACH(77) +#endif + #define __NR_mach_voucher_extract_attr_recipe_trap VG_DARWIN_SYSCALL_CONSTRUCT_MACH(72) #define __NR_mach_timebase_info VG_DARWIN_SYSCALL_CONSTRUCT_MACH(89) @@ -859,6 +864,12 @@ #define __NR___mach_bridge_remote_time VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(531) #endif /* DARWIN_VERS >= DARWIN_10_14 */ +#if DARWIN_VERS >= DARWIN_10_15 +#define __NR_coalition_ledger VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(532) +#define __NR_log_data VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(533) +#define __NR_memorystatus_available_memory VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(534) +#endif + #define __NR_darwin_fake_sigreturn VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(1000) #endif diff --git a/massif/tests/alloc-fns-A.vgtest b/massif/tests/alloc-fns-A.vgtest index c9163223d4..ba3e87d196 100644 --- a/massif/tests/alloc-fns-A.vgtest +++ b/massif/tests/alloc-fns-A.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/alloc-fns-B.vgtest b/massif/tests/alloc-fns-B.vgtest index e7329a378a..2456604c6f 100644 --- a/massif/tests/alloc-fns-B.vgtest +++ b/massif/tests/alloc-fns-B.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/basic.vgtest b/massif/tests/basic.vgtest index 87c3a64444..0a3bc1054c 100644 --- a/massif/tests/basic.vgtest +++ b/massif/tests/basic.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/basic2.vgtest b/massif/tests/basic2.vgtest index 1dce7706f4..950b57e5b8 100644 --- a/massif/tests/basic2.vgtest +++ b/massif/tests/basic2.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/big-alloc.vgtest b/massif/tests/big-alloc.vgtest index 7f9149d912..b2520b997e 100644 --- a/massif/tests/big-alloc.vgtest +++ b/massif/tests/big-alloc.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/bug469146.vgtest b/massif/tests/bug469146.vgtest index 3bf1b60c10..2004bf2688 100644 --- a/massif/tests/bug469146.vgtest +++ b/massif/tests/bug469146.vgtest @@ -8,5 +8,7 @@ vgopts: --ignore-fn=filter_function1 --ignore-fn="filter_function2(int)" --ignor vgopts: --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn=map_images_nolock --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInser --ignore-fn=add_class_to_loadable_list --ignore-fn=NXHashInsert --ignore-fn=class_createInstance --ignore-fn=_xpc_malloc --ignore-fn=strdup --ignore-fn=_xpc_calloc # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | sed 's/gcc[0-9]*/gcc/' | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/culling1.stderr.exp b/massif/tests/culling1.stderr.exp index e277dc60ea..eaa4e72944 100644 --- a/massif/tests/culling1.stderr.exp +++ b/massif/tests/culling1.stderr.exp @@ -39,6 +39,11 @@ Massif: 15: xpc_array_create Massif: 16: _NXMapRehash(_NXMapTable*) Massif: 17: arc4_init Massif: 18: realizeClassWithoutSwift(objc_class*) +Massif: 19: _objc_init +Massif: 20: objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int) +Massif: 21: realizeClassWithoutSwift(objc_class*, objc_class*) +Massif: 22: schedule_class_load(objc_class*) +Massif: 23: objc::SafeRanges::add(unsigned long, unsigned long) Massif: startup S. 0 (t:0, hp:0, ex:0, st:0) Massif: alloc S. 1 (t:32, hp:16, ex:16, st:0) Massif: alloc S. 2 (t:64, hp:32, ex:32, st:0) diff --git a/massif/tests/culling1.vgtest b/massif/tests/culling1.vgtest index 5247e1b711..9dbfa6665a 100644 --- a/massif/tests/culling1.vgtest +++ b/massif/tests/culling1.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" stderr_filter: filter_verbose cleanup: rm massif.out diff --git a/massif/tests/culling2.stderr.exp b/massif/tests/culling2.stderr.exp index 599d0f0aa6..2d77d0461a 100644 --- a/massif/tests/culling2.stderr.exp +++ b/massif/tests/culling2.stderr.exp @@ -39,6 +39,11 @@ Massif: 15: xpc_array_create Massif: 16: _NXMapRehash(_NXMapTable*) Massif: 17: arc4_init Massif: 18: realizeClassWithoutSwift(objc_class*) +Massif: 19: _objc_init +Massif: 20: objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int) +Massif: 21: realizeClassWithoutSwift(objc_class*, objc_class*) +Massif: 22: schedule_class_load(objc_class*) +Massif: 23: objc::SafeRanges::add(unsigned long, unsigned long) Massif: startup S. 0 (t:0, hp:0, ex:0, st:0) Massif: alloc S. 1 (t:16, hp:0, ex:16, st:0) Massif: alloc S. 2 (t:432, hp:400, ex:32, st:0) diff --git a/massif/tests/culling2.vgtest b/massif/tests/culling2.vgtest index 847010e1ef..a5b4771a71 100644 --- a/massif/tests/culling2.vgtest +++ b/massif/tests/culling2.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" stderr_filter: filter_verbose cleanup: rm massif.out diff --git a/massif/tests/custom_alloc.vgtest b/massif/tests/custom_alloc.vgtest index c651534da5..6db7e483b1 100644 --- a/massif/tests/custom_alloc.vgtest +++ b/massif/tests/custom_alloc.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/deep-A.vgtest b/massif/tests/deep-A.vgtest index 77fc9d0e3d..cd80c108da 100644 --- a/massif/tests/deep-A.vgtest +++ b/massif/tests/deep-A.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/deep-B.stderr.exp b/massif/tests/deep-B.stderr.exp index 7f7c332b92..f3fd39d2ae 100644 --- a/massif/tests/deep-B.stderr.exp +++ b/massif/tests/deep-B.stderr.exp @@ -46,6 +46,11 @@ Massif: 15: xpc_array_create Massif: 16: _NXMapRehash(_NXMapTable*) Massif: 17: arc4_init Massif: 18: realizeClassWithoutSwift(objc_class*) +Massif: 19: _objc_init +Massif: 20: objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int) +Massif: 21: realizeClassWithoutSwift(objc_class*, objc_class*) +Massif: 22: schedule_class_load(objc_class*) +Massif: 23: objc::SafeRanges::add(unsigned long, unsigned long) Massif: startup S. 0 (t:0, hp:0, ex:0, st:0) Massif: alloc S. 1 (t:408, hp:400, ex:8, st:0) Massif: alloc S. 2 (t:816, hp:800, ex:16, st:0) diff --git a/massif/tests/deep-B.vgtest b/massif/tests/deep-B.vgtest index 0328353b37..ddbd32c341 100644 --- a/massif/tests/deep-B.vgtest +++ b/massif/tests/deep-B.vgtest @@ -6,5 +6,7 @@ vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=ma # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" stderr_filter: filter_verbose +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/deep-C.stderr.exp b/massif/tests/deep-C.stderr.exp index 39b35f139b..154c757c29 100644 --- a/massif/tests/deep-C.stderr.exp +++ b/massif/tests/deep-C.stderr.exp @@ -49,6 +49,11 @@ Massif: 15: xpc_array_create Massif: 16: _NXMapRehash(_NXMapTable*) Massif: 17: arc4_init Massif: 18: realizeClassWithoutSwift(objc_class*) +Massif: 19: _objc_init +Massif: 20: objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int) +Massif: 21: realizeClassWithoutSwift(objc_class*, objc_class*) +Massif: 22: schedule_class_load(objc_class*) +Massif: 23: objc::SafeRanges::add(unsigned long, unsigned long) Massif: startup S. 0 (t:0, hp:0, ex:0, st:0) Massif: alloc S. 1 (t:408, hp:400, ex:8, st:0) Massif: alloc S. 2 (t:816, hp:800, ex:16, st:0) diff --git a/massif/tests/deep-C.vgtest b/massif/tests/deep-C.vgtest index b21e5df8b1..ef8b558a11 100644 --- a/massif/tests/deep-C.vgtest +++ b/massif/tests/deep-C.vgtest @@ -5,6 +5,8 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" stderr_filter: filter_verbose post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/deep-D.vgtest b/massif/tests/deep-D.vgtest index 374f2afc29..d669fdf9a2 100644 --- a/massif/tests/deep-D.vgtest +++ b/massif/tests/deep-D.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ../../tests/filter_libc | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/filter_ignore_fn b/massif/tests/filter_ignore_fn index 2b524f08ba..3cbc224078 100755 --- a/massif/tests/filter_ignore_fn +++ b/massif/tests/filter_ignore_fn @@ -1,5 +1,9 @@ #! /bin/sh -awk '/Massif arguments/{gsub(/ unsigned int/, "uint")}{print}' | +awk '/Massif arguments/{gsub(/ ?unsigned int/, "uint")}{print}' | +awk '/Massif arguments/{gsub(/ ?unsigned long/, "ulong")}{print}' | +awk '/Massif arguments/{gsub(/char const/, "char_const")}{print}' | +awk '/Massif arguments/{gsub(/ objc/, "_objc")}{print}' | +awk '/Massif arguments/{gsub(/> >/, ">>")}{print}' | # unmangled C++ names can contain spaces so the above filter removes themn first awk '{gsub(/ --ignore-fn=[^ ]*/, ""); print}' diff --git a/massif/tests/ignored.vgtest b/massif/tests/ignored.vgtest index 7f9448156e..805a36eb43 100644 --- a/massif/tests/ignored.vgtest +++ b/massif/tests/ignored.vgtest @@ -6,5 +6,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/ignoring.vgtest b/massif/tests/ignoring.vgtest index 7181f3435a..c3d7a13658 100644 --- a/massif/tests/ignoring.vgtest +++ b/massif/tests/ignoring.vgtest @@ -5,5 +5,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/inlinfomalloc.vgtest b/massif/tests/inlinfomalloc.vgtest index 8f5c401e4d..8df84d2015 100644 --- a/massif/tests/inlinfomalloc.vgtest +++ b/massif/tests/inlinfomalloc.vgtest @@ -6,5 +6,7 @@ vgopts: --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClas # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" stderr_filter: filter_verbose +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignore-fn="schedule_class_load(objc_class*)" --ignore-fn="objc::SafeRanges::add(unsigned long, unsigned long)" post: perl ../../massif/ms_print --threshold=0 massif.out | ../../tests/filter_addresses | ./filter_ignore_fn cleanup: rm massif.out diff --git a/massif/tests/insig.vgtest b/massif/tests/insig.vgtest index a2994b5244..ba307adabc 100644 --- a/massif/tests/insig.vgtest +++ b/massif/tests/insig.vgtest @@ -6,5 +6,7 @@ vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-f vgopts: --alloc-fn=_xpc_malloc --ignore-fn=_xpc_dictionary_insert --ignore-fn=map_images_nolock --ignore-fn="allocBuckets(void*, unsigned int)" --ignore-fn="realizeClass(objc_class*)" --ignore-fn=_NXHashRehashToCapacity --ignore-fn=NXCreateHashTableFromZone --ignore-fn=NXCreateMapTableFromZone --ignore-fn=NXHashInsert --ignore-fn=add_class_to_loadable_list --ignore-fn=class_createInstance --ignore-fn=xpc_string_create --alloc-fn=strdup --alloc-fn=_xpc_calloc --ignore-fn=xpc_array_create # Darwin ignore functions, for macOS 10.14 vgopts: --ignore-fn="_NXMapRehash(_NXMapTable*)" --ignore-fn=arc4_init --ignore-fn="realizeClassWithoutSwift(objc_class*)" +# Darwin ignore functions, for macOS 10.15 +vgopts: --ignore-fn=_objc_init --ignore-fn-"objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="objc::DenseMap<char const*, objc::detail::DenseSetEmpty, objc::DenseMapValueInfo<objc::detail::DenseSetEmpty>, objc::DenseMapInfo<char const*>, objc::detail::DenseSetPair<char const*> >::grow(unsigned int)" --ignore-fn="realizeClassWithoutSwift(objc_class*, objc_class*)" --ignor... [truncated message content] |
|
From: Mark W. <ma...@kl...> - 2025-12-17 13:52:15
|
Hi, On Mon, Dec 15, 2025 at 08:51:52PM +0000, Sertonix wrote: > On Mon Dec 15, 2025 at 9:37 PM CET, Paul Floyd via Valgrind-developers wrote: > > Can you tell us a bit more about this patch? > > While porting some software to ppc I used valgrind a lot and after some > time patched valgrind to be able to handle some syscalls which were > missing for seemingly no reason. > > > Why is it needed, does it need any regression tests? > > Without this valgrind complains about some unknown syscalls and is not > able to properly analyze these on linux ppc32. I don't think it needs > tests and I don't think I would be able add tests since the test suite > is broken on musl libc (which I use). It is unfortunate we don't have a dedicated ppc32 tester. But I agree these look fine. The exact same syscalls are wrapped the exact same way on ppc64. They were probably just forgotten for ppc32. Applied, Mark |
|
From: Mark W. <ma...@so...> - 2025-12-17 13:52:12
|
https://sourceware.org/cgit/valgrind/commit/?id=d45b016046fd6af55e23891f9392e2b8c1193372 commit d45b016046fd6af55e23891f9392e2b8c1193372 Author: Sertonix <ser...@po...> Date: Mon Dec 15 18:29:40 2025 +0000 Linux ppc32: map a few more syscalls Diff: --- coregrind/m_syswrap/syswrap-ppc32-linux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 03773ebc99..16bae5d08f 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -864,7 +864,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_madvise, sys_madvise), // 205 GENXY(__NR_mincore, sys_mincore), // 206 LINX_(__NR_gettid, sys_gettid), // 207 -//.. LINX_(__NR_tkill, sys_tkill), // 208 */Linux + LINX_(__NR_tkill, sys_tkill), // 208 */Linux LINX_(__NR_setxattr, sys_setxattr), // 209 LINX_(__NR_lsetxattr, sys_lsetxattr), // 210 LINX_(__NR_fsetxattr, sys_fsetxattr), // 211 @@ -954,6 +954,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_pselect6, sys_pselect6), // 280 LINXY(__NR_ppoll, sys_ppoll), // 281 + LINX_(__NR_splice, sys_splice), // 283 + LINXY(__NR_openat, sys_openat), // 286 LINX_(__NR_mkdirat, sys_mkdirat), // 287 LINX_(__NR_mknodat, sys_mknodat), // 288 @@ -992,6 +994,7 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_pwritev, sys_pwritev), // 321 LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),// 322 + LINXY(__NR_prlimit64, sys_prlimit64), // 325 LINXY(__NR_socket, sys_socket), // 326 LINX_(__NR_bind, sys_bind), // 327 LINX_(__NR_connect, sys_connect), // 328 @@ -1027,6 +1030,8 @@ static SyscallTableEntry syscall_table[] = { LINX_ (__NR_execveat, sys_execveat), // 362 LINXY(__NR_userfaultfd, sys_userfaultfd), // 364 + LINX_(__NR_membarrier, sys_membarrier), // 365 + GENX_(__NR_mlock2, sys_mlock2), // 378 LINX_(__NR_copy_file_range, sys_copy_file_range), // 379 LINX_(__NR_preadv2, sys_preadv2), // 380 |
|
From: Martin C. <mc...@so...> - 2025-12-16 10:29:33
|
https://sourceware.org/cgit/valgrind/commit/?id=ce7a2995b3194b4ad38a6f7f413988e259d98a24 commit ce7a2995b3194b4ad38a6f7f413988e259d98a24 Author: Martin Cermak <mc...@re...> Date: Tue Dec 16 09:52:29 2025 +0100 Wrap new lsm_list_modules syscall The lsm_list_modules syscall returns a list of the active LSM ids. On success this function returns the number of @ids array elements. This value may be zero if there are no LSMs active. If @size is insufficient to contain the return data -E2BIG is returned and @size is set to the minimum required size. In all other cases a negative value indicating the error is returned. SYSCALL_DEFINE3(lsm_list_modules, u64 __user *, ids, u32 __user *, size, u32, flags) Declare lsm_list_modules wrappers in priv_syswrap-linux.h and hook it for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux. https://bugs.kde.org/show_bug.cgi?id=513257 Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-linux.h | 1 + coregrind/m_syswrap/syswrap-amd64-linux.c | 1 + coregrind/m_syswrap/syswrap-arm-linux.c | 1 + coregrind/m_syswrap/syswrap-arm64-linux.c | 1 + coregrind/m_syswrap/syswrap-linux.c | 22 ++++++++++++++++++++++ coregrind/m_syswrap/syswrap-mips32-linux.c | 1 + coregrind/m_syswrap/syswrap-mips64-linux.c | 5 +++-- coregrind/m_syswrap/syswrap-nanomips-linux.c | 5 +++-- coregrind/m_syswrap/syswrap-ppc32-linux.c | 5 +++-- coregrind/m_syswrap/syswrap-ppc64-linux.c | 5 +++-- coregrind/m_syswrap/syswrap-riscv64-linux.c | 1 + coregrind/m_syswrap/syswrap-s390x-linux.c | 5 +++-- coregrind/m_syswrap/syswrap-x86-linux.c | 1 + include/vki/vki-scnums-shared-linux.h | 1 + 15 files changed, 46 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 51ba3e940a..53768ece3f 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 512030 s390x: bfp-convert testcase fails 512037 malloc trace does not print free size or alignment 512571 regtest problems with darwin dsymuti +513257 Add missing syswraps for lsm_list_modules To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index b02701d27b..f4d3f8a7a5 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -374,6 +374,7 @@ DECL_TEMPLATE(linux, sys_statmount); DECL_TEMPLATE(linux, sys_mseal); DECL_TEMPLATE(linux, sys_lsm_get_self_attr); DECL_TEMPLATE(linux, sys_lsm_set_self_attr); +DECL_TEMPLATE(linux, sys_lsm_list_modules); // Since Linux 6.17-rc1 DECL_TEMPLATE(linux, sys_file_getattr); diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 0a05d7cb51..ab24a2e8f7 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -911,6 +911,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_listmount, sys_listmount), // 458 LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY(__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_(__NR_mseal, sys_mseal), // 462 LINXY(__NR_file_getattr, sys_file_getattr), // 468 LINX_(__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c index e923bee9c9..73e5ef1a72 100644 --- a/coregrind/m_syswrap/syswrap-arm-linux.c +++ b/coregrind/m_syswrap/syswrap-arm-linux.c @@ -1081,6 +1081,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_listmount, sys_listmount), // 458 LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY(__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_(__NR_mseal, sys_mseal), // 462 LINXY(__NR_file_getattr, sys_file_getattr), // 468 LINX_(__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c index 9b6e05dbc9..71d16739c0 100644 --- a/coregrind/m_syswrap/syswrap-arm64-linux.c +++ b/coregrind/m_syswrap/syswrap-arm64-linux.c @@ -862,6 +862,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_listmount, sys_listmount), // 458 LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY(__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_(__NR_mseal, sys_mseal), // 462 LINXY(__NR_file_getattr, sys_file_getattr), // 468 LINX_(__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 7186cf0c48..10e63348d9 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -4676,6 +4676,28 @@ PRE(sys_lsm_set_self_attr) PRE_MEM_READ("lsm_get_self_attr(ctx)", ARG2, ARG3); } +PRE(sys_lsm_list_modules) +{ + // * sys_lsm_list_modules - Return a list of the active security modules + // * @ids: the LSM module ids + // * @size: pointer to size of @ids, updated on return + // * @flags: reserved for future use, must be zero + // SYSCALL_DEFINE3(lsm_list_modules, u64 __user *, ids, u32 __user *, size, + // u32, flags) + PRINT("sys_lsm_list_modules ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x)", ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "lsm_list_modules", __vki_u64 *, ids, __vki_u32 *, size, __vki_u32, flags); + PRE_MEM_READ("lsm_list_modules(size)", ARG2, sizeof(__vki_u32)); + if (ML_(safe_to_deref)((__vki_u32 *)ARG2,sizeof(__vki_u32))) + PRE_MEM_READ("lsm_list_modules(ids)", ARG1, *(__vki_u32 *)ARG2); +} + +POST(sys_lsm_list_modules) +{ + // No need to POST_MEM_WRITE((Addr)ARG2, sizeof(__vki_u32)); + // per https://bugs.kde.org/show_bug.cgi?id=513257#c4 + POST_MEM_WRITE(ARG1, *(__vki_u32 *)ARG2); +} + PRE(sys_syncfs) { *flags |= SfMayBlock; diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index 43c9b861d9..3854c28712 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -1190,6 +1190,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_listmount, sys_listmount), // 458 LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY(__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_(__NR_mseal, sys_mseal), // 462 LINXY(__NR_file_getattr, sys_file_getattr), // 468 LINX_(__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c index d78e59842b..71adfcc680 100644 --- a/coregrind/m_syswrap/syswrap-mips64-linux.c +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c @@ -797,8 +797,9 @@ static SyscallTableEntry syscall_main_table[] = { LINXY (__NR_userfaultfd, sys_userfaultfd), LINXY (__NR_statmount, sys_statmount), LINXY (__NR_listmount, sys_listmount), - LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), - LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), + LINXY (__NR_lsm_get_self_attr, sys_lsm_get_self_attr), + LINX_ (__NR_lsm_set_self_attr, sys_lsm_set_self_attr), + LINXY (__NR_lsm_list_modules, sys_lsm_list_modules), LINX_ (__NR_mseal, sys_mseal), LINX_ (__NR_futex_waitv, sys_futex_waitv), LINXY (__NR_quotactl_fd, sys_quotactl_fd), diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c index e5c6425722..1a2de91585 100644 --- a/coregrind/m_syswrap/syswrap-nanomips-linux.c +++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c @@ -823,8 +823,9 @@ static SyscallTableEntry syscall_main_table[] = { LINX_ (__NR_fchmodat2, sys_fchmodat2), LINXY (__NR_statmount, sys_statmount), LINXY (__NR_listmount, sys_listmount), - LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), - LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), + LINXY (__NR_lsm_get_self_attr, sys_lsm_get_self_attr), + LINX_ (__NR_lsm_set_self_attr, sys_lsm_set_self_attr), + LINXY (__NR_lsm_list_modules, sys_lsm_list_modules), LINX_ (__NR_mseal, sys_mseal), LINX_ (__NR_futex_waitv, sys_futex_waitv), LINXY (__NR_file_getattr, sys_file_getattr), diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 82b67afe34..03773ebc99 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1087,8 +1087,9 @@ static SyscallTableEntry syscall_table[] = { LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 LINXY (__NR_statmount, sys_statmount), // 457 LINXY (__NR_listmount, sys_listmount), // 458 - LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 - LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY (__NR_lsm_get_self_attr,sys_lsm_get_self_attr), // 459 + LINX_ (__NR_lsm_set_self_attr,sys_lsm_set_self_attr), // 460 + LINXY (__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_ (__NR_mseal, sys_mseal), // 462 LINXY (__NR_file_getattr, sys_file_getattr), // 468 LINX_ (__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 445ee30f39..56fe34aa50 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1065,8 +1065,9 @@ static SyscallTableEntry syscall_table[] = { LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 LINXY (__NR_statmount, sys_statmount), // 457 LINXY (__NR_listmount, sys_listmount), // 458 - LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 - LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY (__NR_lsm_get_self_attr,sys_lsm_get_self_attr), // 459 + LINX_ (__NR_lsm_set_self_attr,sys_lsm_set_self_attr), // 460 + LINXY (__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_ (__NR_mseal, sys_mseal), // 462 LINXY (__NR_file_getattr, sys_file_getattr), // 468 LINX_ (__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-riscv64-linux.c b/coregrind/m_syswrap/syswrap-riscv64-linux.c index 92e2794854..a495d09d09 100644 --- a/coregrind/m_syswrap/syswrap-riscv64-linux.c +++ b/coregrind/m_syswrap/syswrap-riscv64-linux.c @@ -610,6 +610,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_listmount, sys_listmount), /* 458 */ LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), /* 459 */ LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), /* 460 */ + LINXY(__NR_lsm_list_modules, sys_lsm_list_modules), /* 461 */ LINX_(__NR_mseal, sys_mseal), /* 462 */ LINXY(__NR_file_getattr, sys_file_getattr), /* 468 */ LINX_(__NR_file_setattr, sys_file_setattr), /* 469 */ diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c index 0b5d436b05..dc8b0d9e7c 100644 --- a/coregrind/m_syswrap/syswrap-s390x-linux.c +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c @@ -900,8 +900,9 @@ static SyscallTableEntry syscall_table[] = { LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 LINXY (__NR_statmount, sys_statmount), // 457 LINXY (__NR_listmount, sys_listmount), // 458 - LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 - LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY (__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 + LINX_ (__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY (__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_ (__NR_mseal, sys_mseal), // 462 LINXY (__NR_file_getattr, sys_file_getattr), // 468 LINX_ (__NR_file_setattr, sys_file_setattr), // 469 diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 1165304da3..922585a87a 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1692,6 +1692,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_listmount, sys_listmount), // 458 LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459 LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460 + LINXY(__NR_lsm_list_modules, sys_lsm_list_modules), // 461 LINX_(__NR_mseal, sys_mseal), // 462 LINXY(__NR_file_getattr, sys_file_getattr), // 468 LINX_(__NR_file_setattr, sys_file_setattr), // 469 diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h index 231372af43..f022c1ff3e 100644 --- a/include/vki/vki-scnums-shared-linux.h +++ b/include/vki/vki-scnums-shared-linux.h @@ -62,6 +62,7 @@ #define __NR_listmount 458 #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 +#define __NR_lsm_list_modules 461 #define __NR_mseal 462 #define __NR_file_getattr 468 #define __NR_file_setattr 469 |
|
From: Florian K. <fk...@so...> - 2025-12-15 22:39:10
|
https://sourceware.org/cgit/valgrind/commit/?id=8d6a233295bde8d47da97a010dfe2af3f93bd3cf commit 8d6a233295bde8d47da97a010dfe2af3f93bd3cf Author: Florian Krohm <fl...@ei...> Date: Mon Dec 15 22:38:37 2025 +0000 s390: Clarify a variable name. Diff: --- VEX/priv/host_s390_defs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index fe37e9d1c6..3205060b59 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -10881,7 +10881,7 @@ s390_insn_vec_replicate_emit(UChar *buf, const s390_insn *insn) Int emit_S390Instr(Bool *is_profinc, UChar *buf, Int nbuf, const s390_insn *insn, - Bool mode64, const VexArchInfo *archinfo, + Bool mode64, const VexArchInfo *archinfo_host, const void *disp_cp_chain_me_to_slowEP, const void *disp_cp_chain_me_to_fastEP, const void *disp_cp_xindir, |
|
From: Sertonix <ser...@po...> - 2025-12-15 20:52:00
|
On Mon Dec 15, 2025 at 9:37 PM CET, Paul Floyd via Valgrind-developers wrote:
> On 2025-12-15 19:29, Sertonix wrote:
>> ---
>> coregrind/m_syswrap/syswrap-ppc32-linux.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
>> index 82b67af..217b4c9 100644
>> --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
>> +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
>> @@ -864,7 +864,7 @@ static SyscallTableEntry syscall_table[] = {
>> GENX_(__NR_madvise, sys_madvise), // 205
>> GENXY(__NR_mincore, sys_mincore), // 206
>> LINX_(__NR_gettid, sys_gettid), // 207
>
> ...
>
> Hi
>
> Can you tell us a bit more about this patch?
While porting some software to ppc I used valgrind a lot and after some
time patched valgrind to be able to handle some syscalls which were
missing for seemingly no reason.
> Why is it needed, does it need any regression tests?
Without this valgrind complains about some unknown syscalls and is not
able to properly analyze these on linux ppc32. I don't think it needs
tests and I don't think I would be able add tests since the test suite
is broken on musl libc (which I use).
> Regards
>
> Paul
>
>
>
>
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
|
|
From: Paul F. <pj...@wa...> - 2025-12-15 20:38:12
|
On 2025-12-15 19:29, Sertonix wrote:
> ---
> coregrind/m_syswrap/syswrap-ppc32-linux.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
> index 82b67af..217b4c9 100644
> --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
> +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
> @@ -864,7 +864,7 @@ static SyscallTableEntry syscall_table[] = {
> GENX_(__NR_madvise, sys_madvise), // 205
> GENXY(__NR_mincore, sys_mincore), // 206
> LINX_(__NR_gettid, sys_gettid), // 207
...
Hi
Can you tell us a bit more about this patch? Why is it needed, does it
need any regression tests?
Regards
Paul
|
|
From: Sertonix <ser...@po...> - 2025-12-15 18:29:48
|
---
coregrind/m_syswrap/syswrap-ppc32-linux.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
index 82b67af..217b4c9 100644
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
@@ -864,7 +864,7 @@ static SyscallTableEntry syscall_table[] = {
GENX_(__NR_madvise, sys_madvise), // 205
GENXY(__NR_mincore, sys_mincore), // 206
LINX_(__NR_gettid, sys_gettid), // 207
-//.. LINX_(__NR_tkill, sys_tkill), // 208 */Linux
+ LINX_(__NR_tkill, sys_tkill), // 208 */Linux
LINX_(__NR_setxattr, sys_setxattr), // 209
LINX_(__NR_lsetxattr, sys_lsetxattr), // 210
LINX_(__NR_fsetxattr, sys_fsetxattr), // 211
@@ -954,6 +954,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_pselect6, sys_pselect6), // 280
LINXY(__NR_ppoll, sys_ppoll), // 281
+ LINX_(__NR_splice, sys_splice), // 283
+
LINXY(__NR_openat, sys_openat), // 286
LINX_(__NR_mkdirat, sys_mkdirat), // 287
LINX_(__NR_mknodat, sys_mknodat), // 288
@@ -992,6 +994,7 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_pwritev, sys_pwritev), // 321
LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),// 322
+ LINXY(__NR_prlimit64, sys_prlimit64), // 325
LINXY(__NR_socket, sys_socket), // 326
LINX_(__NR_bind, sys_bind), // 327
LINX_(__NR_connect, sys_connect), // 328
@@ -1027,6 +1030,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_ (__NR_execveat, sys_execveat), // 362
LINXY(__NR_userfaultfd, sys_userfaultfd), // 364
+ LINX_(__NR_membarrier, sys_membarrier), // 365
+
GENX_(__NR_mlock2, sys_mlock2), // 378
LINX_(__NR_copy_file_range, sys_copy_file_range), // 379
LINX_(__NR_preadv2, sys_preadv2), // 380
--
2.52.0
|
|
From: Florian K. <fk...@so...> - 2025-12-15 10:25:31
|
https://sourceware.org/cgit/valgrind/commit/?id=e40b4d78b841d61b852d64e4695d15c50ccbf147 commit e40b4d78b841d61b852d64e4695d15c50ccbf147 Author: Florian Krohm <fl...@ei...> Date: Mon Dec 15 10:24:49 2025 +0000 Testcase tweak: clenup after yourself Diff: --- .gitignore | 1 - memcheck/tests/mmaptest.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 58b81fa46c..7bdac9edfe 100644 --- a/.gitignore +++ b/.gitignore @@ -898,7 +898,6 @@ /memcheck/tests/demangle-rust /memcheck/tests/describe-block /memcheck/tests/descr_belowsp -/memcheck/tests/dir /memcheck/tests/doublefree /memcheck/tests/duplicate_align_size_errors /memcheck/tests/dw4 diff --git a/memcheck/tests/mmaptest.c b/memcheck/tests/mmaptest.c index fac1f655ca..1840420761 100644 --- a/memcheck/tests/mmaptest.c +++ b/memcheck/tests/mmaptest.c @@ -4,12 +4,13 @@ #include <unistd.h> #include "tests/sys_mman.h" -int main() +int main(void) { int fd; mkdir("dir", 0777); fd = open("dir", O_RDONLY); mmap(NULL, 4711, PROT_READ, MAP_PRIVATE, fd, 0); + rmdir("dir"); return 0; } |
|
From: Paul F. <pa...@so...> - 2025-12-14 19:25:44
|
https://sourceware.org/cgit/valgrind/commit/?id=b13afacd68bf667b50f52bfc5d0a010dc6f71e5a commit b13afacd68bf667b50f52bfc5d0a010dc6f71e5a Author: Paul Floyd <pj...@wa...> Date: Sun Dec 14 20:23:10 2025 +0100 Darwin DRD: redirs for semaphore functions Like 2802b31ae644301ee641dcae20d1f84373615d54 for Helgrind. Use the DRD script supported_sem_init in Helgrind tests that use semaphores, it's clearer than just using tests/os_test Diff: --- drd/drd_pthread_intercepts.c | 23 +++++++++++++++-------- helgrind/hg_intercepts.c | 3 +++ helgrind/tests/tc18_semabuse.vgtest | 1 + helgrind/tests/tc24_nonzero_sem.vgtest | 1 + 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index 0cd7c0be62..6e150ca4e9 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -202,6 +202,13 @@ ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBPTHREAD_SONAME,zf) argl_decl \ { return implf argl; } #endif +#if defined(VGO_darwin) +#define LIBC_FUNC(ret_ty, zf, implf, argl_decl, argl) \ + ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBSYSTEM_KERNEL_SONAME,zf) argl_decl; \ + ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBSYSTEM_KERNEL_SONAME,zf) argl_decl \ + { return implf argl; } +#endif + /** * Macro for generating three Valgrind interception functions: one with the * Z-encoded name zf, one with ZAZa ("@*") appended to the name zf and one @@ -1491,7 +1498,7 @@ int sem_init_intercept(sem_t *sem, int pshared, unsigned int value) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZuinit, sem_init_intercept, (sem_t *sem, int pshared, unsigned int value), (sem, pshared, value)); #else @@ -1534,7 +1541,7 @@ int sem_destroy_intercept(sem_t *sem) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); #else PTH_FUNCS(int, semZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); @@ -1570,7 +1577,7 @@ sem_t* sem_open_intercept(const char *name, int oflag, mode_t mode, return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(sem_t *, semZuopen, sem_open_intercept, (const char *name, int oflag, mode_t mode, unsigned int value), (name, oflag, mode, value)); @@ -1593,7 +1600,7 @@ static __always_inline int sem_close_intercept(sem_t *sem) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZuclose, sem_close_intercept, (sem_t *sem), (sem)); #else PTH_FUNCS(int, semZuclose, sem_close_intercept, (sem_t *sem), (sem)); @@ -1612,7 +1619,7 @@ static __always_inline int sem_wait_intercept(sem_t *sem) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZuwait, sem_wait_intercept, (sem_t *sem), (sem)); #else PTH_FUNCS(int, semZuwait, sem_wait_intercept, (sem_t *sem), (sem)); @@ -1635,7 +1642,7 @@ static __always_inline int sem_trywait_intercept(sem_t *sem) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); #else PTH_FUNCS(int, semZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); @@ -1658,7 +1665,7 @@ int sem_timedwait_intercept(sem_t *sem, const struct timespec *abs_timeout) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZutimedwait, sem_timedwait_intercept, (sem_t *sem, const struct timespec *abs_timeout), (sem, abs_timeout)); @@ -1711,7 +1718,7 @@ static __always_inline int sem_post_intercept(sem_t *sem) return ret; } -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, semZupost, sem_post_intercept, (sem_t *sem), (sem)); #else PTH_FUNCS(int, semZupost, sem_post_intercept, (sem_t *sem), (sem)); diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 09e3bea179..aa48ce02ac 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -3118,6 +3118,7 @@ static int sem_init_WRK(sem_t* sem, int pshared, unsigned long value) return sem_init_WRK(sem, pshared, value); } #elif defined(VGO_darwin) +// exists but fails with ENOSYS function not implemented LIBC_FUNC(int, semZuinit, // sem_init sem_t* sem, int pshared, unsigned long value) { return sem_init_WRK(sem, pshared, value); @@ -3206,6 +3207,7 @@ static int sem_destroy_WRK(sem_t* sem) return sem_destroy_WRK(sem); } #elif defined(VGO_darwin) +// exists but fails with ENOSYS function not implemented LIBC_FUNC(int, semZudestroy, // sem_destroy sem_t* sem) { return sem_destroy_WRK(sem); @@ -3274,6 +3276,7 @@ static int sem_wait_WRK(sem_t* sem) return sem_wait_WRK(sem); } #elif defined(VGO_darwin) +// exists but fails with EBADF bad file number LIBC_FUNC(int, semZuwait, sem_t* sem) { /* sem_wait */ return sem_wait_WRK(sem); } diff --git a/helgrind/tests/tc18_semabuse.vgtest b/helgrind/tests/tc18_semabuse.vgtest index fe4d22ba17..4818d739d4 100644 --- a/helgrind/tests/tc18_semabuse.vgtest +++ b/helgrind/tests/tc18_semabuse.vgtest @@ -1 +1,2 @@ +prereq: ../../drd/tests/supported_sem_init prog: tc18_semabuse diff --git a/helgrind/tests/tc24_nonzero_sem.vgtest b/helgrind/tests/tc24_nonzero_sem.vgtest index 1a43121eb7..87f4b8bfd1 100644 --- a/helgrind/tests/tc24_nonzero_sem.vgtest +++ b/helgrind/tests/tc24_nonzero_sem.vgtest @@ -1,2 +1,3 @@ +prereq: ../../drd/tests/supported_sem_init prog: tc24_nonzero_sem vgopts: --hg-sanity-flags=111111 |
|
From: Florian K. <fk...@so...> - 2025-12-14 18:28:43
|
https://sourceware.org/cgit/valgrind/commit/?id=ab89bdcfbd139ba59d0e194f6c56650e3c3f64b2 commit ab89bdcfbd139ba59d0e194f6c56650e3c3f64b2 Author: Florian Krohm <fl...@ei...> Date: Sun Dec 14 17:26:24 2025 +0000 s390: Fix build failure Followup to 778fe51a69eb099bc6cbfa616986310560a8b828. Diff: --- none/tests/s390x/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am index 8a828463a0..1f830d6f36 100644 --- a/none/tests/s390x/Makefile.am +++ b/none/tests/s390x/Makefile.am @@ -30,6 +30,8 @@ endif check_PROGRAMS = $(INSN_TESTS) \ allexec \ + cksm \ + flogr \ op00 noinst_HEADERS = add.h and.h div.h dfp_utils.h insert.h mul.h opcodes.h \ |
|
From: Paul F. <pa...@so...> - 2025-12-14 17:30:14
|
https://sourceware.org/cgit/valgrind/commit/?id=2802b31ae644301ee641dcae20d1f84373615d54 commit 2802b31ae644301ee641dcae20d1f84373615d54 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 14 18:21:19 2025 +0100 Darwin helgrind: redirs for semaphore functions The semaphore functions are not in the pthread library (similar to FreeBSD). Change the redirs to use libsystem_kernel.dylib Unfortunately this doesn't help much. Darwin has deprecated these functions so the tests will compile (with a warning) but at runtime they all fail with errors like ENOSYS and EBADF. Diff: --- helgrind/hg_intercepts.c | 22 ++++++++++++++-------- helgrind/tests/tc17_sembar.c | 4 ++++ helgrind/tests/tc24_nonzero_sem.c | 6 +++++- include/pub_tool_redir.h | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 4bef0ab959..09e3bea179 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -119,6 +119,12 @@ #include <osreldate.h> #endif +#if defined(VGO_darwin) +#define LIBC_FUNC(ret_ty, f, args...) \ + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBSYSTEM_KERNEL_SONAME,f)(args); \ + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBSYSTEM_KERNEL_SONAME,f)(args) +#endif + // Do a client request. These are macros rather than a functions so // as to avoid having an extra frame in stack traces. @@ -3112,7 +3118,7 @@ static int sem_init_WRK(sem_t* sem, int pshared, unsigned long value) return sem_init_WRK(sem, pshared, value); } #elif defined(VGO_darwin) - PTH_FUNC(int, semZuinit, // sem_init + LIBC_FUNC(int, semZuinit, // sem_init sem_t* sem, int pshared, unsigned long value) { return sem_init_WRK(sem, pshared, value); } @@ -3200,7 +3206,7 @@ static int sem_destroy_WRK(sem_t* sem) return sem_destroy_WRK(sem); } #elif defined(VGO_darwin) - PTH_FUNC(int, semZudestroy, // sem_destroy + LIBC_FUNC(int, semZudestroy, // sem_destroy sem_t* sem) { return sem_destroy_WRK(sem); } @@ -3268,10 +3274,10 @@ static int sem_wait_WRK(sem_t* sem) return sem_wait_WRK(sem); } #elif defined(VGO_darwin) - PTH_FUNC(int, semZuwait, sem_t* sem) { /* sem_wait */ + LIBC_FUNC(int, semZuwait, sem_t* sem) { /* sem_wait */ return sem_wait_WRK(sem); } - PTH_FUNC(int, semZuwaitZDZa, sem_t* sem) { /* sem_wait$* */ + LIBC_FUNC(int, semZuwaitZDZa, sem_t* sem) { /* sem_wait$* */ return sem_wait_WRK(sem); } #elif defined(VGO_freebsd) @@ -3334,7 +3340,7 @@ PTH_FUNC(int, semZutrywaitZAZa, sem_t* sem) { /* sem_trywait@* */ return sem_trywait_WRK(sem); } #elif defined(VGO_darwin) -PTH_FUNC(int, semZutrywait, sem_t* sem) { /* sem_trywait */ +LIBC_FUNC(int, semZutrywait, sem_t* sem) { /* sem_trywait */ return sem_trywait_WRK(sem); } #elif defined(VGO_freebsd) @@ -3511,7 +3517,7 @@ static int sem_post_WRK(sem_t* sem) return sem_post_WRK(sem); } #elif defined(VGO_darwin) - PTH_FUNC(int, semZupost, sem_t* sem) { /* sem_post */ + LIBC_FUNC(int, semZupost, sem_t* sem) { /* sem_post */ return sem_post_WRK(sem); } #elif defined(VGO_freebsd) @@ -3533,7 +3539,7 @@ static int sem_post_WRK(sem_t* sem) // Solaris: sem_open // FreeBSD: sem_open // -#if defined(VGO_freebsd) +#if defined(VGO_freebsd) || defined(VGO_DARWIN) LIBC_FUNC(sem_t*, semZuopen, const char* name, long oflag, long mode, unsigned long value) @@ -3578,7 +3584,7 @@ PTH_FUNC(sem_t*, semZuopen, // darwin: sem_close // Solaris: sem_close // FreeBSD: sem_close -#if defined (VGO_freebsd) +#if defined (VGO_freebsd) || defined(VGO_darwin) LIBC_FUNC(int, sem_close, sem_t* sem) #else PTH_FUNC(int, sem_close, sem_t* sem) diff --git a/helgrind/tests/tc17_sembar.c b/helgrind/tests/tc17_sembar.c index ee40160b08..9f8d3fa8c0 100644 --- a/helgrind/tests/tc17_sembar.c +++ b/helgrind/tests/tc17_sembar.c @@ -253,7 +253,11 @@ static sem_t* my_sem_init (char* identity, int pshared, unsigned count) static int my_sem_destroy ( sem_t* s ) { +#if defined(VGO_darwin) +return 0; +#else return sem_destroy(s); +#endif } static int my_sem_wait(sem_t* s) diff --git a/helgrind/tests/tc24_nonzero_sem.c b/helgrind/tests/tc24_nonzero_sem.c index 2fe4081913..9b08adee45 100644 --- a/helgrind/tests/tc24_nonzero_sem.c +++ b/helgrind/tests/tc24_nonzero_sem.c @@ -45,7 +45,11 @@ int main ( void ) } r= my_sem_destroy(sem); -#if !defined(VGO_darwin) +#if defined(VGO_darwin) + // This outputs "function not implemented" if uncommented + //if (r != 0) + // perror("sem_destroy"); +#else assert(!r); #endif return 0; diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h index f2d7681087..e2cbac44fb 100644 --- a/include/pub_tool_redir.h +++ b/include/pub_tool_redir.h @@ -267,6 +267,7 @@ /* Not tested on systems older than OSX 10.13 */ #define VG_Z_LIBSYSTEM_C_SONAME libsystemZucZddylib #define VG_Z_LIBSYSTEM_PLATFORM_SONAME libsystemZuplatformZddylib +#define VG_Z_LIBSYSTEM_KERNEL_SONAME libsystemZukernelZddylib #else # error "Unknown platform" |
|
From: Paul F. <pa...@so...> - 2025-12-14 12:46:54
|
https://sourceware.org/cgit/valgrind/commit/?id=6878e3f78fe16aa0e758a5eb4483a9c4834e7cb3 commit 6878e3f78fe16aa0e758a5eb4483a9c4834e7cb3 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 14 13:31:18 2025 +0100 Darwin fdleaks: fix handling of recvmsg cmsg In the Darwin headers the macro __DARWIN_ALIGN32 is used for the CMSG macros. We were using just ALIGN which looks like it uses __DARWIN_ALIGN for 8 byte alignment. Using the wrong alignment gate a wrong count of fds and check_cmsg_for_fds was only calling ML_(record_fd_open_named) for one fd. The result was fd errors when writing to a second fd that should have been recorded. Diff: --- include/vki/vki-darwin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h index 056bd9e890..5e381ab4c6 100644 --- a/include/vki/vki-darwin.h +++ b/include/vki/vki-darwin.h @@ -296,7 +296,7 @@ typedef uint32_t vki_u32; #define vki_cmsghdr cmsghdr -#define VKI_CMSG_ALIGN(a) ALIGN(a) +#define VKI_CMSG_ALIGN(a) __DARWIN_ALIGN32(a) #define VKI_CMSG_DATA(cmsg) CMSG_DATA(cmsg) #define VKI_CMSG_FIRSTHDR(mhdr) CMSG_FIRSTHDR(mhdr) #define VKI_CMSG_NXTHDR(mhdr, cmsg) CMSG_NXTHDR(mhdr, cmsg) |
|
From: Paul F. <pa...@so...> - 2025-12-14 09:08:14
|
https://sourceware.org/cgit/valgrind/commit/?id=a28682dc7c6de34428eb680e4d04d887f2d45412 commit a28682dc7c6de34428eb680e4d04d887f2d45412 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 14 10:05:04 2025 +0100 Darwin regtest: update none ioctl_moans This testcase needs IOCTL_REQUEST_BASE to be set to some bogus value with the platform dependent "no direction" flag set. That flag wasn't being set for Darwin and so the testcase was failing. Diff: --- none/tests/ioctl_moans.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/none/tests/ioctl_moans.c b/none/tests/ioctl_moans.c index d350758342..efb7582341 100644 --- a/none/tests/ioctl_moans.c +++ b/none/tests/ioctl_moans.c @@ -13,6 +13,8 @@ #define IOCTL_REQUEST_BASE (0x12345670 | _IOC(_IOC_NONE,0,0,0)) # elif defined(VGO_freebsd) #define IOCTL_REQUEST_BASE (0x12345670 | _IO(0,0)) +# elif defined(VGO_darwin) +#define IOCTL_REQUEST_BASE (0x12345670 | _IOC(IOC_VOID,0,0,0)) # else #define IOCTL_REQUEST_BASE 0x12345670 # endif |
|
From: Florian K. <fk...@so...> - 2025-12-13 22:13:04
|
https://sourceware.org/cgit/valgrind/commit/?id=0282c1cfc9015b69d097ac1cddff4fb264755e66 commit 0282c1cfc9015b69d097ac1cddff4fb264755e66 Author: Florian Krohm <fl...@ei...> Date: Sat Dec 13 22:12:23 2025 +0000 s390: Tweak a few helper functions. Diff: --- VEX/priv/host_s390_defs.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index 3479bbc91b..fe37e9d1c6 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -5011,43 +5011,28 @@ s390_emit_RISBG(UChar *p, UChar r1, UChar r2, UChar i3, Char i4, UChar i5) static __inline__ Bool uint_fits_signed_16bit(UInt val) { - UInt v = val & 0xFFFFu; - - /* sign extend */ - v = (Int)(v << 16) >> 16; - - return val == v; + return val <= 0x7FFFu; } static __inline__ Bool ulong_fits_signed_16bit(ULong val) { - ULong v = val & 0xFFFFu; - - /* sign extend */ - v = (Long)(v << 48) >> 48; - - return val == v; + return val <= 0x7FFFu; } static __inline__ Bool ulong_fits_signed_32bit(ULong val) { - ULong v = val & 0xFFFFFFFFu; - - /* sign extend */ - v = (Long)(v << 32) >> 32; - - return val == v; + return val <= 0x7FFFFFFFu; } static __inline__ Bool ulong_fits_unsigned_32bit(ULong val) { - return (val & 0xFFFFFFFFu) == val; + return val <= 0xFFFFFFFFu; } |