pkgsrc-Bugs archive

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

pkg/55269: 'bjam' always 'bus error' on NetBSD/sparc (presumably, other strict-alignement 32 bits arch as well)



>Number:         55269
>Category:       pkg
>Synopsis:       'bjam' always 'bus error' on NetBSD/sparc (presumably, other strict-alignement 32 bits arch as well)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 16 15:15:00 +0000 2020
>Originator:     Romain Dolbeau
>Release:        pkgsrc 2020Q1
>Organization:
>Environment:
NetBSD vmsparc.dolbeau.name 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/sparc/compile/GENERIC sparc
>Description:
Trying to compile the "boost" meta-package, 'bjam' always crashes with a 'bus error'. The culprit is the function 'timestamp_init' in tools/build/src/engine/timestamp.cpp, which does:

time->secs = secs;

where 'secs' are 'time_t', currently 8 bytes. This is only legal on SPARC if time->secs is 8-bytes aligned, which it isn't, so the 8-bytes store causes a 'bus error'. The reason for the nonalignment is that it comes from the hash table implementation in hash.cpp, which does:

#define hash_item_data(item) ((HASHDATA *)((char *)item + sizeof(ITEM)))

ITEM is the size of a pointer, and item is properly aligned (at least 8 bytes), so this is _never_ aligned properly with 32-bits pointers... This result in reliable crashes on 32-bits machine with strict alignment requirements (i.e., sparc).

>How-To-Repeat:
on NetBSD/sparc as root:

cd /usr/pkgsrc/meta-kpgs/boost
make

eventually, the build of boost-headers will fail.
>Fix:
The following patch fixes the problem for me, but might be a bit overkill (memory wastage) on 32-bits architecture that supports unaligned access. It should be a no-op on 64-bits architecture.

--- tools/build/src/engine/hash.cpp.orig        2019-12-10 01:20:17.000000000 +0100
+++ tools/build/src/engine/hash.cpp     2020-05-16 14:55:46.086210410 +0200
@@ -33,8 +33,8 @@
 typedef struct item ITEM;
 struct item
 {
-    ITEM * next;
-};
+    ITEM * next __attribute__ ((aligned (8)));
+} __attribute__ ((aligned (8)));
 
 #define MAX_LISTS 32


Home | Main Index | Thread Index | Old Index