NetBSD Problem Report #52443

From www@NetBSD.org  Sun Jul 30 14:47:19 2017
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" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id DD9377A172
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 30 Jul 2017 14:47:19 +0000 (UTC)
Message-Id: <20170730144700.185D17A288@mollari.NetBSD.org>
Date: Sun, 30 Jul 2017 14:47:00 +0000 (UTC)
From: aymericvincent@free.fr
Reply-To: aymericvincent@free.fr
To: gnats-bugs@NetBSD.org
Subject: Reproducible builds don't work on 64bit Linux
X-Send-Pr-Version: www-1.0

>Number:         52443
>Category:       toolchain
>Synopsis:       Reproducible builds don't work on 64bit Linux
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lukem
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 30 14:50:00 +0000 2017
>Closed-Date:    Fri May 19 10:25:26 +0000 2023
>Last-Modified:  Sat May 20 12:45:01 +0000 2023
>Originator:     Aymeric Vincent
>Release:        -current, -8
>Organization:
>Environment:
Linux 4.12.4 x86_64

>Description:
Option "-P" (reproducible builds) of src/build.sh is broken on Linux.

usr.bin/cvslatest/cvslatest.c makes use of strptime(3), but strptime() requires _XOPEN_SOURCE to be defined under Linux in order to get its prototype.

However, given that the code for the function is in libc anyway, strptime() will be called and treated as if it returned an int when it actually returns a pointer. The pointer is truncated to 32bits, dereferenced, and nbcvslatest dumps core.


A much less important problem is also that the timestamp is printed by src/build.sh at the end of the build, using "date -r" which doesn't do the same thing at all. "date -d @TS" works on both NetBSD and Linux, but from looking at the date(1) man page of FreeBSD it shouldn't work on FreeBSD.

>How-To-Repeat:

Try to build.sh -P under a 64bit Linux. See it fail and make nbcvslatest dump core.

It is also probably broken on any non-NetBSD LP64 OS which has strict feature testing header files.

>Fix:
A workaround for the problem is to

#define _XOPEN_SOURCE

at the beginning of usr.bin/cvslatest/cvslatest.c, but it looks wrong because it makes build.sh less OS independant. Possibly a better solution would be to import strptime.c into src/tools/compat.


As for the timestamp printing problem, it could make sense to check which OS we are running on to select an invocation of date. A simpler solution would be to print the timestamp untouched, as a number of seconds since Epoch.

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->feedback
State-Changed-By: lukem@NetBSD.org
State-Changed-When: Thu, 18 May 2023 15:46:51 +0000
State-Changed-Why:

Is this still an issue?

cvslatest was modified by joerg@ on 2017-09-24 to force _GNU_SOURCE
on Linux to ensure that strptime() is defined.


From: Aymeric Vincent <aymericvincent@free.fr>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/52443 (Reproducible builds don't work on 64bit Linux)
Date: Fri, 19 May 2023 12:21:29 +0200

 lukem@NetBSD.org writes:

 > Synopsis: Reproducible builds don't work on 64bit Linux
 > [...]
 > Is this still an issue?

 No, it's fine now. Thank you.

 Regards,
  Aymeric

State-Changed-From-To: feedback->closed
State-Changed-By: lukem@NetBSD.org
State-Changed-When: Fri, 19 May 2023 10:25:26 +0000
State-Changed-Why:
Confirmed fixed by submitter.


Responsible-Changed-From-To: toolchain-manager->lukem
Responsible-Changed-By: lukem@NetBSD.org
Responsible-Changed-When: Sat, 20 May 2023 08:39:33 +0000
Responsible-Changed-Why:


From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: gnats-bugs@netbsd.org
Cc: lukem@netbsd.org, toolchain-manager@netbsd.org, netbsd-bugs@netbsd.org,
	gnats-admin@netbsd.org, aymericvincent@free.fr
Subject: Re: toolchain/52443 (Reproducible builds don't work on 64bit Linux)
Date: Sat, 20 May 2023 14:40:04 +0200

 --jafmte2hxhrtko4w
 Content-Type: text/plain; charset=utf-8
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable

 On Sat, 2023-05-20 08:39:33 +0000, lukem@NetBSD.org <lukem@NetBSD.org> wrot=
 e:
 > Synopsis: Reproducible builds don't work on 64bit Linux
 >=20
 > Responsible-Changed-From-To: toolchain-manager->lukem
 > Responsible-Changed-By: lukem@NetBSD.org
 > Responsible-Changed-When: Sat, 20 May 2023 08:39:33 +0000
 > Responsible-Changed-Why:

 I'm interested in this topic. Let me know if/how I can help with this.
 I do regular builds from a modern Debian distro as well as from
 NetBSD.

 Thanks,
   Jan-Benedict
 --=20

 --jafmte2hxhrtko4w
 Content-Type: application/pgp-signature; name="signature.asc"

 -----BEGIN PGP SIGNATURE-----

 iF0EABECAB0WIQQlDTvPcScNjKREqWEdvV51g5nhuwUCZGi/nwAKCRAdvV51g5nh
 u3qJAJ48gMPIpdPBw8QsJePNAyaBWGBfTQCfT0fSbwoUvNi92x8mHiRq/3pC4KI=
 =OM23
 -----END PGP SIGNATURE-----

 --jafmte2hxhrtko4w--

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.