NetBSD Problem Report #51893
From www@NetBSD.org Sun Jan 15 21:29:47 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 "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 43C957A20E
for <gnats-bugs@gnats.NetBSD.org>; Sun, 15 Jan 2017 21:29:47 +0000 (UTC)
Message-Id: <20170115212941.DC8F47A2BD@mollari.NetBSD.org>
Date: Sun, 15 Jan 2017 21:29:41 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] tests/lib/libc/ssp/h_memset: prevent toolchain from optimizing out memset call
X-Send-Pr-Version: www-1.0
>Number: 51893
>Category: bin
>Synopsis: [PATCH] tests/lib/libc/ssp/h_memset: prevent toolchain from optimizing out memset call
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jan 15 21:30:01 +0000 2017
>Closed-Date: Mon Jan 16 18:45:08 +0000 2017
>Last-Modified: Mon Jan 16 18:45:08 +0000 2017
>Originator: Ngie Cooper
>Release: 7.0.2
>Organization:
>Environment:
n/a
>Description:
Peter Holm (pholm@FreeBSD.org) discovered that h_memset's memset call was being compiled out by an earlier version of clang (3.3.x/3.4.x) -- this change uses the result of the memset (b[0]) to ensure that the call to memset isn't over ambitiously optimized out by the toolchain.
Submitted by: Peter Holm <pholm@FreeBSD.org>
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51893: [PATCH] tests/lib/libc/ssp/h_memset: prevent toolchain
from optimizing out memset call
Date: Sun, 15 Jan 2017 13:34:53 -0800
--Apple-Mail=_4FC2B394-64E4-4066-A7B5-FBCDED173B3C
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
Patch attached.
-Ngie
--Apple-Mail=_4FC2B394-64E4-4066-A7B5-FBCDED173B3C
Content-Disposition: attachment;
filename=h_memset-return-b_0-to-prevent-memset-optimization.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="h_memset-return-b_0-to-prevent-memset-optimization.patch"
Content-Transfer-Encoding: 7bit
Index: lib/libc/ssp/h_memset.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/ssp/h_memset.c,v
retrieving revision 1.1
diff -u -r1.1 h_memset.c
--- lib/libc/ssp/h_memset.c 27 Dec 2010 02:04:19 -0000 1.1
+++ lib/libc/ssp/h_memset.c 15 Jan 2017 21:27:18 -0000
@@ -41,5 +41,5 @@
char b[10];
size_t len = atoi(argv[1]);
(void)memset(b, 0, len);
- return 0;
+ return b[0]; /* keeps optimizer from zapping the call to memset() */
}
--Apple-Mail=_4FC2B394-64E4-4066-A7B5-FBCDED173B3C--
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51893 CVS commit: src/tests/lib/libc/ssp
Date: Mon, 16 Jan 2017 11:34:24 -0500
Module Name: src
Committed By: christos
Date: Mon Jan 16 16:34:24 UTC 2017
Modified Files:
src/tests/lib/libc/ssp: h_memset.c
Log Message:
PR/51893: Ngie Cooper: prevent toolchain from optimizing out memset call
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_memset.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Mon, 16 Jan 2017 18:45:08 +0000
State-Changed-Why:
christos committed it. thanks!
>Unformatted:
(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.