]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 519613 - Valgrind incorrectly unpacks the result of sys_port (port_getn) on error...
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 30 Apr 2026 19:00:55 +0000 (21:00 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 30 Apr 2026 19:14:06 +0000 (21:14 +0200)
Patch provided by Arran Cudbard-Bell <a.cudbardb@freeradius.org>

.gitignore
NEWS
coregrind/m_syswrap/syswrap-solaris.c
memcheck/tests/solaris/Makefile.am
memcheck/tests/solaris/bug519613.c [new file with mode: 0644]
memcheck/tests/solaris/bug519613.stdout.exp [new file with mode: 0644]
memcheck/tests/solaris/bug519613.vgtest [new file with mode: 0644]

index a35e309386a583efab52a314be715e1dcaf25fc7..e72d3282763db5894624c59bb9a69c07f41e18f2 100644 (file)
 /memcheck/tests/solaris/Makefile.in
 /memcheck/tests/solaris/aligned_alloc
 /memcheck/tests/solaris/brk
+/memcheck/tests/solaris/bug519613
 /memcheck/tests/solaris/context_stack_die
 /memcheck/tests/solaris/door_data
 /memcheck/tests/solaris/door_kill
diff --git a/NEWS b/NEWS
index 4967fe770062018350c6af23fc9652ee7d668a45..2e31f8b233c8a791341c633372a04ced91e65dad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,8 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 
 519223  Recognize ioctl(UFFDIO_*) operations
 519539  Darwin shm_open mode is optional and depends on oflag
+519613  Valgrind incorrectly unpacks the result of sys_port (port_getn)
+        on error, leading to a ~60s wallclock time delay on every call
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 6ecd3a4c4462ad764e4de13e4e3406fc76e2dbee..33c0bf4db621d532d3df7a789f70e6a04c3a0aec 100644 (file)
@@ -7802,9 +7802,11 @@ POST(sys_port)
    case VKI_PORT_GET:
       POST_MEM_WRITE(ARG3, sizeof(vki_port_event_t));
       break;
-   case VKI_PORT_GETN:
-      POST_MEM_WRITE(ARG3, RES * sizeof(vki_port_event_t));
+   case VKI_PORT_GETN: {
+      UInt nget = (UInt)(RES & 0xFFFFFFFFu);
+      POST_MEM_WRITE(ARG3, nget * sizeof(vki_port_event_t));
       break;
+   }
    case VKI_PORT_ALERT:
    case VKI_PORT_DISPATCH:
       break;
index 0201c5f44e68ab2c230e4df47f49024d731d6429..1d84771e16a33cf8e7beb90aee44e471d2144a7c 100644 (file)
@@ -15,6 +15,7 @@ EXTRA_DIST = \
        aligned_alloc.stderr.exp aligned_alloc.vgtest \
        aligned_alloc.stderr.exp-solaris \
        brk.stderr.exp brk.vgtest \
+       bug519613.vgtest bug519613.stdout.exp \
        context_stack_die.stderr.exp context_stack_die.vgtest \
        door_data.stdout.exp door_data.vgtest \
        door_kill.stdout.exp door_kill.vgtest \
@@ -64,6 +65,7 @@ EXTRA_DIST = \
 check_PROGRAMS = \
        aligned_alloc \
        brk \
+       bug519613 \
        context_stack_die \
        door_data \
        door_kill \
diff --git a/memcheck/tests/solaris/bug519613.c b/memcheck/tests/solaris/bug519613.c
new file mode 100644 (file)
index 0000000..0226018
--- /dev/null
@@ -0,0 +1,13 @@
+#include <port.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+int main(void) {
+   int p = port_create();
+   port_event_t e;
+   uint_t n = 1;
+   struct timespec t = {0, 100000000};
+   port_getn(p, &e, 1, &n, &t);   /* timeout, ETIME expected */
+   printf("%s\n", strerror(errno)); /* triggers strerror_l→dgettext_l→calloc */
+}
diff --git a/memcheck/tests/solaris/bug519613.stdout.exp b/memcheck/tests/solaris/bug519613.stdout.exp
new file mode 100644 (file)
index 0000000..32a6263
--- /dev/null
@@ -0,0 +1 @@
+Timer expired
diff --git a/memcheck/tests/solaris/bug519613.vgtest b/memcheck/tests/solaris/bug519613.vgtest
new file mode 100644 (file)
index 0000000..aa65bc7
--- /dev/null
@@ -0,0 +1,2 @@
+prog: bug519613
+vgopts: -q