pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/58719: wm/cde crashes in dthelpview during startup on sparc64



>Number:         58719
>Category:       pkg
>Synopsis:       wm/cde crashes in dthelpview during startup on sparc64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 05 19:55:00 +0000 2024
>Originator:     Sad Clouds
>Release:        pkg-2024Q2
>Organization:
>Environment:
>Description:
During first run of CDE, program dthelpview is started automatically but then crashes with SIGBUS due to alignment issues on sparc64
>How-To-Repeat:
Run dthelpview X11 client with the following parameters:

dthelpview -helpVolume Intromgr
>Fix:
--- cde-2.5.2/lib/DtHelp/il/iltiff.c.orig	2023-11-18 22:38:09.000000000 +0000
+++ cde-2.5.2/lib/DtHelp/il/iltiff.c	2024-10-05 20:29:11.835179256 +0100
@@ -42,6 +42,7 @@
     */
 
 #include <stdlib.h>
+#include <stdint.h>
 
 #include "iltiffint.h"
 #include "ilerrors.h"
@@ -150,6 +151,18 @@
 int                     tagNumber, nFileTags, nItems, nTags, tagType, i;
 ilBool         bigEndian;
 
+/*
+* Attempt to determine ILP32 or LP64 data model in a portable manner
+* Assume size of pointer (hence its alignment) corresponds to UINTPTR_MAX value
+*/
+#if UINTPTR_MAX <= UINT32_MAX    /* 32-bit pointers */
+    const size_t align_mask = 3; /* Alignment on 4-byte boundary */
+#elif UINTPTR_MAX <= UINT64_MAX  /* 64-bit pointers */
+    const size_t align_mask = 7; /* Alignment on 8-byte boundary */
+#else /* UINTPTR_MAX > UINT64_MAX */
+    #error "Cannot determine correct alignment for pointers"
+#endif
+
     pFileImage = (ilFileImagePtr)fileImage;
     if (mustBeZero != 0) {
         pFileImage->context->error = IL_ERROR_PAR_NOT_ZERO;
@@ -217,7 +230,7 @@
             }
         if (tagFound) {
             mallocSize += (sizeof (ilFileTag) +
-                (pFileTag->length * _ilTagTypeItemSizes [pFileTag->type] + 3)) & ~3;
+                (pFileTag->length * _ilTagTypeItemSizes [pFileTag->type] + align_mask)) & ~align_mask;
             *ppTag++ = (ilFileTag *)pFileTag;
             }
         else *ppTag++ = (ilFileTag *)NULL;
@@ -272,7 +285,7 @@
             else {
                 pTag->pItems = pTagData;        /* data follows the tag */
                 pTag = (ilFileTag *)(pTagData + /* next spot = past data, long-aligned */
-                    ((nItems * _ilTagTypeItemSizes [tagType] + 3) & ~3));
+                    ((nItems * _ilTagTypeItemSizes [tagType] + align_mask) & ~align_mask));
 
                     /*  Byte flip the tag data to the spot pointed to by "pTagData",
                         i.e. right after the 12 bytes for the tag.  In TIFF, the data



Home | Main Index | Thread Index | Old Index