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
(32) |
Oct
|
Nov
|
Dec
|
|
From: Mark W. <ma...@kl...> - 2021-10-12 22:14:01
|
An RC1 tarball for 3.18.0 is now available at https://sourceware.org/pub/valgrind/valgrind-3.18.0.RC1.tar.bz2 (md5sum = 6babaf9e145055a2c9b50cbd2ddfefc0) (sha1sum = ccc73895097cba83cf7664b02edc66866e98a31b) Please give it a try in configurations that are important for you and report any problems you have, either on this mailing list, or (preferably) via our bug tracker at https://bugs.kde.org/enter_bug.cgi?product=valgrind If nothing critical emerges, a final release will happen on Friday 15 October. Note that the NEWS file hasn't been fully updated yet. |
|
From: Mark W. <ma...@so...> - 2021-10-12 21:57:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=20abe9e1489a6443d5330ff507fac0aef7ddb4ae commit 20abe9e1489a6443d5330ff507fac0aef7ddb4ae Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 23:57:00 2021 +0200 -> 3.18.0.RC1 Diff: --- NEWS | 3 ++- configure.ac | 2 +- docs/xml/vg-entities.xml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 73add35e5c..c294c85c3a 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Release 3.??.? (?? 2021) +Release 3.18.0 (15 Oct 2021) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This release supports X86/Linux, AMD64/Linux, ARM32/Linux, ARM64/Linux, @@ -94,6 +94,7 @@ To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX where XXXXXX is the bug number as listed below. +(3.18.0.RC1: 12 Oct 2021) Release 3.17.0 (19 Mar 2021) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/configure.ac b/configure.ac index 3f51bc5c62..3caebab1b8 100755 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ ##------------------------------------------------------------## # Process this file with autoconf to produce a configure script. -AC_INIT([Valgrind],[3.18.0.GIT],[val...@li...]) +AC_INIT([Valgrind],[3.18.0.RC1],[val...@li...]) AC_CONFIG_SRCDIR(coregrind/m_main.c) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects]) diff --git a/docs/xml/vg-entities.xml b/docs/xml/vg-entities.xml index ce3219b523..d986a02573 100644 --- a/docs/xml/vg-entities.xml +++ b/docs/xml/vg-entities.xml @@ -6,8 +6,8 @@ <!-- valgrind release + version stuff --> <!ENTITY rel-type "Release"> -<!ENTITY rel-version "3.17.0"> -<!ENTITY rel-date "19 Mar 2021"> +<!ENTITY rel-version "3.18.0"> +<!ENTITY rel-date "15 Oct 2021"> <!-- where the docs are installed --> <!ENTITY vg-docs-path "$INSTALL/share/doc/valgrind/html/index.html"> |
|
From: Paul F. <pa...@so...> - 2021-10-12 21:33:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=5675b90cc07ca30a18ea653f51fb4973e0f73ff9 commit 5675b90cc07ca30a18ea653f51fb4973e0f73ff9 Author: Paul Floyd <pj...@wa...> Date: Tue Oct 12 23:04:52 2021 +0200 Previous fix was out by one version tag. memalign must have been added with FreeBSD 12.2 Diff: --- memcheck/tests/memalign2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memcheck/tests/memalign2.c b/memcheck/tests/memalign2.c index c5a8b0e07c..a7bdb34c5d 100644 --- a/memcheck/tests/memalign2.c +++ b/memcheck/tests/memalign2.c @@ -31,7 +31,7 @@ int main ( void ) int res; assert(sizeof(long int) == sizeof(void*)); -#if !defined(VGO_freebsd) || (FREEBSD_VERS >= FREEBSD_12) +#if !defined(VGO_freebsd) || (FREEBSD_VERS >= FREEBSD_12_2) // Check behaviour of memalign/free for big alignment. // In particular, the below aims at checking that a // superblock with a big size is not marked as reclaimable |
|
From: Mark W. <ma...@so...> - 2021-10-12 21:27:33
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=970820852e542506dd7a4c722fecd73e34363fde commit 970820852e542506dd7a4c722fecd73e34363fde Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 23:25:32 2021 +0200 vgdb: only queue up to 64 pending signals when waiting for SIGSTOP We should not queue infinite pending signals so we won't run out of memory when the SIGSTOP never arrives. Diff: --- coregrind/vgdb-invoker-ptrace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coregrind/vgdb-invoker-ptrace.c b/coregrind/vgdb-invoker-ptrace.c index 389748960f..07f3400f95 100644 --- a/coregrind/vgdb-invoker-ptrace.c +++ b/coregrind/vgdb-invoker-ptrace.c @@ -300,6 +300,10 @@ Bool waitstopped (pid_t pid, int signal_expected, const char *msg) // realloc a bigger queue, and store new signal at the end. // This is not very efficient but we assume not many sigs are queued. + if (signal_queue_sz >= 64) { + DEBUG(0, "too many queued signals while waiting for SIGSTOP\n"); + return False; + } signal_queue_sz++; signal_queue = vrealloc(signal_queue, sizeof(siginfo_t) * signal_queue_sz); |
|
From: Mark W. <ma...@so...> - 2021-10-12 21:19:31
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=ef95220ddae1af65c85d8d59a8f0dcbb9d7af90f commit ef95220ddae1af65c85d8d59a8f0dcbb9d7af90f Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 23:15:41 2021 +0200 Implement BPF_MAP_LOOKUP_AND_DELETE_ELEM and BPF_MAP_FREEZE Implement BPF_MAP_LOOKUP_AND_DELETE_ELEM (command 21) and BPF_MAP_FREEZE (command 22) and produce a WARNING instead of a fatal error for unrecognized BPF commands. https://bugs.kde.org/show_bug.cgi?id=426148 Diff: --- NEWS | 1 + coregrind/m_syswrap/syswrap-linux.c | 34 ++++++++++++++++++++++++++++++---- include/vki/vki-linux.h | 2 ++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 1127583013..73add35e5c 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 368960 WARNING: unhandled amd64-linux syscall: 163 (acct) 407589 [Linux] Add support for C11 aligned_alloc() and GNU reallocarray() 423963 Error in child thread when CLONE_PIDFD is used +426148 crash with "impossible happened" when running BPF CO-RE programs 429375 PPC ISA 3.1 support is missing, part 9 431157 PPC_FEATURE2_SCV needs to be masked in AT_HWCAP2 431306 Update demangler to support Rust v0 name mangling diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 63dd1fb66e..50203eca09 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -12954,10 +12954,30 @@ PRE(sys_bpf) } } break; + case VKI_BPF_MAP_LOOKUP_AND_DELETE_ELEM: + /* Perform a lookup on an eBPF map. Read key, write value (delete key) */ + PRE_MEM_READ("bpf(attr->key)", (Addr)&attr->key, sizeof(attr->key)); + PRE_MEM_READ("bpf(attr->value)", (Addr)&attr->value, sizeof(attr->value)); + PRE_MEM_READ("bpf(attr->map_fd)", (Addr)&attr->map_fd, sizeof(attr->map_fd)); + if (ML_(safe_to_deref)(attr, ARG3)) { + if (!ML_(fd_allowed)(attr->map_fd, "bpf", tid, False)) { + SET_STATUS_Failure(VKI_EBADF); + break; + } + /* Get size of key and value for this map. */ + if (bpf_map_get_sizes(attr->map_fd, &key_size, &value_size)) { + PRE_MEM_READ("bpf(attr->key)", attr->key, key_size); + PRE_MEM_WRITE("bpf(attr->value)", attr->value, value_size); + } + } + break; + case VKI_BPF_MAP_FREEZE: + /* Freeze map, read map_fd (write frozen flag, not visible to user space). */ + PRE_MEM_READ("bpf(attr->map_fd)", (Addr)&attr->map_fd, sizeof(attr->map_fd)); + break; default: VG_(message)(Vg_DebugMsg, - "FATAL: unhandled eBPF command %lu\n", ARG1); - VG_(core_panic)("... bye!\n"); + "WARNING: unhandled eBPF command %lu\n", ARG1); break; } } @@ -13054,10 +13074,16 @@ POST(sys_bpf) POST_MEM_WRITE((Addr)&attr->task_fd_query.probe_offset, sizeof(attr->task_fd_query.probe_offset)); POST_MEM_WRITE((Addr)&attr->task_fd_query.probe_addr, sizeof(attr->task_fd_query.probe_addr)); break; + case VKI_BPF_MAP_LOOKUP_AND_DELETE_ELEM: + if (bpf_map_get_sizes(attr->map_fd, &key_size, &value_size)) + POST_MEM_WRITE(attr->value, value_size); + break; + case VKI_BPF_MAP_FREEZE: + /* Freeze map, read map_fd (write frozen flag, not visible to user space). */ + break; default: VG_(message)(Vg_DebugMsg, - "FATAL: unhandled eBPF command %lu\n", ARG1); - VG_(core_panic)("... bye!\n"); + "WARNING: unhandled eBPF command %lu\n", ARG1); break; } } diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index eb4e01b337..e6cef7dfff 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -4966,6 +4966,8 @@ enum vki_bpf_cmd { VKI_BPF_BTF_LOAD, VKI_BPF_BTF_GET_FD_BY_ID, VKI_BPF_TASK_FD_QUERY, + VKI_BPF_MAP_LOOKUP_AND_DELETE_ELEM, + VKI_BPF_MAP_FREEZE, }; enum vki_bpf_map_type { |
|
From: Mark W. <ma...@so...> - 2021-10-12 21:04:55
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a21e890f82258c17ee47895fa28bb62937eb1af9 commit a21e890f82258c17ee47895fa28bb62937eb1af9 Author: Lubomir Rintel <lku...@v3...> Date: Mon Oct 4 15:40:29 2021 +0200 Add close_range(2) support This is a system call introduced in Linux 5.9. It's typically used to bulk-close file descriptors that a process inherited without having desired so and doesn't want to pass them to its offspring for security reasons. For this reason the sensible upper limit value tends to be unknown and the users prefer to stay on the safe side by setting it high. This is a bit peculiar because, if unfiltered, the syscall could end up closing descriptors Valgrind uses for its purposes, ending in no end of mayhem and suffering. This patch adjusts the upper bounds to a safe value and then skips over the descriptor Valgrind uses by potentially calling the real system call with sub-ranges that are safe to close. The call can fail on negative ranges and bad flags -- we're dealing with the first condition ourselves while letting the real call fail on bad flags. https://bugs.kde.org/show_bug.cgi?id=439090 Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-linux.h | 3 ++ 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 | 62 ++++++++++++++++++++++++++++ coregrind/m_syswrap/syswrap-mips32-linux.c | 1 + coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 + coregrind/m_syswrap/syswrap-ppc32-linux.c | 1 + coregrind/m_syswrap/syswrap-ppc64-linux.c | 1 + coregrind/m_syswrap/syswrap-s390x-linux.c | 1 + coregrind/m_syswrap/syswrap-x86-linux.c | 1 + include/vki/vki-linux.h | 3 ++ include/vki/vki-scnums-shared-linux.h | 1 + 15 files changed, 80 insertions(+) diff --git a/NEWS b/NEWS index bd4458daef..1127583013 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. have debug information 438871 unhandled instruction bytes: 0xF3 0x49 0xF 0x6F 0x9C 0x24 0x60 0x2 0x0 0x0 439046 valgrind is unusably large when linked with lld +439090 Implement close_range(2) 439326 Valgrind 3.17.0 won't compile with Intel 2021 oneAPI compilers 439590 glibc-2.34 breaks suppressions against obj:*/lib*/libc-2.*so* 440670 unhandled ppc64le-linux syscall: 252 (statfs64) and 253 (fstatfs64) diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index 110f7c832d..baf362f112 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -320,6 +320,9 @@ DECL_TEMPLATE(linux, sys_io_uring_setup); DECL_TEMPLATE(linux, sys_io_uring_enter); DECL_TEMPLATE(linux, sys_io_uring_register); +// Linux-specific (new in Linux 5.9) +DECL_TEMPLATE(linux, sys_close_range); + /* --------------------------------------------------------------------- Wrappers for sockets and ipc-ery. These are split into standalone procedures because x86-linux hides them inside multiplexors diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 46d6b5bebd..5062324a1e 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -875,6 +875,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c index 7f41b07491..556dd844b9 100644 --- a/coregrind/m_syswrap/syswrap-arm-linux.c +++ b/coregrind/m_syswrap/syswrap-arm-linux.c @@ -1052,6 +1052,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c index 0d717f44be..b871077276 100644 --- a/coregrind/m_syswrap/syswrap-arm64-linux.c +++ b/coregrind/m_syswrap/syswrap-arm64-linux.c @@ -831,6 +831,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 818b11ff6e..63dd1fb66e 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -13315,6 +13315,68 @@ PRE(sys_execveat) } +PRE(sys_close_range) +{ + SysRes res = VG_(mk_SysRes_Success)(0); + unsigned int beg, end; + unsigned int last = ARG2; + + FUSE_COMPATIBLE_MAY_BLOCK(); + PRINT("sys_close_range ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" + FMT_REGWORD "u )", ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "close_range", + unsigned int, first, unsigned int, last, + unsigned int, flags); + + if (ARG1 > last) { + SET_STATUS_Failure( VKI_EINVAL ); + return; + } + + if (last >= VG_(fd_hard_limit)) + last = VG_(fd_hard_limit) - 1; + + if (ARG1 > last) { + SET_STATUS_Success ( 0 ); + return; + } + + beg = end = ARG1; + do { + if (end > last + || (end == 2/*stderr*/ && VG_(debugLog_getLevel)() > 0) + || end == VG_(log_output_sink).fd + || end == VG_(xml_output_sink).fd) { + /* Split the range if it contains a file descriptor we're not + * supposed to close. */ + if (end - 1 >= beg) + res = VG_(do_syscall3)(__NR_close_range, (UWord)beg, (UWord)end - 1, ARG3 ); + beg = end + 1; + } + } while (end++ <= last); + + /* If it failed along the way, it's presumably the flags being wrong. */ + SET_STATUS_from_SysRes (res); +} + +POST(sys_close_range) +{ + unsigned int fd; + unsigned int last = ARG2; + + if (!VG_(clo_track_fds) + || (ARG3 & VKI_CLOSE_RANGE_CLOEXEC) != 0) + return; + + if (last >= VG_(fd_hard_limit)) + last = VG_(fd_hard_limit) - 1; + + for (fd = ARG1; fd <= last; fd++) + if ((fd != 2/*stderr*/ || VG_(debugLog_getLevel)() == 0) + && fd != VG_(log_output_sink).fd + && fd != VG_(xml_output_sink).fd) + ML_(record_fd_close)(fd); +} #undef PRE #undef POST diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index f957c6f583..f556e063f0 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -1137,6 +1137,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_ (__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c index 94f38366f0..41a5404c55 100644 --- a/coregrind/m_syswrap/syswrap-mips64-linux.c +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c @@ -816,6 +816,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY (__NR_io_uring_enter, sys_io_uring_enter), LINXY (__NR_io_uring_register, sys_io_uring_register), GENX_ (__NR_clone3, sys_ni_syscall), + LINXY (__NR_close_range, sys_close_range), LINX_ (__NR_faccessat2, sys_faccessat2), }; diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c index 102c155507..f9d4b19f4a 100644 --- a/coregrind/m_syswrap/syswrap-nanomips-linux.c +++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c @@ -825,6 +825,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY (__NR_io_uring_enter, sys_io_uring_enter), LINXY (__NR_io_uring_register, sys_io_uring_register), GENX_ (__NR_clone3, sys_ni_syscall), + LINXY (__NR_close_range, sys_close_range), LINX_ (__NR_faccessat2, sys_faccessat2), }; diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 7f9c9fa9bc..6263ab8451 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1055,6 +1055,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 43cde73271..a26b41c321 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1024,6 +1024,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c index 5283c19fe4..5c9209859f 100644 --- a/coregrind/m_syswrap/syswrap-s390x-linux.c +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c @@ -865,6 +865,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register), // 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 418c769750..1d8f45d33a 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1646,6 +1646,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_io_uring_register, sys_io_uring_register),// 427 GENX_(__NR_clone3, sys_ni_syscall), // 435 + LINXY(__NR_close_range, sys_close_range), // 436 LINX_(__NR_faccessat2, sys_faccessat2), // 439 }; diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index 426d9db92f..eb4e01b337 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -5369,6 +5369,9 @@ struct vki_itimerspec64 { #define VKI_RLIM64_INFINITY (~0ULL) +#define VKI_CLOSE_RANGE_UNSHARE (1U << 1) +#define VKI_CLOSE_RANGE_CLOEXEC (1U << 2) + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h index 6c70c9981d..fa63c7a9bc 100644 --- a/include/vki/vki-scnums-shared-linux.h +++ b/include/vki/vki-scnums-shared-linux.h @@ -40,6 +40,7 @@ #define __NR_fspick 433 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_faccessat2 439 |
|
From: Mark W. <ma...@so...> - 2021-10-12 20:53:24
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=cf9ebf8313952caed53394498fe849251f477c97 commit cf9ebf8313952caed53394498fe849251f477c97 Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 22:47:57 2021 +0200 coregrind: Don't call final_tidyup (__libc_freeres) on FatalSignal When a program gets a fatal signal (one it doesn't handle) valgrind terminates the program. Before termination it will try to call final_tidyup which tries to run __libc_freeres and __gnu_cxx::__freeres to get rid of some memory glibc or libstdc++ don't normally release. But when the program got the fatal signal in a critical section inside glibc it might leave the datastructures in a bad state and cause __libc_freeres to crash. This makes valgrind itself crash just before producing its own error summary, making the valgrind run unusable. A reproducer can found at https://bugzilla.redhat.com/show_bug.cgi?id=1952836 and https://bugzilla.redhat.com/show_bug.cgi?id=1225994#c7 This reproducer is really a worse case scenario with multiple threads racing to get into the critical section that when interrupted will make __libc_freeres unable to cleanup. But it seems a good policy in general. If a program is terminated by a fatal signal instead of normal termination, it seems not having some of the glibc/libstdc++ resource cleaned up is an expected thing. https://bugs.kde.org/show_bug.cgi?id=443605 Diff: --- NEWS | 1 + coregrind/m_main.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d8addbb203..bd4458daef 100644 --- a/NEWS +++ b/NEWS @@ -86,6 +86,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 443180 The subnormal test and the ISA 3.0 test generate compiler warnings. 443314 In the latest GIT version, Valgrind with "--trace-flags" crashes at "al" register +443605 Don't call final_tidyup (__libc_freeres) on FatalSignal To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 56f9c6cbf0..70b6c05495 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -2168,6 +2168,7 @@ void shutdown_actions_NORETURN( ThreadId tid, || tids_schedretcode == VgSrc_ExitProcess || tids_schedretcode == VgSrc_FatalSig ); + /* Try to do final tidyup on "normal" exit, not on FatalSig. */ if (tids_schedretcode == VgSrc_ExitThread) { // We are the last surviving thread. Right? @@ -2185,7 +2186,7 @@ void shutdown_actions_NORETURN( ThreadId tid, vg_assert(VG_(is_running_thread)(tid)); vg_assert(VG_(count_living_threads)() == 1); - } else { + } else if (tids_schedretcode == VgSrc_ExitProcess) { // We may not be the last surviving thread. However, we // want to shut down the entire process. We hold the lock |
|
From: Mark W. <ma...@so...> - 2021-10-12 20:44:45
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=3eba47604df85d93bbd4301a316dda8b71c385b1 commit 3eba47604df85d93bbd4301a316dda8b71c385b1 Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 22:41:30 2021 +0200 filter_gdb: Handle r = SYSCALL_CANCEL as alternative for return SYSCALL_CANCEL This happens with glibc 2.33 when debuginfo is installed. Diff: --- gdbserver_tests/filter_gdb.in | 1 + 1 file changed, 1 insertion(+) diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in index fd20621842..d0c94f3f1a 100755 --- a/gdbserver_tests/filter_gdb.in +++ b/gdbserver_tests/filter_gdb.in @@ -125,6 +125,7 @@ s/in __select$/in syscall .../ /sysv\/linux\/select\.c/d /sysv\/linux\/generic\/select.c/d /return SYSCALL_CANCEL /d +/r = SYSCALL_CANCEL /d # a more specialised system call select stack trace part # (on 32 bits, we have an int_80, on 64 bits, directly select) |
|
From: Paul F. <pa...@so...> - 2021-10-12 19:48:08
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=79a1439786c18f0d38f230616c1ab06b9255577f commit 79a1439786c18f0d38f230616c1ab06b9255577f Author: Paul Floyd <pj...@wa...> Date: Tue Oct 12 21:47:45 2021 +0200 Fix building memalign2 test on older FreeBSD Diff: --- memcheck/tests/memalign2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/memcheck/tests/memalign2.c b/memcheck/tests/memalign2.c index 95d13354e7..c5a8b0e07c 100644 --- a/memcheck/tests/memalign2.c +++ b/memcheck/tests/memalign2.c @@ -16,6 +16,7 @@ #include <assert.h> #include "tests/malloc.h" #include <errno.h> +#include "../../config.h" int main ( void ) { @@ -30,6 +31,7 @@ int main ( void ) int res; assert(sizeof(long int) == sizeof(void*)); +#if !defined(VGO_freebsd) || (FREEBSD_VERS >= FREEBSD_12) // Check behaviour of memalign/free for big alignment. // In particular, the below aims at checking that a // superblock with a big size is not marked as reclaimable @@ -78,6 +80,7 @@ int main ( void ) p = memalign(4 * 1024 * 1024, 100); assert(0 == (long)p % (4 * 1024 * 1024)); p = memalign(16 * 1024 * 1024, 100); assert(0 == (long)p % (16 * 1024 * 1024)); +#endif # define PM(a,b,c) posix_memalign((void**)a, b, c) |
|
From: Mark W. <ma...@so...> - 2021-10-12 18:06:58
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=0b86d267c60d5977ae3426475fb73df226ba8c0b commit 0b86d267c60d5977ae3426475fb73df226ba8c0b Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 20:01:45 2021 +0200 filter_xml: Filter out '@*' from <fn> symbol names With glibc 2.34 we would start seeing some function names ending in '@*' this was already filtered out using drd/tests/filter_stderr.in but not when using the drd xml tests. This would make drd/tests/thread_name_xml and drd/tests/bar_bad_xml fail. Filter this out in the memcheck/tests/filter_xml script, which is also used by the drd test filters. Tested against glibc 2.34, 2.33 and 2.17 on x86_64. Diff: --- memcheck/tests/filter_xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/memcheck/tests/filter_xml b/memcheck/tests/filter_xml index 6de4e930b5..e8c0b75cf5 100755 --- a/memcheck/tests/filter_xml +++ b/memcheck/tests/filter_xml @@ -11,6 +11,8 @@ sed "s/<obj>.*<\/obj>/<obj>...<\/obj>/" | sed "s/<line>.*<\/line>/<line>...<\/line>/" | sed "s/<dir>.*<\/dir>/<dir>...<\/dir>/" | sed "s/<count>.*<\/count>/<count>...<\/count>/" | +# Filter out @* version symbol function names +sed "s/<fn>\(.*\)\@\*<\/fn>/<fn>\1<\/fn>/" | sed "s/of size [48]</of size N</" | perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c/vg_replace_malloc.c/" | perl -0 -p -e "s/<suppcounts>.*<\/suppcounts>/<suppcounts>...<\/suppcounts>/s" | |
|
From: Paul F. <pa...@so...> - 2021-10-12 17:32:18
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=22857ddd1da007a4f5b54086acb3cd82925d5ff6 commit 22857ddd1da007a4f5b54086acb3cd82925d5ff6 Author: Paul Floyd <pj...@wa...> Date: Tue Oct 12 19:31:04 2021 +0200 filter_stderr also needs to handle FreeBSD libthr Diff: --- drd/tests/filter_stderr.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drd/tests/filter_stderr.in b/drd/tests/filter_stderr.in index e7d975b81b..81a48ab7b8 100755 --- a/drd/tests/filter_stderr.in +++ b/drd/tests/filter_stderr.in @@ -37,7 +37,7 @@ $SED \ -e "s/_swapcontext/swapcontext/" \ -e "s/[A-Za-z_]* (pthread_create.c:[0-9]*)/(within libpthread-?.?.so)/" \ -e "s/[A-Za-z_]* (in [^ ]*libpthread-[0-9.]*\.so)/(within libpthread-?.?.so)/" \ --e "s/... (in \/lib\/libthr.so.3)/(within libpthread-?.?.so)/" \ +-e "s/... (in \/lib\/libthr.so.3)/start_thread/" \ -e "s:(within /lib[0-9]*/ld-[0-9.]*\.so):(within ld-?.?.so):" \ -e "s/was held during [0-9][0-9]*/was held during .../" \ -e "s: BSS section of [^<]*/: BSS section of :g" \ |
|
From: Mark W. <ma...@so...> - 2021-10-12 16:56:49
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=df838bccab28311b06836d032f54df9973c9cb74 commit df838bccab28311b06836d032f54df9973c9cb74 Author: Mark Wielaard <ma...@kl...> Date: Tue Oct 12 18:51:23 2021 +0200 drd/tests: Extract start_thread which can come from libpthread or libc The drd/tests/tc21_pthonce and drd/tests/annotate_barrier tests would fail if start_thread came from libc (as it does in glibc 2.34) instead of from libpthread. Extract start_thread in filter_stderr.in and update the backtraces in annotate_barrier.stderr.exp and in tc21_pthonce.stderr.exp Tested against glibc 2.34, 2.33 and 2.17 on x86_64. Diff: --- drd/tests/annotate_barrier.stderr.exp | 2 +- drd/tests/filter_stderr.in | 2 ++ drd/tests/tc21_pthonce.stderr.exp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drd/tests/annotate_barrier.stderr.exp b/drd/tests/annotate_barrier.stderr.exp index 1ae8934c34..41296531a9 100644 --- a/drd/tests/annotate_barrier.stderr.exp +++ b/drd/tests/annotate_barrier.stderr.exp @@ -25,7 +25,7 @@ Thread 2: Conflicting store by thread 2 at 0x........ size 4 at 0x........: threadfunc (annotate_barrier.c:?) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) - by 0x........: (within libpthread-?.?.so) + by 0x........: start_thread Address 0x........ is at offset 0 from 0x......... Allocation context: at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: barriers_and_races (annotate_barrier.c:?) diff --git a/drd/tests/filter_stderr.in b/drd/tests/filter_stderr.in index aec1d60f5d..e7d975b81b 100755 --- a/drd/tests/filter_stderr.in +++ b/drd/tests/filter_stderr.in @@ -19,6 +19,7 @@ fi | # Remove line numbers referring to drd's source code. # Remove libpthread's version number. # Remove line numbers from stack traces. +# Extract start_thread because it can be in libpthread or libc. $SED \ -e "/^drd, a thread error detector$/d" \ -e "s/^Allocation context: stack of thread \([0-9]*\), offset -[0-9]*$/Allocation context: stack of thread \1, offset .../" \ @@ -30,6 +31,7 @@ $SED \ -e "s/(\(functional\|thread\):[0-9]*)/(\1:...)/" \ -e "s/(tc20_verifywrap.c:261)/(tc20_verifywrap.c:262)/" \ -e "/^Copyright (C) 2006-20.., and GNU GPL'd, by Bart Van Assche.$/d" \ +-e "s/start_thread ([^)]*)/start_thread/" \ -e "s/\([A-Za-z_]*\) (clone.S:[0-9]*)/\1 (in \/...libc...)/" \ -e "s/\([A-Za-z_]*\) (swapcontext.S:[0-9]*)/\1 (in \/...libc...)/" \ -e "s/_swapcontext/swapcontext/" \ diff --git a/drd/tests/tc21_pthonce.stderr.exp b/drd/tests/tc21_pthonce.stderr.exp index b6458280f1..3179b98859 100644 --- a/drd/tests/tc21_pthonce.stderr.exp +++ b/drd/tests/tc21_pthonce.stderr.exp @@ -3,7 +3,7 @@ Thread 3: Conflicting load by thread 3 at 0x........ size 4 at 0x........: child (tc21_pthonce.c:74) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) - by 0x........: (within libpthread-?.?.so) + by 0x........: start_thread Allocation context: BSS section of tc21_pthonce Other segment start (thread 2) (thread finished, call stack no longer available) @@ -13,7 +13,7 @@ Other segment end (thread 2) Conflicting store by thread 3 at 0x........ size 4 at 0x........: child (tc21_pthonce.c:74) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) - by 0x........: (within libpthread-?.?.so) + by 0x........: start_thread Allocation context: BSS section of tc21_pthonce Other segment start (thread 2) (thread finished, call stack no longer available) |
|
From: Mark W. <ma...@kl...> - 2021-10-12 13:19:00
|
Hi valgrind hackers, On Wed, 2021-09-22 at 15:02 +0200, Mark Wielaard wrote: > I would like to propose we do a valgrind 3.18.0 release next month. > There have been various useful changes since 3.17.0 for power10, > s390x z15 updates, arm64 v8.2, glibc 2.34 updates (which are really > needed, without them things simply break). I believe things are looking pretty good, the DWARF reader speedups are in, as are the Power PC fixes and the freebsd port, the libiberty demangler has been updated to support Rust v0 mangling. The bug database was cleaned up a bit and various smaller fixes have landed. And as a bonus both make and make check should now have zero compiler warnings (at least on x86_64 with latest gcc 11). There are 4 issue with patches which I like to land today and then do an RC1 release to more general testing: https://bugs.kde.org/show_bug.cgi?id=443605 Don't call final_tidyup (__libc_freeres) on FatalSignal https://bugs.kde.org/show_bug.cgi?id=439090 Implement close_range(2) https://bugs.kde.org/show_bug.cgi?id=426148 Valgrind crash with "impossible happened" when running BPF CO-RE This isn't a full fix, there are still various BPF syscall commands we don't support, but it should help those using bpf under valgrind to report better bug reports about which support is needed (most). https://bugs.kde.org/show_bug.cgi?id=441474 vgdb might eat all memory while waiting for sigstop This is only a workaround for an issue on s390x which I have been unable to track fully down. But it makes sure we don't eat all memory on the machine. We'll stop after we get more than 64 pending signals. There are also still some issues in the testsuite when running against glibc 2.34 and libstdc++ 11.2. I don't think they are critical, but it would be nice if we could clean them up: On x86_64: == 721 tests, 9 stderr failures, 0 stdout failures, 1 stderrB failure, 0 stdoutB failures, 3 post failures == gdbserver_tests/hginfo (stderrB) memcheck/tests/leak_cpp_interior (stderr) memcheck/tests/overlap (stderr) memcheck/tests/supp_unknown (stderr) helgrind/tests/tls_threads (stderr) drd/tests/annotate_barrier (stderr) drd/tests/bar_bad_xml (stderr) drd/tests/pth_barrier_thr_cr (stderr) drd/tests/tc21_pthonce (stderr) drd/tests/thread_name_xml (stderr) massif/tests/deep-D (post) massif/tests/new-cpp (post) massif/tests/overloaded-new (post) - hginfo detects an extra lock, which I don't know how to suppress: Lock ga 0x........ { Address 0x........ is 2440 bytes inside data symbol "_rtld_local" kind mbRec } - leak_cpp_interior detects slightly different leaks, which I believe are inside libstdc++: - possibly lost: x (-x) bytes in 5 (+1) blocks - still reachable: x (+x) bytes in 3 (-1) blocks + possibly lost: x (-x) bytes in 4 (+0) blocks + still reachable: x (+x) bytes in 5 (+0) blocks of which reachable via heuristic: - newarray : x (+x) bytes in 1 (+1) blocks + newarray : x (+x) bytes in 2 (+2) blocks - overlap is a known issue https://bugs.kde.org/show_bug.cgi?id=402833 - supp_unknown doesn't work because we are missing the main frame somehow - tls_threads sched WARNING: pthread stack cache cannot be disabled! This was changed in glibc 2.34, there is a new mechanism. Also helgrind seems to detect a race in pthread_create@* itself which seems odd, bad suppression? - annotate_barrier expects a backtrace in libpthread, but symbols have moved into main libc.so - by 0x........: (within libpthread-?.?.so) + by 0x........: start_thread (in /...libc...) Needs an alternate .exp file? - bar_bad_xml, we expect an unversioned pthread_barrier_init in the xml output, but get a versioned one. <frame> <ip>0x........</ip> <obj>...</obj> - <fn>pthread_barrier_init</fn> + <fn>pthread_barrier_init@*</fn> <dir>...</dir> <file>drd_pthread_intercepts.c</file> Should we just filter out the @* ? - pth_barrier_thr_cr Number of concurrent pthread_barrier_wait() calls exceeds the barrier count Not analyzed yet. - tc21_pthonce same as annotate_barrier - thread_name_xml same as bar_bad_xml but now for pthread_mutex_unlock - The massif post outputs seem to need adjustments for some internal allocation patterns in glibc/libstdc++ Cheers, Mark |
|
From: Paul F. <pa...@so...> - 2021-10-11 06:19:49
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=2269aeb76c0531fe09e1dbb0d66fa3961159247c commit 2269aeb76c0531fe09e1dbb0d66fa3961159247c Author: Paul Floyd <pj...@wa...> Date: Mon Oct 11 08:16:32 2021 +0200 Dnother iteration for getting the right expected line numbers. Diff: --- drd/tests/tc09_bad_unlock.stderr.exp-ppc | 4 ++-- memcheck/tests/badjump2.stderr.exp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-ppc b/drd/tests/tc09_bad_unlock.stderr.exp-ppc index 9a42458da9..72cbe743c1 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-ppc +++ b/drd/tests/tc09_bad_unlock.stderr.exp-ppc @@ -25,7 +25,7 @@ The object at address 0x........ is not a mutex. by 0x........: main (tc09_bad_unlock.c:52) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:44) + at 0x........: nearly_main (tc09_bad_unlock.c:43) by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) @@ -48,7 +48,7 @@ The object at address 0x........ is not a mutex. by 0x........: main (tc09_bad_unlock.c:53) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:44) + at 0x........: nearly_main (tc09_bad_unlock.c:43) by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) diff --git a/memcheck/tests/badjump2.stderr.exp b/memcheck/tests/badjump2.stderr.exp index 78e416bdcd..6846e3a58e 100644 --- a/memcheck/tests/badjump2.stderr.exp +++ b/memcheck/tests/badjump2.stderr.exp @@ -1,6 +1,6 @@ Jump to the invalid address stated on the next line ... - by 0x........: main (badjump2.c:47) + by 0x........: main (badjump2.c:48) Address 0x........ is not stack'd, malloc'd or (recently) free'd Signal caught, as expected |
|
From: Paul F. <pa...@so...> - 2021-10-10 20:17:13
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=46607a76bd3be925f37aceb2ab4f49db0581e6b5 commit 46607a76bd3be925f37aceb2ab4f49db0581e6b5 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 10 22:15:59 2021 +0200 memalign is available on FreeBSD as a non-portable interface Remove #if block protecting memalign calls Diff: --- memcheck/tests/memalign2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/memcheck/tests/memalign2.c b/memcheck/tests/memalign2.c index 4ae967b9e8..95d13354e7 100644 --- a/memcheck/tests/memalign2.c +++ b/memcheck/tests/memalign2.c @@ -30,7 +30,6 @@ int main ( void ) int res; assert(sizeof(long int) == sizeof(void*)); -#if !defined(__FreeBSD__) // Check behaviour of memalign/free for big alignment. // In particular, the below aims at checking that a // superblock with a big size is not marked as reclaimable @@ -79,7 +78,6 @@ int main ( void ) p = memalign(4 * 1024 * 1024, 100); assert(0 == (long)p % (4 * 1024 * 1024)); p = memalign(16 * 1024 * 1024, 100); assert(0 == (long)p % (16 * 1024 * 1024)); -#endif # define PM(a,b,c) posix_memalign((void**)a, b, c) |
|
From: Paul F. <pa...@so...> - 2021-10-10 20:03:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=8c0f72667e1a4d378ecda3699d198d56e0ac9498 commit 8c0f72667e1a4d378ecda3699d198d56e0ac9498 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 10 21:56:49 2021 +0200 Fix the ramaining easily fixable warnings with clang There's one remaining memalign2.c:29:9: warning: unused variable 'piece' [-Wunused-variable] because of a block of #if FreeBSD for memalign that looks unnecessary Otherwise all that is left is a few like warning: unknown warning option '-Wno-alloc-size-larger-than'; did you mean '-Wno-frame-larger-than='? [-Wunknown-warning-option] because there is no standard for compiler arguments. Diff: --- coregrind/m_gdbserver/valgrind-low-nanomips.c | 1 + drd/tests/tc12_rwl_trivial.stderr.exp | 2 +- helgrind/tests/safe-pthread.h | 1 + helgrind/tests/safe-semaphore.h | 1 + massif/tests/Makefile.am | 4 ++++ memcheck/tests/Makefile.am | 7 +++++-- none/tests/Makefile.am | 1 + none/tests/amd64/sbbmisc.c | 2 +- none/tests/x86/sbbmisc.c | 2 +- 9 files changed, 16 insertions(+), 5 deletions(-) diff --git a/coregrind/m_gdbserver/valgrind-low-nanomips.c b/coregrind/m_gdbserver/valgrind-low-nanomips.c index e8ed36400b..77a4190fe0 100644 --- a/coregrind/m_gdbserver/valgrind-low-nanomips.c +++ b/coregrind/m_gdbserver/valgrind-low-nanomips.c @@ -107,6 +107,7 @@ void set_pc (CORE_ADDR newpc) #define itype_rt(x) ((x >> 16) & 0x1f) #define rtype_funct(x) (x & 0x3f) +static inline UInt getUInt(UChar * p) __attribute__((unused)); /* Do a endian load of a 32-bit word, regardless of the endianness of the underlying host. */ static inline UInt getUInt(UChar * p) diff --git a/drd/tests/tc12_rwl_trivial.stderr.exp b/drd/tests/tc12_rwl_trivial.stderr.exp index 73163e7b23..b2d4048ab6 100644 --- a/drd/tests/tc12_rwl_trivial.stderr.exp +++ b/drd/tests/tc12_rwl_trivial.stderr.exp @@ -1,7 +1,7 @@ Reader-writer lock not locked by calling thread: rwlock 0x......... at 0x........: pthread_rwlock_unlock (drd_pthread_intercepts.c:?) - by 0x........: safe_pthread_rwlock_unlock (safe-pthread.h:58) + by 0x........: safe_pthread_rwlock_unlock (safe-pthread.h:59) by 0x........: main (tc12_rwl_trivial.c:29) rwlock 0x........ was first observed at: at 0x........: pthread_rwlock_init (drd_pthread_intercepts.c:?) diff --git a/helgrind/tests/safe-pthread.h b/helgrind/tests/safe-pthread.h index 0a2c813237..788f7b89b6 100644 --- a/helgrind/tests/safe-pthread.h +++ b/helgrind/tests/safe-pthread.h @@ -28,6 +28,7 @@ static void segv_handler( int signum, siginfo_t *siginfo, void *sigcontext ) { siglongjmp( env, EPERM ); } +static int safe_pthread_rwlock_unlock( pthread_rwlock_t *rwlock ) __attribute__((unused)); /* * Wrapper for pthread_rwlock_unlock which may execute xend * unconditionally when used on a lock that is not locked. diff --git a/helgrind/tests/safe-semaphore.h b/helgrind/tests/safe-semaphore.h index 3aa0dc4e4c..c0e003bcbc 100644 --- a/helgrind/tests/safe-semaphore.h +++ b/helgrind/tests/safe-semaphore.h @@ -14,6 +14,7 @@ static void abrt_handler( int signum, siginfo_t *siginfo, void *sigcontext ) { siglongjmp( env, EINVAL ); } +static int safe_sem_post( sem_t *sem ) __attribute__((unused)); static int safe_sem_post( sem_t *sem ) { struct sigaction sa; struct sigaction oldsa; diff --git a/massif/tests/Makefile.am b/massif/tests/Makefile.am index 54814fb6bf..5b3d1938f4 100644 --- a/massif/tests/Makefile.am +++ b/massif/tests/Makefile.am @@ -88,6 +88,10 @@ AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) # C++ tests new_cpp_SOURCES = new-cpp.cpp overloaded_new_SOURCES = overloaded-new.cpp +# pre C++11 compilers don't have exception specs +# C++11 and later compilers may complain about not having +# exception specs +overloaded_new_CXXFLAGS = $(AM_CXXFLAGS) -Wno-implicit-exception-spec-mismatch -Wno-missing-exception-spec # Suppress warnings for issues we are testing for alloc_fns_CFLAGS = $(AM_CFLAGS) -Wno-unused-result diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index f6b97f53d3..4d0476e2df 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -584,7 +584,8 @@ origin6_fp_CFLAGS = $(AM_CFLAGS) -O # Don't allow GCC to inline memcpy() and strcpy(), # because then we can't intercept it -overlap_CFLAGS = $(AM_CFLAGS) -fno-builtin-memcpy -fno-builtin-strcpy +overlap_CFLAGS = $(AM_CFLAGS) -fno-builtin-memcpy -fno-builtin-strcpy \ + -Wno-fortify-source resvn_stack_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ @@ -602,6 +603,7 @@ endif str_tester_CFLAGS = $(AM_CFLAGS) -Wno-shadow -Wno-stringop-overflow \ -Wno-stringop-truncation \ + -Wno-fortify-source -Wno-suspicious-bzero \ @FLAG_W_NO_MEMSET_TRANSPOSED_ARGS@ supp_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ @@ -702,5 +704,6 @@ xml1_CFLAGS = $(AM_CFLAGS) -D_GNU_SOURCE if HAVE_ALIGNED_CXX_ALLOC check_PROGRAMS += cxx17_aligned_new cxx17_aligned_new_SOURCES = cxx17_aligned_new.cpp -cxx17_aligned_new_CXXFLAGS = -std=c++17 +# need C++ 17, and we deliberately mismatch new and delete +cxx17_aligned_new_CXXFLAGS = -std=c++17 -Wno-mismatched-new-delete endif diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 7ac07c68d5..24a81b3be9 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -303,6 +303,7 @@ fdleak_creat_LDADD = -lsocket -lnsl fdleak_socketpair_LDADD = -lsocket -lnsl endif floored_LDADD = -lm +ifunc_CFLAGS = $(AM_CFLAGS) -Wno-unused-function manythreads_LDADD = -lpthread if VGCONF_OS_IS_DARWIN nestedfns_CFLAGS = $(AM_CFLAGS) -fnested-functions diff --git a/none/tests/amd64/sbbmisc.c b/none/tests/amd64/sbbmisc.c index f82cc6ba09..82b5db0ce2 100644 --- a/none/tests/amd64/sbbmisc.c +++ b/none/tests/amd64/sbbmisc.c @@ -401,7 +401,7 @@ int main ( void ) adc_ib_al(); printf("r8 = %d %d\n", (int)out_b1, (int)out_b2); - in_w = 49999; + in_w = -15537; adc_iw_ax(); printf("r9 = %d %d\n", (int)out_w1, (int)out_w2); diff --git a/none/tests/x86/sbbmisc.c b/none/tests/x86/sbbmisc.c index f9e7f901ca..6e3822cb38 100644 --- a/none/tests/x86/sbbmisc.c +++ b/none/tests/x86/sbbmisc.c @@ -252,7 +252,7 @@ int main ( void ) adc_ib_al(); printf("r8 = %d %d\n", (int)out_b1, (int)out_b2); - in_w = 49999; + in_w = -15537; adc_iw_ax(); printf("r9 = %d %d\n", (int)out_w1, (int)out_w2); |
|
From: Paul F. <pa...@so...> - 2021-10-10 18:34:39
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=03f1c090f6a55d44cad51a833517ba822d7656b8 commit 03f1c090f6a55d44cad51a833517ba822d7656b8 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 10 20:32:44 2021 +0200 Remove a couple more warnings suffix rule with dependency generates a warning https://www.gnu.org/software/make/manual/html_node/Error-Messages.html (bottom of page) the other is a short initialized with an int literal that wraps to a negative short value Diff: --- none/tests/amd64/Makefile.am | 2 +- none/tests/amd64/sbbmisc.c | 2 +- none/tests/x86/Makefile.am | 2 +- none/tests/x86/sbbmisc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am index 790c1c0450..27a244a9e5 100644 --- a/none/tests/amd64/Makefile.am +++ b/none/tests/amd64/Makefile.am @@ -231,5 +231,5 @@ looper_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ sbbmisc_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ shrld_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ -.def.c: $(srcdir)/gen_insn_test.pl +.def.c: $(PERL) $(srcdir)/gen_insn_test.pl < $< > $@ diff --git a/none/tests/amd64/sbbmisc.c b/none/tests/amd64/sbbmisc.c index 1024bfd579..f82cc6ba09 100644 --- a/none/tests/amd64/sbbmisc.c +++ b/none/tests/amd64/sbbmisc.c @@ -369,7 +369,7 @@ int main ( void ) sbb_ib_al(); printf("r1 = %d %d\n", (int)out_b1, (int)out_b2); - in_w = 49999; + in_w = -15537; /* was 49999 but that causes a warning */ sbb_iw_ax(); printf("r2 = %d %d\n", (int)out_w1, (int)out_w2); diff --git a/none/tests/x86/Makefile.am b/none/tests/x86/Makefile.am index 3f6ad1249e..3ecd1ad3c2 100644 --- a/none/tests/x86/Makefile.am +++ b/none/tests/x86/Makefile.am @@ -180,5 +180,5 @@ insn_ssse3_LDADD = -lm x86locked_CFLAGS = $(AM_CFLAGS) -O yield_LDADD = -lpthread -.def.c: $(srcdir)/gen_insn_test.pl +.def.c: $(PERL) $(srcdir)/gen_insn_test.pl < $< > $@ diff --git a/none/tests/x86/sbbmisc.c b/none/tests/x86/sbbmisc.c index 7c4585d957..f9e7f901ca 100644 --- a/none/tests/x86/sbbmisc.c +++ b/none/tests/x86/sbbmisc.c @@ -220,7 +220,7 @@ int main ( void ) sbb_ib_al(); printf("r1 = %d %d\n", (int)out_b1, (int)out_b2); - in_w = 49999; + in_w = -15537; /* was 49999 but that causes a warning */ sbb_iw_ax(); printf("r2 = %d %d\n", (int)out_w1, (int)out_w2); |
|
From: Mark W. <ma...@so...> - 2021-10-10 15:20:18
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bfd28bb9f83c34cd366ac63a72d1fc0bf2028060 commit bfd28bb9f83c34cd366ac63a72d1fc0bf2028060 Author: Mark Wielaard <ma...@kl...> Date: Sun Oct 10 17:13:43 2021 +0200 Remove more warnings from tests GCC12 catches various issues in tests at compile time that we want to catch at runtime. Also glibc 2.34 deprecated various mallinfo related functions. Add the relevant -Wno-foobar flags to those tests. In one case, unit_oset.c, the warning was correct and the uninitialized variable was explicitly set. Diff: --- dhat/tests/Makefile.am | 3 ++- massif/tests/Makefile.am | 1 + memcheck/tests/Makefile.am | 10 +++++++--- memcheck/tests/unit_oset.c | 1 + memcheck/tests/x86-linux/Makefile.am | 1 + memcheck/tests/x86/Makefile.am | 1 + 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dhat/tests/Makefile.am b/dhat/tests/Makefile.am index 3b0cd3e62a..86a9b6d647 100644 --- a/dhat/tests/Makefile.am +++ b/dhat/tests/Makefile.am @@ -26,5 +26,6 @@ check_PROGRAMS = \ AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) -# We don't care about unused malloc results +# We don't care about uninitialized or unused malloc results +basic_CFLAGS = $(AM_CFLAGS) -Wno-uninitialized big_CFLAGS = $(AM_CFLAGS) -Wno-unused-result diff --git a/massif/tests/Makefile.am b/massif/tests/Makefile.am index 0ecf09676a..54814fb6bf 100644 --- a/massif/tests/Makefile.am +++ b/massif/tests/Makefile.am @@ -100,3 +100,4 @@ insig_CFLAGS = $(AM_CFLAGS) -Wno-unused-result long_names_CFLAGS = $(AM_CFLAGS) -Wno-unused-result one_CFLAGS = $(AM_CFLAGS) -Wno-unused-result thresholds_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +realloc_CFLAGS = $(AM_CFLAGS) -Wno-free-nonheap-object diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index d7759296fc..f6b97f53d3 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -508,13 +508,17 @@ demangle_SOURCES = demangle.cpp # Suppress various gcc warnings which are correct, but for things # we are actually testing for at runtime. accounting_CFLAGS = $(AM_CFLAGS) -Wno-alloc-size-larger-than +badfree_CFLAGS = $(AM_CFLAGS) -Wno-free-nonheap-object bug155125_CFLAGS = $(AM_CFLAGS) -Wno-unused-result -Wno-alloc-size-larger-than +mallinfo_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations malloc3_CFLAGS = $(AM_CFLAGS) -Wno-alloc-size-larger-than +sbfragment_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations +strchr_CFLAGS = $(AM_CFLAGS) -Wno-uninitialized big_debuginfo_symbol_SOURCES = big_debuginfo_symbol.cpp big_debuginfo_symbol_CXXFLAGS = $(AM_CXXFLAGS) -std=c++0x -bug340392_CFLAGS = $(AM_CFLAGS) -O3 +bug340392_CFLAGS = $(AM_CFLAGS) -O3 -Wno-maybe-uninitialized dw4_CFLAGS = $(AM_CFLAGS) -gdwarf-4 -fdebug-types-section descr_belowsp_LDADD = -lpthread @@ -535,7 +539,7 @@ execve1_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@ execve2_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@ -fprw_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ +fprw_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ -Wno-free-nonheap-object inits_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ @@ -647,7 +651,7 @@ else varinfo5so_so_LDFLAGS = -fpic $(AM_FLAG_M3264_PRI) -shared \ -Wl,-soname -Wl,varinfo5so.so endif -varinforestrict_CFLAGS = $(AM_CFLAGS) -O0 -g +varinforestrict_CFLAGS = $(AM_CFLAGS) -O0 -g -Wno-maybe-uninitialized # Build shared object for wrap7 wrap7_SOURCES = wrap7.c diff --git a/memcheck/tests/unit_oset.c b/memcheck/tests/unit_oset.c index 1d2d255610..db9aab6a8b 100644 --- a/memcheck/tests/unit_oset.c +++ b/memcheck/tests/unit_oset.c @@ -92,6 +92,7 @@ void example1singleset(OSet* oset, char *descr) UWord sorted_elts[NN]; // Used to test VG_(OSetGen_ResetIterAt) // Try some operations on an empty OSet to ensure they don't screw up. + v = 0; vg_assert( ! VG_(OSetGen_Contains)(oset, &v) ); vg_assert( ! VG_(OSetGen_Lookup)(oset, &v) ); vg_assert( ! VG_(OSetGen_Remove)(oset, &v) ); diff --git a/memcheck/tests/x86-linux/Makefile.am b/memcheck/tests/x86-linux/Makefile.am index e9fdbac5b3..04c18442ef 100644 --- a/memcheck/tests/x86-linux/Makefile.am +++ b/memcheck/tests/x86-linux/Makefile.am @@ -28,3 +28,4 @@ AM_CFLAGS += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE) AM_CXXFLAGS += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE) AM_CCASFLAGS += @FLAG_M32@ +scalar_supp_CFLAGS = $(AM_CFLAGS) -Wno-uninitialized diff --git a/memcheck/tests/x86/Makefile.am b/memcheck/tests/x86/Makefile.am index 557de6b11a..c8a0cb02fb 100644 --- a/memcheck/tests/x86/Makefile.am +++ b/memcheck/tests/x86/Makefile.am @@ -52,6 +52,7 @@ AM_CCASFLAGS += @FLAG_M32@ # fpeflags must use these flags -- bug only occurred with them. fpeflags_CFLAGS = $(AM_CFLAGS) -march=i686 +pushfpopf_CFLAGS = $(AM_CFLAGS) -Wno-uninitialized pushfpopf_SOURCES = pushfpopf_c.c pushfpopf_s.S if VGCONF_OS_IS_DARWIN pushpopmem_CFLAGS = $(AM_CFLAGS) -mdynamic-no-pic |
|
From: Mark W. <ma...@so...> - 2021-10-10 14:39:12
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7b1a2b1edd99f15e23be0d259498247367f1e457 commit 7b1a2b1edd99f15e23be0d259498247367f1e457 Author: Mark Wielaard <ma...@kl...> Date: Sun Oct 10 16:35:37 2021 +0200 Fix printf warning in libmpiwrap.c libmpiwrap.c:1379:45: warning: format '%d' expects argument of type 'int', but argument 5 has type 'MPI_Request' {aka 'struct ompi_request_t *'} Unfortunately MPI_Request is an opaque type (we don't really know what is in struct ompi_request_t) so we cannot simply print it as int. In other places we print an MPI_Request as 0x%lx by casting it to an unsigned long. Do the same here. Diff: --- mpi/libmpiwrap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mpi/libmpiwrap.c b/mpi/libmpiwrap.c index 1ec0c202ae..b277617854 100644 --- a/mpi/libmpiwrap.c +++ b/mpi/libmpiwrap.c @@ -1376,8 +1376,8 @@ static void maybe_complete ( Bool error_in_status, if (count_from_Status(&recv_count, shadow->datatype, status)) { make_mem_defined_if_addressable(shadow->buf, recv_count, shadow->datatype); if (opt_verbosity > 1) - fprintf(stderr, "%s %5d: sReq- %d (completed)\n", - preamble, my_pid, request_before); + fprintf(stderr, "%s %5d: sReq- 0x%lx (completed)\n", + preamble, my_pid, (unsigned long) request_before); } delete_shadow_Request(request_before); } |
|
From: Mark W. <ma...@so...> - 2021-10-10 14:03:56
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4015813336b620f1642d630963327bf484150648 commit 4015813336b620f1642d630963327bf484150648 Author: Mark Wielaard <ma...@kl...> Date: Sun Oct 10 15:56:50 2021 +0200 Remove some warnings from tests Various tests do things which we want to detect at runtime, like ignoring the result of malloc or doing a deliberate impossibly large allocation or operations that would result in overflowing or truncated strings, that generate a warning from gcc. In once case, mq_setattr called with new and old attrs overlapping, this was explicitly fixed, in others -Wno-foobar was added to silence the warning. This is safe even for older gcc, since a compiler will ignore any -Wno-foobar they don't know about - since they do know they won't warn for foobar. Diff: --- dhat/tests/Makefile.am | 2 ++ massif/tests/Makefile.am | 11 +++++++++++ memcheck/tests/Makefile.am | 9 ++++++++- none/tests/mq.c | 5 +++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dhat/tests/Makefile.am b/dhat/tests/Makefile.am index ce01a742f7..3b0cd3e62a 100644 --- a/dhat/tests/Makefile.am +++ b/dhat/tests/Makefile.am @@ -26,3 +26,5 @@ check_PROGRAMS = \ AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) +# We don't care about unused malloc results +big_CFLAGS = $(AM_CFLAGS) -Wno-unused-result diff --git a/massif/tests/Makefile.am b/massif/tests/Makefile.am index 5b5ee599b3..0ecf09676a 100644 --- a/massif/tests/Makefile.am +++ b/massif/tests/Makefile.am @@ -89,3 +89,14 @@ AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) new_cpp_SOURCES = new-cpp.cpp overloaded_new_SOURCES = overloaded-new.cpp +# Suppress warnings for issues we are testing for +alloc_fns_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +big_alloc_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +culling1_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +culling2_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +deep_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +ignoring_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +insig_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +long_names_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +one_CFLAGS = $(AM_CFLAGS) -Wno-unused-result +thresholds_CFLAGS = $(AM_CFLAGS) -Wno-unused-result diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 3ce33af181..d7759296fc 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -505,6 +505,12 @@ leak_cpp_interior_SOURCES = leak_cpp_interior.cpp demangle_SOURCES = demangle.cpp +# Suppress various gcc warnings which are correct, but for things +# we are actually testing for at runtime. +accounting_CFLAGS = $(AM_CFLAGS) -Wno-alloc-size-larger-than +bug155125_CFLAGS = $(AM_CFLAGS) -Wno-unused-result -Wno-alloc-size-larger-than +malloc3_CFLAGS = $(AM_CFLAGS) -Wno-alloc-size-larger-than + big_debuginfo_symbol_SOURCES = big_debuginfo_symbol.cpp big_debuginfo_symbol_CXXFLAGS = $(AM_CXXFLAGS) -std=c++0x @@ -590,7 +596,8 @@ sized_delete_SOURCES = sized_delete.cpp sized_delete_CXXFLAGS = $(AM_CXXFLAGS) @FLAG_FSIZED_DEALLOCATION@ endif -str_tester_CFLAGS = $(AM_CFLAGS) -Wno-shadow \ +str_tester_CFLAGS = $(AM_CFLAGS) -Wno-shadow -Wno-stringop-overflow \ + -Wno-stringop-truncation \ @FLAG_W_NO_MEMSET_TRANSPOSED_ARGS@ supp_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ diff --git a/none/tests/mq.c b/none/tests/mq.c index 6c1af148ae..72c150d9a5 100644 --- a/none/tests/mq.c +++ b/none/tests/mq.c @@ -15,7 +15,7 @@ int main(int argc, char **argv) { - struct mq_attr mqa; + struct mq_attr mqa, mqa2; mqd_t mqdw; mqd_t mqdr; char buffer[MSGSIZEMAX]; @@ -89,7 +89,8 @@ int main(int argc, char **argv) exit(1); } - if (mq_setattr(mqdw, &mqa, &mqa) < 0) + mqa2 = mqa; + if (mq_setattr(mqdw, &mqa, &mqa2) < 0) { perror("mq_setattr"); mq_close(mqdr); |
|
From: Paul F. <pa...@so...> - 2021-10-10 10:04:34
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=d187106a76381fbca34d57879eb45fc3f88c41d2 commit d187106a76381fbca34d57879eb45fc3f88c41d2 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 10 11:48:50 2021 +0200 Updating a few expecteds based on valgrind-testresults I tried to work out what the expecteds should be based on the changes to the testcase source so there may be a bit more to do. Diff: --- drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 | 4 +-- drd/tests/tc09_bad_unlock.stderr.exp-ppc | 46 +++++++++++++-------------- drd/tests/tc09_bad_unlock.stderr.exp-s390 | 36 ++++++++++----------- drd/tests/tc09_bad_unlock.stderr.exp-solaris | 36 ++++++++++----------- drd/tests/tc09_bad_unlock.stderr.exp-x86 | 46 +++++++++++++-------------- helgrind/tests/bar_bad.stderr.exp | 16 +++++----- memcheck/tests/badjump2.stderr.exp | 2 +- 7 files changed, 93 insertions(+), 93 deletions(-) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 b/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 index 9a6c0474f5..8a60570c5b 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 +++ b/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 @@ -26,7 +26,7 @@ The object at address 0x........ is not a mutex. Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. at 0x........: nearly_main (tc09_bad_unlock.c:48) - by 0x........: main (tc09_bad_unlock.c:52) + by 0x........: (below main) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) by 0x........: nearly_main (tc09_bad_unlock.c:32) @@ -49,7 +49,7 @@ The object at address 0x........ is not a mutex. Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. at 0x........: nearly_main (tc09_bad_unlock.c:48) - by 0x........: main (tc09_bad_unlock.c:53) + by 0x........: (below main) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) by 0x........: nearly_main (tc09_bad_unlock.c:32) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-ppc b/drd/tests/tc09_bad_unlock.stderr.exp-ppc index 0be4db6eac..9a42458da9 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-ppc +++ b/drd/tests/tc09_bad_unlock.stderr.exp-ppc @@ -1,59 +1,59 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:52) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + at 0x........: nearly_main (tc09_bad_unlock.c:44) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) --------------------- Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:53) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + at 0x........: nearly_main (tc09_bad_unlock.c:44) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) ERROR SUMMARY: 8 errors from 7 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-s390 b/drd/tests/tc09_bad_unlock.stderr.exp-s390 index dd84c816e1..6f6493e483 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-s390 +++ b/drd/tests/tc09_bad_unlock.stderr.exp-s390 @@ -1,51 +1,51 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:52) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) + at 0x........: nearly_main (tc09_bad_unlock.c:48) by 0x........: ??? mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) --------------------- Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:53) ERROR SUMMARY: 8 errors from 6 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-solaris b/drd/tests/tc09_bad_unlock.stderr.exp-solaris index a517b71f0f..1a1ef29baa 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-solaris +++ b/drd/tests/tc09_bad_unlock.stderr.exp-solaris @@ -1,54 +1,54 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) + by 0x........: nearly_main (tc09_bad_unlock.c:24) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) + by 0x........: nearly_main (tc09_bad_unlock.c:32) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:5) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: main (tc09_bad_unlock.c:49) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) + by 0x........: nearly_main (tc09_bad_unlock.c:32) --------------------- Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) + by 0x........: nearly_main (tc09_bad_unlock.c:24) The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:53) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: main (tc09_bad_unlock.c:50) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) + by 0x........: nearly_main (tc09_bad_unlock.c:32) ERROR SUMMARY: 8 errors from 7 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc09_bad_unlock.stderr.exp-x86 b/drd/tests/tc09_bad_unlock.stderr.exp-x86 index 7f8e2cc2aa..9a6c0474f5 100644 --- a/drd/tests/tc09_bad_unlock.stderr.exp-x86 +++ b/drd/tests/tc09_bad_unlock.stderr.exp-x86 @@ -1,59 +1,59 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:52) Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: child_fn (tc09_bad_unlock.c:11) + by 0x........: child_fn (tc09_bad_unlock.c:12) by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) Thread 1: The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:52) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: main (tc09_bad_unlock.c:49) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:52) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:49) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:52) --------------------- Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:27) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:28) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:23) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:24) + by 0x........: main (tc09_bad_unlock.c:53) The object at address 0x........ is not a mutex. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:41) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:43) + by 0x........: main (tc09_bad_unlock.c:53) Destroying locked mutex: mutex 0x........, recursion count 1, owner 1. - at 0x........: nearly_main (tc09_bad_unlock.c:45) - by 0x........: main (tc09_bad_unlock.c:50) + at 0x........: nearly_main (tc09_bad_unlock.c:48) + by 0x........: main (tc09_bad_unlock.c:53) mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) - by 0x........: nearly_main (tc09_bad_unlock.c:31) - by 0x........: main (tc09_bad_unlock.c:50) + by 0x........: nearly_main (tc09_bad_unlock.c:32) + by 0x........: main (tc09_bad_unlock.c:53) ERROR SUMMARY: 8 errors from 7 contexts (suppressed: 0 from 0) diff --git a/helgrind/tests/bar_bad.stderr.exp b/helgrind/tests/bar_bad.stderr.exp index a675a18df0..7aa18c047c 100644 --- a/helgrind/tests/bar_bad.stderr.exp +++ b/helgrind/tests/bar_bad.stderr.exp @@ -8,14 +8,14 @@ Thread #x is the program's root thread Thread #x: pthread_barrier_init: 'count' argument is zero at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:43) + by 0x........: main (bar_bad.c:44) ---------------------------------------------------------------- Thread #x's call to pthread_barrier_init failed with error code 22 (EINVAL: Invalid argument) at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:43) + by 0x........: main (bar_bad.c:44) initialise a barrier twice @@ -23,7 +23,7 @@ initialise a barrier twice Thread #x: pthread_barrier_init: barrier is already initialised at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:49) + by 0x........: main (bar_bad.c:50) initialise a barrier which has threads waiting on it @@ -31,13 +31,13 @@ initialise a barrier which has threads waiting on it Thread #x: pthread_barrier_init: barrier is already initialised at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:64) + by 0x........: main (bar_bad.c:65) ---------------------------------------------------------------- Thread #x: pthread_barrier_init: threads are waiting at barrier at 0x........: pthread_barrier_init (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:64) + by 0x........: main (bar_bad.c:65) destroy a barrier that has waiting threads @@ -45,14 +45,14 @@ destroy a barrier that has waiting threads Thread #x: pthread_barrier_destroy: threads are waiting at barrier at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:82) + by 0x........: main (bar_bad.c:83) ---------------------------------------------------------------- Thread #x's call to pthread_barrier_destroy failed with error code 16 (EBUSY: Device or resource busy) at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:82) + by 0x........: main (bar_bad.c:83) destroy a barrier that was never initialised @@ -60,5 +60,5 @@ destroy a barrier that was never initialised Thread #x: pthread_barrier_destroy: barrier was never initialised at 0x........: pthread_barrier_destroy (hg_intercepts.c:...) - by 0x........: main (bar_bad.c:98) + by 0x........: main (bar_bad.c:100) diff --git a/memcheck/tests/badjump2.stderr.exp b/memcheck/tests/badjump2.stderr.exp index 7033e69d7e..78e416bdcd 100644 --- a/memcheck/tests/badjump2.stderr.exp +++ b/memcheck/tests/badjump2.stderr.exp @@ -1,6 +1,6 @@ Jump to the invalid address stated on the next line ... - by 0x........: main (badjump2.c:46) + by 0x........: main (badjump2.c:47) Address 0x........ is not stack'd, malloc'd or (recently) free'd Signal caught, as expected |
|
From: Paul F. <pa...@so...> - 2021-10-09 21:04:00
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=1c57706fbdc7f4ebd866aeade0900f437942f44c commit 1c57706fbdc7f4ebd866aeade0900f437942f44c Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 23:02:28 2021 +0200 Bug 443314 - In the latest GIT version, Valgrind with "--trace-flags" crashes at "al" register Diff: --- NEWS | 2 ++ VEX/priv/guest_amd64_toIR.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index d2455d4472..d8addbb203 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. 443179 Need new test for the lxvx and stxvx instructions on ISA 2.07 and ISA 3.0 systems. 443180 The subnormal test and the ISA 3.0 test generate compiler warnings. +443314 In the latest GIT version, Valgrind with "--trace-flags" crashes at + "al" register To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c index c7f94b15b5..86fe07fdc5 100644 --- a/VEX/priv/guest_amd64_toIR.c +++ b/VEX/priv/guest_amd64_toIR.c @@ -1188,8 +1188,9 @@ static const HChar* nameIRegRexB ( Int sz, Prefix pfx, UInt lo3bits ) vassert(lo3bits < 8); vassert(IS_VALID_PFX(pfx)); vassert(sz == 8 || sz == 4 || sz == 2 || sz == 1); - return nameIReg( sz, lo3bits | (getRexB(pfx) << 3), - toBool(sz==1 && !haveREX(pfx)) ); + UInt regNo = lo3bits | (getRexB(pfx) << 3); + return nameIReg( sz, regNo, + toBool(sz==1 && !haveREX(pfx) && regNo >= 4 && regNo < 8)); } static IRExpr* getIRegRexB ( Int sz, Prefix pfx, UInt lo3bits ) |
|
From: Paul F. <pa...@so...> - 2021-10-09 19:46:10
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=c3002642d35b69f82fb1633ffc874e8ede370d32 commit c3002642d35b69f82fb1633ffc874e8ede370d32 Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 21:25:22 2021 +0200 Bug 439326 - Valgrind 3.17.0 won't compile with Intel 2021 oneAPI compilers Also reorder NEWS Diff: --- NEWS | 25 +++++++++++++------------ configure.ac | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index e5414c02b4..d2455d4472 100644 --- a/NEWS +++ b/NEWS @@ -47,19 +47,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 429375 PPC ISA 3.1 support is missing, part 9 431157 PPC_FEATURE2_SCV needs to be masked in AT_HWCAP2 431306 Update demangler to support Rust v0 name mangling -433801 PPC ISA 3.1 support is missing, part 10 (ISA 3.1 support complete) -433863 s390x: memcheck/tests/s390x/{cds,cs,csg} failures -434840 PPC64 darn instruction not supported -434296 s390x: False-positive memcheck diagnostics from vector string - instructions -435665 PPC ISA 3.0 copy, paste, cpabort instructions are not supported -438871 unhandled instruction bytes: 0xF3 0x49 0xF 0x6F 0x9C 0x24 0x60 0x2 0x0 0x0 -435908 valgrind tries to fetch from deubginfod for files which already - have debug information -439590 glibc-2.34 breaks suppressions against obj:*/lib*/libc-2.*so* -440670 unhandled ppc64le-linux syscall: 252 (statfs64) and 253 (fstatfs64) 432387 s390x: z15 instructions support -439046 valgrind is unusably large when linked with lld 433437 FreeBSD support, part 1 433438 FreeBSD support, part 2 433439 FreeBSD support, part 3 @@ -72,6 +60,19 @@ are not entered into bugzilla tend to get forgotten about or ignored. 433507 FreeBSD support, part 10 433508 FreeBSD support, part 11 433510 FreeBSD support, part 12 +433801 PPC ISA 3.1 support is missing, part 10 (ISA 3.1 support complete) +433863 s390x: memcheck/tests/s390x/{cds,cs,csg} failures +434296 s390x: False-positive memcheck diagnostics from vector string + instructions +434840 PPC64 darn instruction not supported +435665 PPC ISA 3.0 copy, paste, cpabort instructions are not supported +435908 valgrind tries to fetch from deubginfod for files which already + have debug information +438871 unhandled instruction bytes: 0xF3 0x49 0xF 0x6F 0x9C 0x24 0x60 0x2 0x0 0x0 +439046 valgrind is unusably large when linked with lld +439326 Valgrind 3.17.0 won't compile with Intel 2021 oneAPI compilers +439590 glibc-2.34 breaks suppressions against obj:*/lib*/libc-2.*so* +440670 unhandled ppc64le-linux syscall: 252 (statfs64) and 253 (fstatfs64) 440906 Fix impossible constraint issue in P10 testcase. 441512 Remove a unneeded / unnecessary prefix check. 441534 Update the expected output for test_isa_3_1_VRT. diff --git a/configure.ac b/configure.ac index 275c0ca02c..3f51bc5c62 100755 --- a/configure.ac +++ b/configure.ac @@ -175,7 +175,7 @@ case "${is_clang}-${gcc_version}" in applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*) AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})]) ;; - icc-1[[3-9]].*) + icc-1[[3-9]].*|icc-202[[0-9]].*) AC_MSG_RESULT([ok (ICC version ${gcc_version})]) ;; notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*) |
|
From: Paul F. <pa...@so...> - 2021-10-09 13:15:00
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=80459895c4a89c4057cbfccba5c820f64e9dbe23 commit 80459895c4a89c4057cbfccba5c820f64e9dbe23 Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 15:13:50 2021 +0200 FreeBSD support, last loose ends One merge I missed and make a couple of changes to remove compiler warnings. Diff: --- coregrind/Makefile.am | 1 + coregrind/m_coredump/coredump-elf.c | 2 +- coregrind/m_mallocfree.c | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 1de685bb45..76c0aebc9d 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -51,6 +51,7 @@ valgrind_SOURCES = \ endif if VGCONF_OS_IS_FREEBSD valgrind_SOURCES = \ + launcher-freebsd.c \ m_debuglog.c endif diff --git a/coregrind/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c index d0e8a03c94..0d22d01cbb 100644 --- a/coregrind/m_coredump/coredump-elf.c +++ b/coregrind/m_coredump/coredump-elf.c @@ -490,7 +490,7 @@ static void fill_prstatus(const ThreadState *tst, regs[VKI_MIPS32_EF_CP0_EPC] = arch->vex.guest_PC; # undef DO #elif defined(VGP_amd64_freebsd) - regs->rflags = LibVEX_GuestAMD64_get_rflags( &((ThreadArchState*)arch)->vex ); + regs->rflags = LibVEX_GuestAMD64_get_rflags( &arch->vex ); regs->rsp = arch->vex.guest_RSP; regs->rip = arch->vex.guest_RIP; regs->rbx = arch->vex.guest_RBX; diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index 4bc24f91e5..90c7d9aac9 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -1011,6 +1011,14 @@ Superblock* maybe_findSb ( Arena* a, Addr ad ) /*--- Functions for working with freelists. ---*/ /*------------------------------------------------------------*/ +#if defined(__clang__) +/* The nicely aligned 'returns' in the function below produce + * misleading indentation warnings. Rather than turn the + * warning off globally, just turn it off for the block of code. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmisleading-indentation" +#endif + // Nb: Determination of which freelist a block lives on is based on the // payload size, not block size. @@ -1120,6 +1128,10 @@ UInt pszB_to_listNo_SLOW ( SizeT pszB__divided_by__VG_MIN_MALLOC_SZB ) vg_assert(0); } +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + static inline UInt pszB_to_listNo ( SizeT pszB ) { |
|
From: Paul F. <pa...@so...> - 2021-10-09 13:02:01
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=68bb7c063f71631a4f207adca2235eb0f8d00d33 commit 68bb7c063f71631a4f207adca2235eb0f8d00d33 Author: Paul Floyd <pj...@wa...> Date: Sat Oct 9 15:01:08 2021 +0200 FreeBSD support, patch 12 coregrind modified files Diff: --- NEWS | 20 +- coregrind/m_aspacemgr/aspacemgr-common.c | 76 +++++- coregrind/m_aspacemgr/aspacemgr-linux.c | 195 ++++++++++++- coregrind/m_aspacemgr/priv_aspacemgr.h | 2 +- coregrind/m_coredump/coredump-elf.c | 79 +++++- coregrind/m_debuginfo/d3basics.c | 4 +- coregrind/m_debuginfo/debuginfo.c | 19 +- coregrind/m_debuginfo/priv_readpdb.h | 4 +- coregrind/m_debuginfo/readdwarf.c | 8 +- coregrind/m_debuginfo/readdwarf3.c | 4 +- coregrind/m_debuginfo/readelf.c | 116 +++++++- coregrind/m_debuginfo/readpdb.c | 4 +- coregrind/m_debuginfo/storage.c | 7 +- coregrind/m_debuglog.c | 83 ++++++ coregrind/m_gdbserver/gdb/signals.h | 3 + coregrind/m_gdbserver/remote-utils.c | 37 ++- coregrind/m_gdbserver/signals.c | 8 + coregrind/m_libcassert.c | 6 +- coregrind/m_libcfile.c | 141 ++++++++-- coregrind/m_libcprint.c | 2 +- coregrind/m_libcproc.c | 108 +++++++- coregrind/m_libcsetjmp.c | 22 +- coregrind/m_libcsignal.c | 39 ++- coregrind/m_machine.c | 17 +- coregrind/m_main.c | 148 +++++++++- coregrind/m_redir.c | 5 + coregrind/m_replacemalloc/vg_replace_malloc.c | 379 +++++++++++++++++++++++--- coregrind/m_scheduler/scheduler.c | 5 +- coregrind/m_scheduler/sema.c | 4 +- coregrind/m_sigframe/sigframe-common.c | 2 +- coregrind/m_signals.c | 99 ++++++- coregrind/m_stacktrace.c | 35 ++- coregrind/m_syscall.c | 130 +++++++++ coregrind/m_syswrap/priv_types_n_macros.h | 84 +++++- coregrind/m_syswrap/syswrap-generic.c | 73 ++++- coregrind/m_syswrap/syswrap-main.c | 357 +++++++++++++++++++++++- coregrind/m_trampoline.S | 68 +++++ coregrind/m_translate.c | 4 +- coregrind/m_ume/elf.c | 14 +- coregrind/m_ume/main.c | 2 +- coregrind/m_ume/priv_ume.h | 4 +- coregrind/m_vki.c | 4 +- coregrind/m_vkiscnums.c | 11 + coregrind/pub_core_aspacemgr.h | 4 + coregrind/pub_core_debuginfo.h | 2 +- coregrind/pub_core_gdbserver.h | 1 + coregrind/pub_core_initimg.h | 2 +- coregrind/pub_core_libcproc.h | 7 + coregrind/pub_core_machine.h | 4 +- coregrind/pub_core_mallocfree.h | 2 + coregrind/pub_core_sigframe.h | 6 +- coregrind/pub_core_syscall.h | 2 + coregrind/pub_core_syswrap.h | 4 + coregrind/pub_core_trampoline.h | 8 + coregrind/vg_preloaded.c | 6 +- coregrind/vgdb.c | 2 + include/pub_tool_libcproc.h | 2 +- 57 files changed, 2270 insertions(+), 214 deletions(-) diff --git a/NEWS b/NEWS index 68315a77ad..e5414c02b4 100644 --- a/NEWS +++ b/NEWS @@ -4,8 +4,9 @@ Release 3.??.? (?? 2021) This release supports X86/Linux, AMD64/Linux, ARM32/Linux, ARM64/Linux, PPC32/Linux, PPC64BE/Linux, PPC64LE/Linux, S390X/Linux, MIPS32/Linux, MIPS64/Linux, ARM/Android, ARM64/Android, MIPS32/Android, X86/Android, -X86/Solaris, AMD64/Solaris and AMD64/MacOSX 10.12. There is also preliminary -support for X86/macOS 10.13, AMD64/macOS 10.13 and nanoMIPS/Linux. +X86/Solaris, AMD64/Solaris, AMD64/MacOSX 10.12, X86/FreeBSD and +AMD64/FreeBSD. There is also preliminary support for X86/macOS 10.13, +AMD64/macOS 10.13 and nanoMIPS/Linux. * ==================== CORE CHANGES =================== @@ -25,6 +26,8 @@ support for X86/macOS 10.13, AMD64/macOS 10.13 and nanoMIPS/Linux. - ISA 3.0 support for the darn instruction added. - ISA 3.0 support for the vector system call instruction scv added. - ISA 3.0 support for the copy, paste and cpabort instructions added. + +* Support for X86/FreeBSD and AMD64/FreeBSD has been added. * ==================== TOOL CHANGES ==================== @@ -56,6 +59,19 @@ are not entered into bugzilla tend to get forgotten about or ignored. 439590 glibc-2.34 breaks suppressions against obj:*/lib*/libc-2.*so* 440670 unhandled ppc64le-linux syscall: 252 (statfs64) and 253 (fstatfs64) 432387 s390x: z15 instructions support +439046 valgrind is unusably large when linked with lld +433437 FreeBSD support, part 1 +433438 FreeBSD support, part 2 +433439 FreeBSD support, part 3 +433469 FreeBSD support, part 4 +433473 FreeBSD support, part 5 +433477 FreeBSD support, part 6 +433479 FreeBSD support, part 7 +433504 FreeBSD support, part 8 +433506 FreeBSD support, part 9 +433507 FreeBSD support, part 10 +433508 FreeBSD support, part 11 +433510 FreeBSD support, part 12 440906 Fix impossible constraint issue in P10 testcase. 441512 Remove a unneeded / unnecessary prefix check. 441534 Update the expected output for test_isa_3_1_VRT. diff --git a/coregrind/m_aspacemgr/aspacemgr-common.c b/coregrind/m_aspacemgr/aspacemgr-common.c index 214b54a35e..6814410c09 100644 --- a/coregrind/m_aspacemgr/aspacemgr-common.c +++ b/coregrind/m_aspacemgr/aspacemgr-common.c @@ -35,6 +35,7 @@ ************************************************************* */ #include "priv_aspacemgr.h" +#include "pub_core_libcassert.h" #include "config.h" @@ -171,6 +172,16 @@ SysRes VG_(am_do_mmap_NO_NOTIFY)( Addr start, SizeT length, UInt prot, } res = VG_(do_syscall6)(__NR_mmap, (UWord)start, length, prot, flags, (UInt)fd, offset); +# elif defined(VGP_x86_freebsd) + if (flags & VKI_MAP_ANONYMOUS && fd == 0) + fd = -1; + res = VG_(do_syscall7)(__NR_mmap, (UWord)start, length, + prot, flags, fd, offset, offset >> 32ul); +# elif defined(VGP_amd64_freebsd) + if ((flags & VKI_MAP_ANONYMOUS) && fd == 0) + fd = -1; + res = VG_(do_syscall6)(__NR_mmap, (UWord)start, length, + prot, flags, fd, offset); # elif defined(VGP_x86_solaris) /* MAP_ANON with fd==0 is EINVAL. */ if (fd == 0 && (flags & VKI_MAP_ANONYMOUS)) @@ -255,7 +266,7 @@ SysRes ML_(am_open) ( const HChar* pathname, Int flags, Int mode ) /* ARM64 wants to use __NR_openat rather than __NR_open. */ SysRes res = VG_(do_syscall4)(__NR_openat, VKI_AT_FDCWD, (UWord)pathname, flags, mode); -# elif defined(VGO_linux) || defined(VGO_darwin) +# elif defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) SysRes res = VG_(do_syscall3)(__NR_open, (UWord)pathname, flags, mode); # elif defined(VGO_solaris) SysRes res = VG_(do_syscall4)(__NR_openat, VKI_AT_FDCWD, (UWord)pathname, @@ -283,7 +294,7 @@ Int ML_(am_readlink)(const HChar* path, HChar* buf, UInt bufsiz) # if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path, (UWord)buf, bufsiz); -# elif defined(VGO_linux) || defined(VGO_darwin) +# elif defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) res = VG_(do_syscall3)(__NR_readlink, (UWord)path, (UWord)buf, bufsiz); # elif defined(VGO_solaris) res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path, @@ -296,7 +307,7 @@ Int ML_(am_readlink)(const HChar* path, HChar* buf, UInt bufsiz) Int ML_(am_fcntl) ( Int fd, Int cmd, Addr arg ) { -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # if defined(VGP_nanomips_linux) SysRes res = VG_(do_syscall3)(__NR_fcntl64, fd, cmd, arg); # else @@ -330,7 +341,8 @@ Bool ML_(am_get_fd_d_i_m)( Int fd, *mode = (UInt)bufx.stx_mode; return True; } -# endif +# endif // VGO_linux only + # if defined(VGO_linux) && defined(__NR_fstat64) /* fstat64 is second candidate as it can cope with minor and major device numbers outside the 0-255 range and it works properly for x86 @@ -343,7 +355,8 @@ Bool ML_(am_get_fd_d_i_m)( Int fd, *mode = (UInt) buf64.st_mode; return True; } -# endif +# endif // VGO_linux and defined __NR_fstat64 + # if defined(__NR_fstat) struct vki_stat buf; res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf); @@ -353,7 +366,7 @@ Bool ML_(am_get_fd_d_i_m)( Int fd, *mode = (UInt) buf.st_mode; return True; } -# endif +# endif // defined __NR_fstat return False; # elif defined(VGO_solaris) # if defined(VGP_x86_solaris) @@ -372,11 +385,30 @@ Bool ML_(am_get_fd_d_i_m)( Int fd, return True; } return False; +# elif defined(VGO_freebsd) + struct vki_freebsd11_stat buf; +#if (FREEBSD_VERS >= FREEBSD_12) + SysRes res = VG_(do_syscall2)(__NR_freebsd11_fstat, fd, (UWord)&buf); +#else + SysRes res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf); +#endif + if (!sr_isError(res)) { + *dev = (ULong)buf.st_dev; + *ino = (ULong)buf.st_ino; + *mode = (UInt) buf.st_mode; + return True; + } + return False; # else # error Unknown OS # endif } +#if defined(VGO_freebsd) +#define M_FILEDESC_BUF 1000000 +static Char filedesc_buf[M_FILEDESC_BUF]; +#endif + Bool ML_(am_resolve_filename) ( Int fd, /*OUT*/HChar* buf, Int nbuf ) { #if defined(VGO_linux) @@ -389,6 +421,38 @@ Bool ML_(am_resolve_filename) ( Int fd, /*OUT*/HChar* buf, Int nbuf ) else return False; +#elif defined(VGO_freebsd) + Int mib[4]; + SysRes sres; + vki_size_t len; + Char *bp, *eb; + struct vki_kinfo_file *kf; + + mib[0] = VKI_CTL_KERN; + mib[1] = VKI_KERN_PROC; + mib[2] = VKI_KERN_PROC_FILEDESC; + mib[3] = sr_Res(VG_(do_syscall0)(__NR_getpid)); + len = sizeof(filedesc_buf); + sres = VG_(do_syscall6)(__NR___sysctl, (UWord)mib, 4, (UWord)filedesc_buf, + (UWord)&len, 0, 0); + if (sr_isError(sres)) { + VG_(debugLog)(0, "sysctl(kern.proc.filedesc)", "%s\n", VG_(strerror)(sr_Err(sres))); + ML_(am_exit)(1); + } + /* Walk though the list. */ + bp = filedesc_buf; + eb = filedesc_buf + len; + while (bp < eb) { + kf = (struct vki_kinfo_file *)bp; + if (kf->kf_fd == fd) + break; + bp += kf->kf_structsize; + } + if (bp >= eb || *kf->kf_path == '\0') + VG_(strncpy)( buf, "[unknown]", nbuf ); + else + VG_(strncpy)( buf, kf->kf_path, nbuf ); + return True; #elif defined(VGO_darwin) HChar tmp[VKI_MAXPATHLEN+1]; if (0 == ML_(am_fcntl)(fd, VKI_F_GETPATH, (UWord)tmp)) { diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c index 0eb3143161..9a69f3850f 100644 --- a/coregrind/m_aspacemgr/aspacemgr-linux.c +++ b/coregrind/m_aspacemgr/aspacemgr-linux.c @@ -4,7 +4,7 @@ /*--- The address space manager: segment initialisation and ---*/ /*--- tracking, stack operations ---*/ /*--- ---*/ -/*--- Implementation for Linux (and Darwin!) aspacemgr-linux.c ---*/ +/*--- Implementation for Linux, Darwin, Solaris and FreeBSD ---*/ /*--------------------------------------------------------------------*/ /* @@ -30,7 +30,7 @@ The GNU General Public License is contained in the file COPYING. */ -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /* ************************************************************* DO NOT INCLUDE ANY OTHER FILES HERE. @@ -314,6 +314,8 @@ Addr VG_(clo_aspacem_minAddr) # endif #elif defined(VGO_solaris) = (Addr) 0x00100000; // 1MB +#elif defined(VGO_freebsd) + = (Addr) 0x04000000; // 64M #else #endif @@ -367,7 +369,12 @@ static void parse_procselfmaps ( # define ARM_LINUX_FAKE_COMMPAGE_END1 0xFFFF1000 #endif - +#if !defined(VKI_MAP_STACK) +/* this is only defined for FreeBSD + * for readability, define it to 0 + * for other platforms */ +#define VKI_MAP_STACK 0 +#endif /*-----------------------------------------------------------------*/ /*--- ---*/ @@ -871,7 +878,7 @@ static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot, cmp_devino = False; #endif -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // GrP fixme kernel info doesn't have dev/inode cmp_devino = False; @@ -1491,7 +1498,13 @@ static void init_nsegment ( /*OUT*/NSegment* seg ) seg->mode = 0; seg->offset = 0; seg->fnIdx = -1; - seg->hasR = seg->hasW = seg->hasX = seg->hasT = seg->isCH = False; + + seg->hasR = seg->hasW = seg->hasX = seg->hasT + = seg->isCH = False; +#if defined(VGO_freebsd) + seg->isFF = False; +#endif + } /* Make an NSegment which holds a reservation. */ @@ -1637,6 +1650,81 @@ Addr VG_(am_startup) ( Addr sp_at_startup ) suggested_clstack_end = -1; // ignored; Mach-O specifies its stack + // --- Freebsd ------------------------------------------ +#elif defined(VGO_freebsd) + + + VG_(debugLog)(2, "aspacem", + " sp_at_startup = 0x%010lx (supplied)\n", + sp_at_startup ); + +# if VG_WORDSIZE == 4 + + aspacem_maxAddr = VG_PGROUNDDN( sp_at_startup ) - 1; +# else + aspacem_maxAddr = (Addr) (Addr)0x800000000UL - 1; // 32G +# ifdef ENABLE_INNER + { Addr cse = VG_PGROUNDDN( sp_at_startup ) - 1; + if (aspacem_maxAddr > cse) + aspacem_maxAddr = cse; + } +# endif // ENABLE_INNER +# endif + + aspacem_cStart = aspacem_minAddr; + aspacem_vStart = VG_PGROUNDUP((aspacem_minAddr + aspacem_maxAddr + 1) / 2); + +# ifdef ENABLE_INNER + aspacem_vStart -= 0x10000000UL; // 512M +# endif // ENABLE_INNER + + // starting with FreeBSD 10.4, the stack is created with a zone + // that is marked MAP_GUARD. This zone is reserved but unmapped, + // and fills the space up to the end of the segment + // see man mmap + + // Version number from + // https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions-10.html + + // On x86 this is 0x3FE0000 + // And on amd64 it is 0x1FFE0000 (536739840) + // There is less of an issue on amd64 as we just choose some arbitrary address rather then trying + // to squeeze in just below the host stack + + // Some of this is in sys/vm/vm_map.c, for instance vm_map_stack and vm_map_stack_locked + // These refer to the kernel global sgrowsiz, which seems to be the initial size + // of the user stack, 128k on my system + // + // This seems to be in the sysctl kern.sgrowsiz + // Then there is kern.maxssiz which is the total stack size (grow size + guard area) + // In other words guard area = maxssiz - sgrowsiz + +#if (__FreeBSD_version >= 1003516) + +#if 0 + // this block implements what is described above + // this makes no changes to the regression tests + // I'm keeping it for a rainy day. + // note this needs + // #include "pub_core_libcproc.h" + SizeT kern_maxssiz; + SizeT kern_sgrowsiz; + SizeT sysctl_size = sizeof(SizeT); + VG_(sysctlbyname)("kern.maxssiz", &kern_maxssiz, &sysctl_size, NULL, 0); + VG_(sysctlbyname)("kern.sgrowsiz", &kern_sgrowsiz, &sysctl_size, NULL, 0); + + suggested_clstack_end = aspacem_maxAddr - (kern_maxssiz - kern_sgrowsiz) + VKI_PAGE_SIZE; +#endif + + suggested_clstack_end = aspacem_maxAddr - 64*1024*1024UL + + VKI_PAGE_SIZE; + +#else + suggested_clstack_end = aspacem_maxAddr - 16*1024*1024UL + + VKI_PAGE_SIZE; + +#endif + // --- Solaris ------------------------------------------ #elif defined(VGO_solaris) # if VG_WORDSIZE == 4 @@ -1759,7 +1847,7 @@ Addr VG_(am_startup) ( Addr sp_at_startup ) suggested_clstack_end = aspacem_maxAddr - 16*1024*1024ULL + VKI_PAGE_SIZE; -#endif +#endif /* #else of 'defined(VGO_solaris)' */ // --- (end) -------------------------------------------- aspacem_assert(VG_IS_PAGE_ALIGNED(aspacem_minAddr)); @@ -2165,13 +2253,13 @@ VG_(am_notify_client_mmap)( Addr a, SizeT len, UInt prot, UInt flags, needDiscard = any_Ts_in_range( a, len ); init_nsegment( &seg ); - seg.kind = (flags & VKI_MAP_ANONYMOUS) ? SkAnonC : SkFileC; + seg.kind = (flags & (VKI_MAP_ANONYMOUS | VKI_MAP_STACK)) ? SkAnonC : SkFileC; seg.start = a; seg.end = a + len - 1; seg.hasR = toBool(prot & VKI_PROT_READ); seg.hasW = toBool(prot & VKI_PROT_WRITE); seg.hasX = toBool(prot & VKI_PROT_EXEC); - if (!(flags & VKI_MAP_ANONYMOUS)) { + if (!(flags & (VKI_MAP_ANONYMOUS | VKI_MAP_STACK))) { // Nb: We ignore offset requests in anonymous mmaps (see bug #126722) seg.offset = offset; if (ML_(am_get_fd_d_i_m)(fd, &dev, &ino, &mode)) { @@ -2182,6 +2270,9 @@ VG_(am_notify_client_mmap)( Addr a, SizeT len, UInt prot, UInt flags, if (ML_(am_resolve_filename)(fd, buf, VKI_PATH_MAX)) { seg.fnIdx = ML_(am_allocate_segname)( buf ); } +#if defined(VGO_freebsd) + seg.isFF = (flags & VKI_MAP_FIXED); +#endif } add_segment( &seg ); AM_SANITY_CHECK; @@ -2423,6 +2514,9 @@ SysRes VG_(am_mmap_named_file_fixed_client_flags) } else if (ML_(am_resolve_filename)(fd, buf, VKI_PATH_MAX)) { seg.fnIdx = ML_(am_allocate_segname)( buf ); } +#if defined(VGO_freebsd) + seg.isFF = (flags & VKI_MAP_FIXED); +#endif add_segment( &seg ); AM_SANITY_CHECK; @@ -2733,6 +2827,9 @@ static SysRes VG_(am_mmap_file_float_valgrind_flags) ( SizeT length, UInt prot, if (ML_(am_resolve_filename)(fd, buf, VKI_PATH_MAX)) { seg.fnIdx = ML_(am_allocate_segname)( buf ); } +#if defined(VGO_freebsd) + seg.isFF = (flags & VKI_MAP_FIXED); +#endif add_segment( &seg ); AM_SANITY_CHECK; @@ -3796,13 +3893,89 @@ Bool VG_(get_changed_segments)( return !css_overflowed; } -#endif // defined(VGO_darwin) /*------END-procmaps-parser-for-Darwin---------------------------*/ +/*------BEGIN-procmaps-parser-for-Freebsd------------------------*/ +#elif defined(VGO_freebsd) + +/* Size of a smallish table used to read /proc/self/map entries. */ +#define M_PROCMAP_BUF 10485760 /* 10M */ + +/* static ... to keep it out of the stack frame. */ +static char procmap_buf[M_PROCMAP_BUF]; + +static void parse_procselfmaps ( + void (*record_mapping)( Addr addr, SizeT len, UInt prot, + ULong dev, ULong ino, Off64T offset, + const HChar* filename ), + void (*record_gap)( Addr addr, SizeT len ) + ) +{ + Addr start, endPlusOne, gapStart; + char* filename; + char *p; + UInt prot; + ULong foffset, dev, ino; + struct vki_kinfo_vmentry *kve; + vki_size_t len; + Int oid[4]; + SysRes sres; + + foffset = ino = 0; /* keep gcc-4.1.0 happy */ + + oid[0] = VKI_CTL_KERN; + oid[1] = VKI_KERN_PROC; + oid[2] = VKI_KERN_PROC_VMMAP; + oid[3] = sr_Res(VG_(do_syscall0)(__NR_getpid)); + len = sizeof(procmap_buf); + + sres = VG_(do_syscall6)(__NR___sysctl, (UWord)oid, 4, (UWord)procmap_buf, + (UWord)&len, 0, 0); + if (sr_isError(sres)) { + VG_(debugLog)(0, "procselfmaps", "sysctl %lu\n", sr_Err(sres)); + ML_(am_exit)(1); + } + gapStart = Addr_MIN; + p = procmap_buf; + while (p < (char *)procmap_buf + len) { + kve = (struct vki_kinfo_vmentry *)p; + start = (UWord)kve->kve_start; + endPlusOne = (UWord)kve->kve_end; + foffset = kve->kve_offset; + filename = kve->kve_path; + dev = kve->kve_fsid; + ino = kve->kve_fileid; + if (filename[0] != '/') { + filename = NULL; + foffset = 0; + } + + prot = 0; + if (kve->kve_protection & VKI_KVME_PROT_READ) prot |= VKI_PROT_READ; + if (kve->kve_protection & VKI_KVME_PROT_WRITE) prot |= VKI_PROT_WRITE; + if (kve->kve_protection & VKI_KVME_PROT_EXEC) prot |= VKI_PROT_EXEC; + + if (record_gap && gapStart < start) + (*record_gap) ( gapStart, start-gapStart ); + + if (record_mapping && start < endPlusOne) + (*record_mapping) ( start, endPlusOne-start, + prot, dev, ino, + foffset, filename ); + gapStart = endPlusOne; + p += kve->kve_structsize; + } + + if (record_gap && gapStart < Addr_MAX) + (*record_gap) ( gapStart, Addr_MAX - gapStart + 1 ); +} + +/*------END-procmaps-parser-for-Freebsd--------------------------*/ + /*------BEGIN-procmaps-parser-for-Solaris------------------------*/ -#if defined(VGO_solaris) +#elif defined(VGO_solaris) /* Note: /proc/self/xmap contains extended information about already materialized mappings whereas /proc/self/rmap contains information about @@ -4112,7 +4285,7 @@ Bool VG_(am_search_for_new_segment)(Addr *addr, SizeT *size, UInt *prot) /*------END-procmaps-parser-for-Solaris--------------------------*/ -#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_aspacemgr/priv_aspacemgr.h b/coregrind/m_aspacemgr/priv_aspacemgr.h index fbc46aca7b..161c5c2954 100644 --- a/coregrind/m_aspacemgr/priv_aspacemgr.h +++ b/coregrind/m_aspacemgr/priv_aspacemgr.h @@ -77,7 +77,7 @@ extern void ML_(am_assert_fail) ( const HChar* expr, const HChar* fn ); #define aspacem_assert(expr) \ - ((void) (LIKELY(expr) ? 0 : \ + ((void) (LIKELY(expr) ? (void)0 : \ (ML_(am_assert_fail)(#expr, \ __FILE__, __LINE__, \ __PRETTY_FUNCTION__)))) diff --git a/coregrind/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c index daf85e6479..d0e8a03c94 100644 --- a/coregrind/m_coredump/coredump-elf.c +++ b/coregrind/m_coredump/coredump-elf.c @@ -26,7 +26,7 @@ The GNU General Public License is contained in the file COPYING. */ -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) #include "pub_core_basics.h" #include "pub_core_vki.h" @@ -90,6 +90,9 @@ static void fill_ehdr(ESZ(Ehdr) *ehdr, Int num_phdrs) ehdr->e_ident[EI_CLASS] = VG_ELF_CLASS; ehdr->e_ident[EI_DATA] = VG_ELF_DATA2XXX; ehdr->e_ident[EI_VERSION] = EV_CURRENT; +#if defined(VGO_freebsd) + ehdr->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; +#endif ehdr->e_type = ET_CORE; ehdr->e_machine = VG_ELF_MACHINE; @@ -193,6 +196,19 @@ static void write_note(Int fd, const struct note *n) VG_(write)(fd, &n->note, note_size(n)); } +#if defined(VGO_freebsd) +static void fill_prpsinfo(const ThreadState *tst, + struct vki_elf_prpsinfo *prpsinfo) +{ + VG_(memset)(prpsinfo, 0, sizeof(*prpsinfo)); + + prpsinfo->pr_version = VKI_PRPSINFO_VERSION; + prpsinfo->pr_psinfosz = sizeof(struct vki_elf_prpsinfo); + VG_(client_fname)(prpsinfo->pr_fname, sizeof(prpsinfo->pr_fname), False); + // why? + VG_(strncpy)(prpsinfo->pr_psargs, prpsinfo->pr_fname, sizeof(prpsinfo->pr_psargs) - 1); +} +#else static void fill_prpsinfo(const ThreadState *tst, struct vki_elf_prpsinfo *prpsinfo) { @@ -223,6 +239,7 @@ static void fill_prpsinfo(const ThreadState *tst, VG_(client_fname)(prpsinfo->pr_fname, sizeof(prpsinfo->pr_fname), False); } +#endif static void fill_prstatus(const ThreadState *tst, /*OUT*/struct vki_elf_prstatus *prs, @@ -238,6 +255,16 @@ static void fill_prstatus(const ThreadState *tst, VG_(memset)(prs, 0, sizeof(*prs)); +#if defined(VGO_freebsd) + prs->pr_version = VKI_PRSTATUS_VERSION; + prs->pr_statussz = sizeof(struct vki_elf_prstatus); + prs->pr_gregsetsz = sizeof(vki_elf_gregset_t); + prs->pr_fpregsetsz = sizeof(vki_elf_fpregset_t); + prs->pr_osreldate = VG_(getosreldate)(); + + prs->pr_cursig = si->si_signo; + prs->pr_pid = tst->os_state.lwpid; +#else prs->pr_info.si_signo = si->si_signo; prs->pr_info.si_code = si->si_code; prs->pr_info.si_errno = 0; @@ -248,6 +275,7 @@ static void fill_prstatus(const ThreadState *tst, prs->pr_ppid = 0; prs->pr_pgrp = VG_(getpgrp)(); prs->pr_sid = VG_(getpgrp)(); +#endif #if defined(VGP_s390x_linux) /* prs->pr_reg has struct type. Need to take address. */ @@ -461,6 +489,45 @@ static void fill_prstatus(const ThreadState *tst, regs[VKI_MIPS32_EF_CP0_STATUS] = arch->vex.guest_CP0_status; regs[VKI_MIPS32_EF_CP0_EPC] = arch->vex.guest_PC; # undef DO +#elif defined(VGP_amd64_freebsd) + regs->rflags = LibVEX_GuestAMD64_get_rflags( &((ThreadArchState*)arch)->vex ); + regs->rsp = arch->vex.guest_RSP; + regs->rip = arch->vex.guest_RIP; + regs->rbx = arch->vex.guest_RBX; + regs->rcx = arch->vex.guest_RCX; + regs->rdx = arch->vex.guest_RDX; + regs->rsi = arch->vex.guest_RSI; + regs->rdi = arch->vex.guest_RDI; + regs->rbp = arch->vex.guest_RBP; + regs->rax = arch->vex.guest_RAX; + regs->r8 = arch->vex.guest_R8; + regs->r9 = arch->vex.guest_R9; + regs->r10 = arch->vex.guest_R10; + regs->r11 = arch->vex.guest_R11; + regs->r12 = arch->vex.guest_R12; + regs->r13 = arch->vex.guest_R13; + regs->r14 = arch->vex.guest_R14; + regs->r15 = arch->vex.guest_R15; +#elif defined(VGP_x86_freebsd) + regs->eflags = LibVEX_GuestX86_get_eflags( &arch->vex ); + regs->esp = arch->vex.guest_ESP; + regs->eip = arch->vex.guest_EIP; + + regs->ebx = arch->vex.guest_EBX; + regs->ecx = arch->vex.guest_ECX; + regs->edx = arch->vex.guest_EDX; + regs->esi = arch->vex.guest_ESI; + regs->edi = arch->vex.guest_EDI; + regs->ebp = arch->vex.guest_EBP; + regs->eax = arch->vex.guest_EAX; + + regs->cs = arch->vex.guest_CS; + regs->ds = arch->vex.guest_DS; + regs->ss = arch->vex.guest_SS; + regs->es = arch->vex.guest_ES; + regs->fs = arch->vex.guest_FS; + regs->gs = arch->vex.guest_GS; + #else # error Unknown ELF platform #endif @@ -587,6 +654,16 @@ static void fill_fpu(const ThreadState *tst, vki_elf_fpregset_t *fpu) # undef DO #elif defined(VGP_nanomips_linux) +#elif defined(VGP_x86_freebsd) + +#elif defined(VGP_amd64_freebsd) + +# define DO(n) VG_(memcpy)(fpu->xmm_space + n * 4, \ + &arch->vex.guest_YMM##n[0], 16) + DO(0); DO(1); DO(2); DO(3); DO(4); DO(5); DO(6); DO(7); + DO(8); DO(9); DO(10); DO(11); DO(12); DO(13); DO(14); DO(15); +# undef DO + #else # error Unknown ELF platform #endif diff --git a/coregrind/m_debuginfo/d3basics.c b/coregrind/m_debuginfo/d3basics.c index 1bc5f8f052..555e1e00d0 100644 --- a/coregrind/m_debuginfo/d3basics.c +++ b/coregrind/m_debuginfo/d3basics.c @@ -498,11 +498,11 @@ static Bool get_Dwarf_Reg( /*OUT*/Addr* a, Word regno, const RegSummary* regs ) { vg_assert(regs); # if defined(VGP_x86_linux) || defined(VGP_x86_darwin) \ - || defined(VGP_x86_solaris) + || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) if (regno == 5/*EBP*/) { *a = regs->fp; return True; } if (regno == 4/*ESP*/) { *a = regs->sp; return True; } # elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) \ - || defined(VGP_amd64_solaris) + || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) if (regno == 6/*RBP*/) { *a = regs->fp; return True; } if (regno == 7/*RSP*/) { *a = regs->sp; return True; } # elif defined(VGP_ppc32_linux) diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index e2218f2668..2e5b9b0192 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -57,7 +57,7 @@ #include "priv_tytypes.h" #include "priv_storage.h" #include "priv_readdwarf.h" -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # include "priv_readelf.h" # include "priv_readdwarf3.h" # include "priv_readpdb.h" @@ -814,7 +814,7 @@ void VG_(di_initialise) ( void ) /*--- ---*/ /*--------------------------------------------------------------*/ -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /* Helper (indirect) for di_notify_ACHIEVE_ACCEPT_STATE */ static Bool overlaps_DebugInfoMappings ( const DebugInfoMapping* map1, @@ -965,7 +965,7 @@ static ULong di_notify_ACHIEVE_ACCEPT_STATE ( struct _DebugInfo* di ) truncate_DebugInfoMapping_overlaps( di, di->fsm.maps ); /* And acquire new info. */ -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) ok = ML_(read_elf_debug_info)( di ); # elif defined(VGO_darwin) ok = ML_(read_macho_debug_info)( di ); @@ -1204,6 +1204,13 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) if (!(is_rx_map || is_rw_map || is_ro_map)) return 0; +#if defined(VGO_freebsd) + /* Ignore non-fixed read-only mappings. The dynamic linker may be + * mapping something for its own transient purposes. */ + if (!seg->isFF && is_ro_map) + return 0; +#endif + /* Peer at the first few bytes of the file, to see if it is an ELF */ /* object file. Ignore the file if we do not have read permission. */ VG_(memset)(buf1k, 0, sizeof(buf1k)); @@ -1247,7 +1254,7 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) vg_assert(sr_Res(preadres) > 0 && sr_Res(preadres) <= sizeof(buf1k) ); /* We're only interested in mappings of object files. */ -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) if (!ML_(is_elf_object_file)( buf1k, (SizeT)sr_Res(preadres), False )) return 0; # elif defined(VGO_darwin) @@ -1696,7 +1703,7 @@ void VG_(di_notify_pdb_debuginfo)( Int fd_obj, Addr avma_obj, if (pdbname) ML_(dinfo_free)(pdbname); } -#endif /* defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) */ +#endif /* defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) */ /*------------------------------------------------------------*/ @@ -2290,6 +2297,8 @@ Vg_FnNameKind VG_(get_fnname_kind) ( const HChar* name ) VG_STREQ("generic_start_main", name) || // Yellow Dog doggedness VG_STREQN(19, "generic_start_main.", name) || // gcc optimization VG_STREQ("_start", name) || +# elif defined(VGO_freebsd) + VG_STREQ("_start", name) || // FreeBSD libc # elif defined(VGO_darwin) // See readmacho.c for an explanation of this. VG_STREQ("start_according_to_valgrind", name) || // Darwin, darling diff --git a/coregrind/m_debuginfo/priv_readpdb.h b/coregrind/m_debuginfo/priv_readpdb.h index b8f5958103..b9b8fb3a2c 100644 --- a/coregrind/m_debuginfo/priv_readpdb.h +++ b/coregrind/m_debuginfo/priv_readpdb.h @@ -30,7 +30,7 @@ The GNU General Public License is contained in the file COPYING. */ -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) #ifndef __PRIV_READPDB_H #define __PRIV_READPDB_H @@ -57,7 +57,7 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename ); #endif /* ndef __PRIV_READPDB_H */ -#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c index bcacca4cb9..39a2946870 100644 --- a/coregrind/m_debuginfo/readdwarf.c +++ b/coregrind/m_debuginfo/readdwarf.c @@ -27,7 +27,7 @@ The GNU General Public License is contained in the file COPYING. */ -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) #include "pub_core_basics.h" #include "pub_core_debuginfo.h" @@ -1961,11 +1961,11 @@ void ML_(read_debuginfo_dwarf1) ( /* --------------- Decls --------------- */ -#if defined(VGP_x86_linux) || defined(VGP_x86_solaris) +#if defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) # define FP_REG 5 # define SP_REG 4 # define RA_REG_DEFAULT 8 -#elif defined(VGP_amd64_linux) || defined(VGP_amd64_solaris) +#elif defined(VGP_amd64_linux) || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) # define FP_REG 6 # define SP_REG 7 # define RA_REG_DEFAULT 16 @@ -4522,7 +4522,7 @@ void ML_(read_callframe_info_dwarf3) return; } -#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 4ac23a3c4d..18eecea9f3 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -33,7 +33,7 @@ without prior written permission. */ -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /* REFERENCE (without which this code will not make much sense): @@ -5879,7 +5879,7 @@ ML_(new_dwarf3_reader) ( TRACE_SYMTAB("\n"); #endif -#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index e424e3e7e8..c586e3f332 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -27,7 +27,7 @@ The GNU General Public License is contained in the file COPYING. */ -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) #include "pub_core_basics.h" #include "pub_core_vki.h" @@ -45,6 +45,7 @@ #include "pub_core_syscall.h" #include "pub_core_tooliface.h" /* VG_(needs) */ #include "pub_core_xarray.h" +#include "pub_core_libcproc.h" #include "priv_misc.h" /* dinfo_zalloc/free/strdup */ #include "priv_image.h" #include "priv_d3basics.h" @@ -1118,6 +1119,80 @@ void read_elf_symtab__ppc64be_linux( VG_(OSetGen_Destroy)( oset ); } +#if defined(VGO_freebsd) + +/** + * read_and_set_osrel + * + * "osrel" is in an Elf note. It has values such as 1201000 for FreeBSD 12.1 + * Some of the behaviour related to SIGSEGV and SIGBUS signals depends on the + * kernel reading this value. + * + * However in the case of Valgrind, the host is strictly statically linked and + * does not contain the NT_FREEBSD_ABI_TAG note. And even if it did, we want to + * override the value with that of the guest. + * + * At some later date we might want to look at the value of "fctl0" (note with the + * NT_FREEBSD_FEATURE_CTL type). This seems to be related to Address Space Layout + * Randomization. No hurry at the moment. + * + * See /usr/src/sys/kern/imgact_elf.c for details on how the kernel reads these + * notes. + */ +static +void read_and_set_osrel(DiImage* img) +{ + if (is_elf_object_file_by_DiImage(img, False)) { + Word i; + + ElfXX_Ehdr ehdr; + ML_(img_get)(&ehdr, img, 0, sizeof(ehdr)); + /* Skip the phdrs when we have to search the shdrs. In separate + .debug files the phdrs might not be valid (they are a copy of + the main ELF file) and might trigger assertions when getting + image notes based on them. */ + for (i = 0; i < ehdr.e_phnum; i++) { + ElfXX_Phdr phdr; + ML_(img_get)(&phdr, img, + ehdr.e_phoff + i * ehdr.e_phentsize, sizeof(phdr)); + + if (phdr.p_type == PT_NOTE) { + ElfXX_Off note_ioff = phdr.p_offset; + + while (note_ioff < phdr.p_offset + phdr.p_filesz) { + ElfXX_Nhdr note[2]; + ML_(img_get)(note, img, (DiOffT)note_ioff, sizeof(note)); + DiOffT name_ioff = note_ioff + sizeof(ElfXX_Nhdr); + //DiOffT desc_ioff = name_ioff + ((note[0].n_namesz + 3) & ~3); + if (ML_(img_strcmp_c)(img, name_ioff, "FreeBSD") == 0 + && note[0].n_type == NT_FREEBSD_ABI_TAG) { + + u_int32_t osrel = note[1].n_type; + int name[4]; + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = KERN_PROC_OSREL; + name[3] = VG_(getpid)(); + SizeT newlen = sizeof(osrel); + Int error = VG_(sysctl)(name, 4, NULL, NULL, &osrel, newlen); + if (error == -1) { + VG_(message)(Vg_DebugMsg, "Warning: failed to set osrel for current process with value %d\n", osrel); + } else { + if (VG_(clo_verbosity) > 1) { + VG_(message)(Vg_DebugMsg, "Set osrel for current process with value %d\n", osrel); + } + } + } + note_ioff = note_ioff + sizeof(ElfXX_Nhdr) + + ((note[0].n_namesz + 3) & ~3) + + ((note[0].n_descsz + 3) & ~3); + } + } + } + } + +} +#endif /* * Look for a build-id in an ELF image. The build-id specification @@ -1701,7 +1776,7 @@ static HChar* readlink_path (const HChar *path) #if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path, (UWord)buf, bufsiz); -#elif defined(VGO_linux) || defined(VGO_darwin) +#elif defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) res = VG_(do_syscall3)(__NR_readlink, (UWord)path, (UWord)buf, bufsiz); #elif defined(VGO_solaris) res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path, @@ -1939,14 +2014,14 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i); if (map->rx) - TRACE_SYMTAB("rx_map: avma %#lx size %lu foff %ld\n", - map->avma, map->size, map->foff); + TRACE_SYMTAB("rx_map: avma %#lx size %lu foff %lld\n", + map->avma, map->size, (Long)map->foff); } for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i); if (map->rw) - TRACE_SYMTAB("rw_map: avma %#lx size %lu foff %ld\n", - map->avma, map->size, map->foff); + TRACE_SYMTAB("rw_map: avma %#lx size %lu foff %lld\n", + map->avma, map->size, (Long)map->foff); } if (phdr_mnent == 0 @@ -2039,6 +2114,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) item.svma_limit = a_phdr.p_vaddr + a_phdr.p_memsz; item.bias = map->avma - map->foff + a_phdr.p_offset - a_phdr.p_vaddr; +#if (FREEBSD_VERS >= FREEBSD_12_2) + if ((long long int)item.bias < 0LL) { + item.bias = 0; + } +#endif if (map->rw && (a_phdr.p_flags & (PF_R | PF_W)) == (PF_R | PF_W)) { @@ -2166,8 +2246,8 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i); if (map->rx) - TRACE_SYMTAB("rx: at %#lx are mapped foffsets %ld .. %lu\n", - map->avma, map->foff, map->foff + map->size - 1 ); + TRACE_SYMTAB("rx: at %#lx are mapped foffsets %lld .. %lld\n", + map->avma, (Long)map->foff, (Long)(map->foff + map->size - 1) ); } TRACE_SYMTAB("rx: contains these svma regions:\n"); for (i = 0; i < VG_(sizeXA)(svma_ranges); i++) { @@ -2179,8 +2259,8 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) { const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i); if (map->rw) - TRACE_SYMTAB("rw: at %#lx are mapped foffsets %ld .. %lu\n", - map->avma, map->foff, map->foff + map->size - 1 ); + TRACE_SYMTAB("rw: at %#lx are mapped foffsets %lld .. %lld\n", + map->avma, (Long)map->foff, (Long)(map->foff + map->size - 1) ); } TRACE_SYMTAB("rw: contains these svma regions:\n"); for (i = 0; i < VG_(sizeXA)(svma_ranges); i++) { @@ -2222,10 +2302,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) } } - TRACE_SYMTAB(" [sec %2ld] %s %s al%4u foff %6ld .. %6lu " + TRACE_SYMTAB(" [sec %2ld] %s %s al%4u foff %6lld .. %6lld " " svma %p name \"%s\"\n", i, inrx ? "rx" : " ", inrw ? "rw" : " ", alyn, - foff, (size == 0) ? foff : foff+size-1, (void *) svma, name); + (Long) foff, (size == 0) ? (Long)foff : (Long)(foff+size-1), + (void *) svma, name); /* Check for sane-sized segments. SHT_NOBITS sections have zero size in the file and their offsets are just conceptual. */ @@ -2540,7 +2621,8 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) || defined(VGP_arm_linux) || defined (VGP_s390x_linux) \ || defined(VGP_mips32_linux) || defined(VGP_mips64_linux) \ || defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) \ - || defined(VGP_x86_solaris) || defined(VGP_amd64_solaris) + || defined(VGP_x86_solaris) || defined(VGP_amd64_solaris) \ + || defined(VGP_x86_freebsd) || defined(VGP_amd64_freebsd) /* Accept .plt where mapped as rx (code) */ if (0 == VG_(strcmp)(name, ".plt")) { if (inrx && !di->plt_present) { @@ -2876,6 +2958,12 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) |dimg| to it. */ vg_assert(dimg == NULL && aimg == NULL); +#if defined(VGO_freebsd) + /* */ + read_and_set_osrel(mimg); + +#endif + /* Look for a build-id */ HChar* buildid = find_buildid(mimg, False, False); @@ -3512,7 +3600,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) /* NOTREACHED */ } -#endif // defined(VGO_linux) || defined(VGO_solaris) +#endif // defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_debuginfo/readpdb.c b/coregrind/m_debuginfo/readpdb.c index f9128e30cf..a53cf48c44 100644 --- a/coregrind/m_debuginfo/readpdb.c +++ b/coregrind/m_debuginfo/readpdb.c @@ -33,7 +33,7 @@ The GNU General Public License is contained in the file COPYING. */ -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) #include "pub_core_basics.h" #include "pub_core_debuginfo.h" @@ -2604,7 +2604,7 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename ) return res; } -#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index 48a92b4029..9ba74076c1 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -365,6 +365,11 @@ void ML_(addSym) ( struct _DebugInfo* di, DiSym* sym ) vg_assert(sym->pri_name != NULL); vg_assert(sym->sec_names == NULL); +#if defined(VGO_freebsd) + if (sym->size == 0) + sym->size = 1; +#endif + /* Ignore zero-sized syms. */ if (sym->size == 0) return; @@ -1534,7 +1539,7 @@ Bool preferName ( const DebugInfo* di, vlena = VG_(strlen)(a_name); vlenb = VG_(strlen)(b_name); -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # define VERSION_CHAR '@' # elif defined(VGO_darwin) # define VERSION_CHAR '$' diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index ce4714d1bf..355c3caf5b 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -435,6 +435,89 @@ static UInt local_sys_getpid ( void ) return (UInt)(__res); } +#elif defined(VGP_x86_freebsd) +static UInt local_sys_write_stderr (const HChar* buf, Int n ) +{ + Int result; + + __asm__ volatile ( + "movl %2, %%eax\n" /* push n */ + "movl %1, %%edx\n" /* push buf */ + "pushl %%eax\n" + "pushl %%edx\n" + "movl $2, %%eax\n" /* push stderr */ + "pushl %%eax\n" + "movl $"VG_STRINGIFY(__NR_write)", %%eax\n" + "pushl %%eax\n" /* push write syscall id */ + "int $0x80\n" /* write(stderr, buf, n) */ + "jnc 1f\n" /* jump if no error */ + "movl $-1, %%eax\n" /* return -1 if error */ + "1: " + "movl %%eax, %0\n" /* __res = eax */ + "addl $16, %%esp\n" /* pop x4 */ + : /*wr*/ "=mr" (result) + : /*rd*/ "g" (buf), "g" (n) + : /*trash*/ "eax", "edx", "cc" + ); + return result >= 0 ? result : -1; +} + +static UInt local_sys_getpid ( void ) +{ + UInt __res; + __asm__ volatile ( + "movl $20, %%eax\n" /* set %eax = __NR_getpid */ + "int $0x80\n" /* getpid() */ + "movl %%eax, %0\n" /* set __res = eax */ + : "=mr" (__res) + : + : "eax" ); + return __res; +} + +#elif defined(VGP_amd64_freebsd) +__attribute__((noinline)) +static UInt local_sys_write_stderr (const HChar* buf, Int n ) +{ + volatile Long block[2]; + block[0] = (Long)buf; + block[1] = n; + __asm__ volatile ( + "subq $256, %%rsp\n" /* don't trash the stack redzone */ + "pushq %%r15\n" /* r15 is callee-save */ + "movq %0, %%r15\n" /* r15 = &block */ + "pushq %%r15\n" /* save &block */ + "movq $"VG_STRINGIFY(__NR_write)", %%rax\n" /* rax = __NR_write */ + "movq $2, %%rdi\n" /* rdi = stderr */ + "movq 0(%%r15), %%rsi\n" /* rsi = buf */ + "movq 8(%%r15), %%rdx\n" /* rdx = n */ + "syscall\n" /* write(stderr, buf, n) */ + "popq %%r15\n" /* reestablish &block */ + "movq %%rax, 0(%%r15)\n" /* block[0] = result */ + "popq %%r15\n" /* restore r15 */ + "addq $256, %%rsp\n" /* restore stack ptr */ + : /*wr*/ + : /*rd*/ "r" (block) + : /*trash*/ "rax", "rdi", "rsi", "rdx", "memory", "cc", "rcx", "r8", "r9", "r11" + ); + if (block[0] < 0) + block[0] = -1; + return (UInt)block[0]; +} + +static UInt local_sys_getpid ( void ) +{ + UInt __res; + __asm__ volatile ( + "movq $20, %%rax\n" /* set %rax = __NR_getpid */ + "syscall\n" /* getpid() */ + "movl %%eax, %0\n" /* set __res = %eax */ + : "=mr" (__res) + : + : "rax", "rcx");//, "r11" ); + return __res; +} + #elif defined(VGP_mips32_linux) || defined(VGP_mips64_linux) static UInt local_sys_write_stderr ( const HChar* buf, Int n ) diff --git a/coregrind/m_gdbserver/gdb/signals.h b/coregrind/m_gdbserver/gdb/signals.h index d04a574771..4857475fa3 100644 --- a/coregrind/m_gdbserver/gdb/signals.h +++ b/coregrind/m_gdbserver/gdb/signals.h @@ -137,6 +137,9 @@ enum target_signal /* Used internally by Solaris threads. See signal(5) on Solaris. */ TARGET_SIGNAL_CANCEL = 76, + /* Similar to the above, but for FreeBSD */ + TARGET_SIGNAL_THR = 77, + /* Yes, this pains me, too. But LynxOS didn't have SIG32, and now GNU/Linux does, and we can't disturb the numbering, since it's part of the remote protocol. Note that in some GDB's diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index 2d13b79f3d..559d8dd8e9 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -27,6 +27,7 @@ #include "pub_core_libcsignal.h" #include "pub_core_options.h" #include "pub_core_aspacemgr.h" +#include "pub_core_syswrap.h" #include "server.h" @@ -322,7 +323,11 @@ void remote_open (const HChar *name) (Addr) VG_(threads), VG_N_THREADS, sizeof(ThreadState), offsetof(ThreadState, status), offsetof(ThreadState, os_state) + offsetof(ThreadOSstate, lwpid), - 0}; + 0 +#if VEX_HOST_WORDSIZE == 8 + , 0 +#endif + }; user = VG_(getenv)("LOGNAME"); if (user == NULL) user = VG_(getenv)("USER"); @@ -519,12 +524,30 @@ void remote_close (void) from_gdb ? from_gdb : "NULL", to_gdb ? to_gdb : "NULL", shared_mem ? shared_mem : "NULL"); - if (pid == pid_from_to_creator && from_gdb && VG_(unlink) (from_gdb) == -1) - warning ("could not unlink %s\n", from_gdb); - if (pid == pid_from_to_creator && to_gdb && VG_(unlink) (to_gdb) == -1) - warning ("could not unlink %s\n", to_gdb); - if (pid == pid_from_to_creator && shared_mem && VG_(unlink) (shared_mem) == -1) - warning ("could not unlink %s\n", shared_mem); + + // PJF this is not ideal + // if the guest enters capability mode then the unlink calls will fail + // this may well also apply to Linux and seccomp + // I don't have any thoughts on how to fix it, other than forking early on + // having the child run the guest and the parent wait()ing and then + // the parent doing the cleanup + + Bool unlinkPossible = True; +#if defined(VGO_freebsd) + unlinkPossible = (VG_(get_capability_mode)() == False); +#endif + + if (unlinkPossible == True) { + if (pid == pid_from_to_creator && from_gdb && VG_(unlink) (from_gdb) == -1) + warning ("could not unlink %s\n", from_gdb); + if (pid == pid_from_to_creator && to_gdb && VG_(unlink) (to_gdb) == -1) + warning ("could not unlink %s\n", to_gdb); + if (pid == pid_from_to_creator && shared_mem && VG_(unlink) (shared_mem) == -1) + warning ("could not unlink %s\n", shared_mem); + } else { + VG_(debugLog)(1, "remote close", + "cannot unlink gdb pipes\n"); + } free (from_gdb); from_gdb = NULL; free (to_gdb); diff --git a/coregrind/m_gdbserver/signals.c b/coregrind/m_gdbserver/signals.c index 24948a19a4..9aee90fcba 100644 --- a/coregrind/m_gdbserver/signals.c +++ b/coregrind/m_gdbserver/signals.c @@ -404,6 +404,10 @@ enum target_signal target_signal_from_host (int hostsig) if (hostsig == VKI_SIGCANCEL) return TARGET_SIGNAL_CANCEL; #endif +#if defined(VKI_SIGTHR) + if (hostsig == VKI_SIGTHR) + return TARGET_SIGNAL_THR; +#endif #if defined (VKI_SIGLWP) if (hostsig == VKI_SIGLWP) return TARGET_SIGNAL_LWP; @@ -657,6 +661,10 @@ int do_target_signal_to_host (enum target_signal oursig, case TARGET_SIGNAL_CANCEL: return VKI_SIGCANCEL; #endif +#if defined (VKI_SIGTHR) + case TARGET_SIGNAL_THR: + return VKI_SIGTHR; +#endif #if defined (VKI_SIGLWP) case TARGET_SIGNAL_LWP: return VKI_SIGLWP; diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index ec63fccefb..35f37f88df 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -49,7 +49,7 @@ ------------------------------------------------------------------ */ #if defined(VGP_x86_linux) || defined(VGP_x86_darwin) \ - || defined(VGP_x86_solaris) + || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) # define GET_STARTREGS(srP) \ { UInt eip, esp, ebp; \ __asm__ __volatile__( \ @@ -66,7 +66,7 @@ (srP)->misc.X86.r_ebp = ebp; \ } #elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) \ - || defined(VGP_amd64_solaris) + || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) # define GET_STARTREGS(srP) \ { ULong rip, rsp, rbp; \ __asm__ __volatile__( \ @@ -309,7 +309,7 @@ void VG_(exit_now)( Int status ) { #if defined(VGO_linux) (void)VG_(do_syscall1)(__NR_exit_group, status ); -#elif defined(VGO_darwin) || defined(VGO_solaris) +#elif defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) (void)VG_(do_syscall1)(__NR_exit, status ); #else # error Unknown OS diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index 3a8fed85d9..598027c6d9 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -67,6 +67,11 @@ Int VG_(safe_fd)(Int oldfd) return newfd; } +#if defined(VGO_freebsd) +#define M_FILEDESC_BUF 1000000 +static Char filedesc_buf[M_FILEDESC_BUF]; +#endif + /* Given a file descriptor, attempt to deduce its filename. To do this, we use /proc/self/fd/<FD>. If this doesn't point to a file, or if it doesn't exist, we return False. @@ -113,6 +118,46 @@ Bool VG_(resolve_filename) ( Int fd, const HChar** result ) *result = NULL; return False; +#elif defined(VGO_freebsd) + Int mib[4]; + SysRes sres; + vki_size_t len; + Char *bp, *eb; + struct vki_kinfo_file *kf; + static HChar *buf = NULL; + static SizeT bufsiz = 0; + + if (buf == NULL) { // first time + bufsiz = 500; + buf = VG_(malloc)("resolve_filename", bufsiz); + } + + mib[0] = VKI_CTL_KERN; + mib[1] = VKI_KERN_PROC; + mib[2] = VKI_KERN_PROC_FILEDESC; + mib[3] = sr_Res(VG_(do_syscall0)(__NR_getpid)); + len = sizeof(filedesc_buf); + sres = VG_(do_syscall6)(__NR___sysctl, (UWord)mib, 4, (UWord)filedesc_buf, + (UWord)&len, 0, 0); + if (sr_isError(sres)) { + VG_(debugLog)(0, "sysctl(kern.proc.filedesc)", "%s\n", VG_(strerror)(sr_Err(sres))); + return False; + } + /* Walk though the list. */ + bp = filedesc_buf; + eb = filedesc_buf + len; + while (bp < eb) { + kf = (struct vki_kinfo_file *)bp; + if (kf->kf_fd == fd) + break; + bp += kf->kf_structsize; + } + if (bp >= eb || *kf->kf_path == '\0') + VG_(strncpy)( buf, "[unknown]", bufsiz ); + else + VG_(strncpy)( buf, kf->kf_path, bufsiz ); + *result = buf; + return True; # elif defined(VGO_darwin) HChar tmp[VKI_MAXPATHLEN+1]; if (0 == VG_(fcntl)(fd, VKI_F_GETPATH, (UWord)tmp)) { @@ -143,6 +188,9 @@ SysRes VG_(mknod) ( const HChar* pathname, Int mode, UWord dev ) # elif defined(VGO_linux) || defined(VGO_darwin) SysRes res = VG_(do_syscall3)(__NR_mknod, (UWord)pathname, mode, dev); +# elif defined(VGO_freebsd) + SysRes res = VG_(do_syscall3)(__NR_freebsd11_mknod, + (UWord)pathname, mode, dev); # elif defined(VGO_solaris) SysRes res = VG_(do_syscall4)(__NR_mknodat, VKI_AT_FDCWD, (UWord)pathname, mode, dev); @@ -158,7 +206,7 @@ SysRes VG_(open) ( const HChar* pathname, Int flags, Int mode ) /* ARM64 wants to use __NR_openat rather than __NR_open. */ SysRes res = VG_(do_syscall4)(__NR_openat, VKI_AT_FDCWD, (UWord)pathname, flags, mode); -# elif defined(VGO_linux) +# elif defined(VGO_linux) || defined(VGO_freebsd) SysRes res = VG_(do_syscall3)(__NR_open, (UWord)pathname, flags, mode); # elif defined(VGO_darwin) @@ -186,7 +234,7 @@ Int VG_(fd_open) (const HChar* pathname, Int flags, Int mode) void VG_(close) ( Int fd ) { /* Hmm. Return value is not checked. That's uncool. */ -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) (void)VG_(do_syscall1)(__NR_close, fd); # elif defined(VGO_darwin) (void)VG_(do_syscall1)(__NR_close_nocancel, fd); @@ -198,7 +246,7 @@ void VG_(close) ( Int fd ) Int VG_(read) ( Int fd, void* buf, Int count) { Int ret; -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) SysRes res = VG_(do_syscall3)(__NR_read, fd, (UWord)buf, count); # elif defined(VGO_darwin) SysRes res = VG_(do_syscall3)(__NR_read_nocancel, fd, (UWord)buf, count); @@ -218,7 +266,7 @@ Int VG_(read) ( Int fd, void* buf, Int count) Int VG_(write) ( Int fd, const void* buf, Int count) { Int ret; -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) SysRes res = VG_(do_syscall3)(__NR_write, fd, (UWord)buf, count); # elif defined(VGO_darwin) SysRes res = VG_(do_syscall3)(__NR_write_nocancel, fd, (UWord)buf, count); @@ -254,6 +302,13 @@ Int VG_(pipe) ( Int fd[2] ) # elif defined(VGO_linux) SysRes res = VG_(do_syscall1)(__NR_pipe, (UWord)fd); return sr_isError(res) ? -1 : 0; +# elif defined(VGO_freebsd) + SysRes res = VG_(do_syscall0)(__NR_freebsd10_pipe); + if (!sr_isError(res)) { + fd[0] = sr_Res(res); + fd[1] = sr_ResHI(res); + } + return sr_isError(res) ? -1 : 0; # elif defined(VGO_darwin) /* __NR_pipe is UX64, so produces a double-word result */ SysRes res = VG_(do_syscall0)(__NR_pipe); @@ -281,7 +336,7 @@ Int VG_(pipe) ( Int fd[2] ) Off64T VG_(lseek) ( Int fd, Off64T offset, Int whence ) { -# if defined(VGO_linux) || defined(VGP_amd64_darwin) +# if defined(VGO_linux) || defined(VGP_amd64_darwin) || defined(VGP_amd64_freebsd) # if defined(__NR__llseek) Off64T result; SysRes res = VG_(do_syscall5)(__NR__llseek, fd, @@ -293,7 +348,7 @@ Off64T VG_(lseek) ( Int fd, Off64T offset, Int whence ) vg_assert(sizeof(Off64T) == sizeof(sr_Res(res))); return sr_isError(res) ? (-1) : sr_Res(res); # endif -# elif defined(VGP_x86_darwin) +# elif defined(VGP_x86_darwin) || defined(VGP_x86_freebsd) SysRes res = VG_(do_syscall4)(__NR_lseek, fd, offset & 0xffffffff, offset >> 32, whence); return sr_isError(res) ? (-1) : sr_Res(res); @@ -424,6 +479,18 @@ SysRes VG_(stat) ( const HChar* file_n... [truncated message content] |