From owner-freebsd-arch@FreeBSD.ORG Fri Feb 6 16:27:16 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3BE77E0 for ; Fri, 6 Feb 2015 16:27:16 +0000 (UTC) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0140.outbound.protection.outlook.com [157.56.111.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D01D994F for ; Fri, 6 Feb 2015 16:27:15 +0000 (UTC) Received: from CO2PR05CA019.namprd05.prod.outlook.com (10.141.241.147) by DM2PR05MB448.namprd05.prod.outlook.com (10.141.104.152) with Microsoft SMTP Server (TLS) id 15.1.75.20; Fri, 6 Feb 2015 16:27:07 +0000 Received: from BN1AFFO11OLC001.protection.gbl (2a01:111:f400:7c10::135) by CO2PR05CA019.outlook.office365.com (2a01:111:e400:1429::19) with Microsoft SMTP Server (TLS) id 15.1.81.19 via Frontend Transport; Fri, 6 Feb 2015 16:27:07 +0000 Received: from P-EMF02-SAC.jnpr.net (66.129.239.16) by BN1AFFO11OLC001.mail.protection.outlook.com (10.58.53.72) with Microsoft SMTP Server (TLS) id 15.1.87.10 via Frontend Transport; Fri, 6 Feb 2015 16:27:06 +0000 Received: from magenta.juniper.net (172.17.27.123) by P-EMF02-SAC.jnpr.net (172.24.192.21) with Microsoft SMTP Server (TLS) id 14.3.146.0; Fri, 6 Feb 2015 08:27:05 -0800 Received: from chaos.jnpr.net (chaos.jnpr.net [172.21.16.28]) by magenta.juniper.net (8.11.3/8.11.3) with ESMTP id t16GR5W98624; Fri, 6 Feb 2015 08:27:05 -0800 (PST) (envelope-from sjg@juniper.net) Received: from chaos (localhost [127.0.0.1]) by chaos.jnpr.net (Postfix) with ESMTP id D68F1580A3; Fri, 6 Feb 2015 08:27:04 -0800 (PST) To: Poul-Henning Kamp Subject: Re: Buggy sbspace() on 64bit builds? In-Reply-To: <37282.1423208201@critter.freebsd.dk> References: <37282.1423208201@critter.freebsd.dk> Comments: In-reply-to: Poul-Henning Kamp message dated "Fri, 06 Feb 2015 07:36:41 +0000." From: "Simon J. Gerraty" X-Mailer: MH-E 8.0.3; nmh 1.3; GNU Emacs 22.3.1 Date: Fri, 6 Feb 2015 08:27:04 -0800 Message-ID: <2705.1423240024@chaos> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:66.129.239.16; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(51704005)(24454002)(106466001)(77096005)(110136001)(77156002)(57986006)(50226001)(92566002)(76506005)(76176999)(50466002)(46102003)(48376002)(62966003)(33716001)(2950100001)(6806004)(47776003)(19580395003)(50986999)(86362001)(19580405001)(117636001)(87936001)(62816006)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR05MB448; H:P-EMF02-SAC.jnpr.net; FPR:; SPF:None; MLV:sfv; LANG:en; Authentication-Results: freebsd.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DM2PR05MB448; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:DM2PR05MB448; X-Forefront-PRVS: 047999FF16 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:DM2PR05MB448; X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2015 16:27:06.7850 (UTC) X-MS-Exchange-CrossTenant-Id: bea78b3c-4cdb-4130-854a-1d193232e5f4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=bea78b3c-4cdb-4130-854a-1d193232e5f4; Ip=[66.129.239.16] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR05MB448 Cc: "freebsd-arch@freebsd.org" , Anuranjan Shukla , sjg@juniper.net X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Feb 2015 16:27:16 -0000 Poul-Henning Kamp wrote: > >Any thoughts on what a fix should be for this? > > size_t or intptr_t ? I don't think so, the bug lies in the fact that on 64bit long is much bigger than the uint's that are being manipulated. Using a result object the same size works. Here's a simple demo of the problem: #include #include #include int main(int argc, char *argv[]) { uint a, b; long r1; int r2; a = 1; b = 2; r1 = a - b; r2 = a - b; printf("r1=%ld\nr2=%d\n", r1, r2); exit(0); } 32bit version outputs: r1=-1 r2=-1 64bit version outputs: r1=4294967295 r2=-1 the r1 value is obviously not what is expected by the caller.