]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD regtest: make memcheck/tests/freebsd/setcred consistent on arm64 and amd64
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 20 Jul 2025 08:19:00 +0000 (10:19 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 20 Jul 2025 08:19:00 +0000 (10:19 +0200)
Was getting different errors due to the contents of junk pointers.

memcheck/tests/freebsd/setcred.cpp
memcheck/tests/freebsd/setcred.stderr.exp

index 7553599dfc6037730af43f142cb7ba71063ee0e4..464de08efe1abb276adb135228671c653a1238d9 100644 (file)
@@ -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);
 }
 
index 1d9cecf8e39d1bd98cf462f85d83d2a63ef6107d..629ceacf845ff8b58084439624e7a019e7c02e1b 100644 (file)
@@ -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)