From: Paul F. <pa...@so...> - 2025-07-20 08:20:24
|
https://sourceware.org/cgit/valgrind/commit/?id=282fd0d3eb2b8d0b289b35311b05db4acddfdc14 commit 282fd0d3eb2b8d0b289b35311b05db4acddfdc14 Author: Paul Floyd <pj...@wa...> Date: Sun Jul 20 10:19:00 2025 +0200 FreeBSD regtest: make memcheck/tests/freebsd/setcred consistent on arm64 and amd64 Was getting different errors due to the contents of junk pointers. Diff: --- memcheck/tests/freebsd/setcred.cpp | 9 +++++++-- memcheck/tests/freebsd/setcred.stderr.exp | 19 +++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/memcheck/tests/freebsd/setcred.cpp b/memcheck/tests/freebsd/setcred.cpp index 7553599dfc..464de08efe 100644 --- a/memcheck/tests/freebsd/setcred.cpp +++ b/memcheck/tests/freebsd/setcred.cpp @@ -1,14 +1,18 @@ #include <sys/ucred.h> #include <cstring> +#include <cstdlib> + +static long x0; int main() { + long *px{static_cast<long*>(malloc(2*sizeof(long)))}; + x0 = px[0]; struct setcred cred1; struct setcred* cred2; int flags1{0}; int flags2; size_t size1{sizeof(cred1)}; - size_t size2; std::memset(&cred1, 250, sizeof(cred1)); @@ -19,7 +23,7 @@ int main() setcred(flags1, nullptr, size1); // uninit - setcred(flags2, cred2, size2); + setcred(flags2, (struct setcred*)x0, size1+x0); cred2 = new struct setcred; @@ -27,5 +31,6 @@ int main() setcred(flags1, cred2, size1); delete cred2; + free(px); } diff --git a/memcheck/tests/freebsd/setcred.stderr.exp b/memcheck/tests/freebsd/setcred.stderr.exp index 1d9cecf8e3..629ceacf84 100644 --- a/memcheck/tests/freebsd/setcred.stderr.exp +++ b/memcheck/tests/freebsd/setcred.stderr.exp @@ -1,30 +1,29 @@ Syscall param setcred(wcred) points to unaddressable byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:19) + by 0x........: main (setcred.cpp:23) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param setcred(flags) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:22) + by 0x........: main (setcred.cpp:26) Syscall param setcred(wcred) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:22) + by 0x........: main (setcred.cpp:26) Syscall param setcred(size) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:22) + by 0x........: main (setcred.cpp:26) -Syscall param setcred(wcred) points to uninitialised byte(s) +Syscall param setcred(wcred) points to unaddressable byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:22) - Address 0x........ is on thread 1's stack - in frame #2, created by __libc_start1 (???:) + by 0x........: main (setcred.cpp:26) + Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param setcred(wcred) points to uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:27) + by 0x........: main (setcred.cpp:31) Address 0x........ is 0 bytes inside a block of size 48 alloc'd at 0x........: ...operator new... (vg_replace_malloc.c:...) - by 0x........: main (setcred.cpp:24) + by 0x........: main (setcred.cpp:28) |