Problem discovered when some tests hanged indefinitely,
due to fstat clobbering some victims just past a struct stat.
* lib/stackvma.c [__sun && !__sun]: Simplify by removing code that
has not been needed since we removed IRIX support.
* lib/stackvma.c, lib/vma-iter.c:
(fstat) [__sun && !defined _LP64]: #undef so that we do not use
the Gnulib replacement, which has an incompatible struct stat
given that we "#define _FILE_OFFSET_BITS 32".
* lib/vma-iter.c [__sun]: Include <sys/stat.h> explicitly,
instead of relying on implicit includes.
---
 ChangeLog      | 14 ++++++++++++++
 lib/stackvma.c | 18 ++++++------------
 lib/vma-iter.c |  9 +++++++++
 3 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a440b6d3f6..72a983994f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-09-25  Paul Eggert  <[email protected]>
+
+       sigsegv, vma-iter: port to 32-bit Solaris
+       Problem discovered when some tests hanged indefinitely,
+       due to fstat clobbering some victims just past a struct stat.
+       * lib/stackvma.c [__sun && !__sun]: Simplify by removing code that
+       has not been needed since we removed IRIX support.
+       * lib/stackvma.c, lib/vma-iter.c:
+       (fstat) [__sun && !defined _LP64]: #undef so that we do not use
+       the Gnulib replacement, which has an incompatible struct stat
+       given that we "#define _FILE_OFFSET_BITS 32".
+       * lib/vma-iter.c [__sun]: Include <sys/stat.h> explicitly,
+       instead of relying on implicit includes.
+
 2026-09-23  Paul Eggert  <[email protected]>
 
        tests: prefer GCC sanitization macros
diff --git a/lib/stackvma.c b/lib/stackvma.c
index 9b50e4b43e..92568757ab 100644
--- a/lib/stackvma.c
+++ b/lib/stackvma.c
@@ -1830,18 +1830,12 @@ sigsegv_get_vma (uintptr_t address, struct vma_struct 
*vma)
 # define _STRUCTURED_PROC 1
 # include <sys/procfs.h> /* prmap_t, optionally PIOC* */
 
-# if !defined __sun
-
-/* Cache for getpagesize().  */
-static uintptr_t pagesize;
-
-/* Initialize pagesize.  */
-static void
-init_pagesize (void)
-{
-  pagesize = getpagesize ();
-}
-
+/*  In 32-bit Solaris do not use the Gnulib replacement for fstat as
+    it typically assumes a struct stat with 64-bit off_t, whereas our
+    struct stat uses only 32-bit off_t.  We don't need the Gnulib
+    fstat workarounds here.  */
+# if defined fstat && !defined _LP64
+#  undef fstat
 # endif
 
 struct callback_locals
diff --git a/lib/vma-iter.c b/lib/vma-iter.c
index 639235ca0c..4732da3eb0 100644
--- a/lib/vma-iter.c
+++ b/lib/vma-iter.c
@@ -86,9 +86,18 @@
 # include <string.h> /* memcpy */
 # include <sys/types.h>
 # include <sys/mman.h> /* mmap, munmap */
+# include <sys/stat.h> /* fstat */
 /* Try to use the newer ("structured") /proc filesystem API, if supported.  */
 # define _STRUCTURED_PROC 1
 # include <sys/procfs.h> /* prmap_t, optionally PIOC* */
+
+/*  In 32-bit Solaris do not use the Gnulib replacement for fstat as
+    it typically assumes a struct stat with 64-bit off_t, whereas our
+    struct stat uses only 32-bit off_t.  We don't need the Gnulib
+    fstat workarounds here.  */
+# if defined fstat && !defined _LP64
+#  undef fstat
+# endif
 #endif
 
 #if HAVE_PSTAT_GETPROCVM /* HP-UX */
-- 
2.55.0


Reply via email to