NetBSD Problem Report #55269
From www@netbsd.org Sat May 16 15:13:51 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id B86681A9227
for <gnats-bugs@gnats.NetBSD.org>; Sat, 16 May 2020 15:13:51 +0000 (UTC)
Message-Id: <20200516151350.8929A1A9228@mollari.NetBSD.org>
Date: Sat, 16 May 2020 15:13:50 +0000 (UTC)
From: romain@dolbeau.org
Reply-To: romain@dolbeau.org
To: gnats-bugs@NetBSD.org
Subject: 'bjam' always 'bus error' on NetBSD/sparc (presumably, other strict-alignement 32 bits arch as well)
X-Send-Pr-Version: www-1.0
>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
>Last-Modified: Mon May 18 11:10:01 +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:/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
>Audit-Trail:
From: Benny Siegert <bsiegert@gmail.com>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55269: 'bjam' always 'bus error' on NetBSD/sparc (presumably,
other strict-alignement 32 bits arch as well)
Date: Sun, 17 May 2020 15:52:40 +0200
Thank you for your report. Did you also file this upstream?
From: Romain Dolbeau <romain@dolbeau.org>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55269: 'bjam' always 'bus error' on NetBSD/sparc (presumably,
other strict-alignement 32 bits arch as well)
Date: Sun, 17 May 2020 16:03:30 +0200
Le dim. 17 mai 2020 =C3=A0 15:55, Benny Siegert <bsiegert@gmail.com> a =C3=
=A9crit :
> Thank you for your report. Did you also file this upstream?
No, I wasn't sure if that was needed - or, indeed, a good idea; fix
for 25+ years old hardware aren't always welcome :-)
Binary packages are visible here:
<https://www.dropbox.com/sh/5w6od9b333u97dm/AAChGRHJejsfh89iMlL6dYUxa?dl=3D=
0>.
(boost-mpi is missing because mpich blows up at compile time as
well... I didn't even know there was a boost-mpi ;-) ).
Cordially,
--=20
Romain Dolbeau
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/55269: 'bjam' always 'bus error' on NetBSD/sparc
(presumably, other strict-alignement 32 bits arch as well)
Date: Mon, 18 May 2020 12:45:36 +0200
Please report this upstream, it is plain broken code.
#define hash_item_data(item) ((HASHDATA *)((char *)item + sizeof(ITEM)))
is obviously broken for all architectures where alignement of HASHDATA
and ITEM differ.
Let upstream decide on what they like best as a fix.
Maybe something like
struct item_data {
ITEM item;
HASDATA data;
};
and then letting the compiler do the homework.
Martin
From: Romain Dolbeau <romain@dolbeau.org>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55269: 'bjam' always 'bus error' on NetBSD/sparc (presumably,
other strict-alignement 32 bits arch as well)
Date: Mon, 18 May 2020 13:01:10 +0200
Le lun. 18 mai 2020 =C3=A0 12:50, Martin Husemann <martin@duskware.de> a =
=C3=A9crit :
> Please report this upstream, it is plain broken code.
It is, however it will work as long as alignment rules are respected,
which is always the case except for data atom with an alignment
requirement larger than the size of a pointer. The exception never
happens 'for real' except 8-bytes data atom with 4-bytes pointer and
strict alignment rules, so pretty much only 32-bits sparc and maybe
some other 32-bits RISC architecture are affected... not a primary
concern for Boost, I would guess.
I'll fill a bug in GitHub and see what happens :-)
Cordially,
--=20
Romain Dolbeau
From: Romain Dolbeau <romain@dolbeau.org>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55269: 'bjam' always 'bus error' on NetBSD/sparc (presumably,
other strict-alignement 32 bits arch as well)
Date: Mon, 18 May 2020 13:08:36 +0200
Le lun. 18 mai 2020 =C3=A0 13:01, Romain Dolbeau <romain@dolbeau.org> a =C3=
=A9crit :
> I'll fill a bug in GitHub and see what happens :-)
FYI: <https://github.com/boostorg/boost/issues/396>
Cordially,
--=20
Romain Dolbeau
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.