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:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 30 14:50:00 +0000 2017
>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.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.