From patchwork Tue Feb 12 12:08:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 1040543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-495937-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="el9oGFOt"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43zLz52LXzz9sN1 for ; Tue, 12 Feb 2019 23:08:32 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=Ge8sdMysJM5vUjEdoeEkjaM+pa0beSX5rFTakr4hWIKfPubl3Bd5/ JgZQ7A6Xq7caOARaDurvTWa+yovLbfKIoSMfImaGaxl75HCj9+93UivfAc2uMfeF Bz3aTKlJfbuWAYPp60tRu1YOsL50tTBp94YR9brahbpK5fiX/jgT2g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=c+mJ8mgPcxOk8yf8Fhd8Y2EtX8w=; b=el9oGFOtlNVa+7JhEmOY IMjvWR16W5pmYy+tuwKXpSzQn/cMTeFkntJ0ZNtG6HwnHXbnhJQHh1mXWBE+diba E8yHEe8X3Ljmb3XRMdrh3FUhRuQdnzgFbDJPf8EUqzqYck+p8EGbShblZiAVZ79S Imfyv9Uh3yqQ5pL7BRP6844= Received: (qmail 34558 invoked by alias); 12 Feb 2019 12:08:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 34345 invoked by uid 89); 12 Feb 2019 12:08:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:HHH X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-oln040092065109.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (40.92.65.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Feb 2019 12:08:24 +0000 Received: from HE1EUR01FT056.eop-EUR01.prod.protection.outlook.com (10.152.0.60) by HE1EUR01HT154.eop-EUR01.prod.protection.outlook.com (10.152.1.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10; Tue, 12 Feb 2019 12:08:19 +0000 Received: from VI1PR0702MB3840.eurprd07.prod.outlook.com (10.152.0.51) by HE1EUR01FT056.mail.protection.outlook.com (10.152.0.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10 via Frontend Transport; Tue, 12 Feb 2019 12:08:19 +0000 Received: from VI1PR0702MB3840.eurprd07.prod.outlook.com ([fe80::6139:4cf3:fb81:b105]) by VI1PR0702MB3840.eurprd07.prod.outlook.com ([fe80::6139:4cf3:fb81:b105%4]) with mapi id 15.20.1622.016; Tue, 12 Feb 2019 12:08:18 +0000 From: Bernd Edlinger To: "gcc-patches@gcc.gnu.org" , Iain Buclaw Subject: [PATCH] [LIBPHOBOS] Fix ualigned access in murmurhash.d (PR d/89177) Date: Tue, 12 Feb 2019 12:08:18 +0000 Message-ID: x-microsoft-original-message-id: <2fbe9b81-5d2b-f737-98da-c311f0b3c092@hotmail.de> MIME-Version: 1.0 Hi, in the function MurmurHash3::put an unaligned access fault happens on an arm system. The linux kernel is able to emulate the unaligned LDM instruction, but it is still not desirable, to generate code that depends on that. Fixed by the attached patch. Bootstrapped and reg-tested on arm-linux-gnueabihf Is it OK for trunk? Thanks Bernd. 2019-02-08 Bernd Edlinger PR d/89177 * src/std/digest/murmurhash.d (MurmurHash3::put): Avoid unaligned access traps. Index: libphobos/src/std/digest/murmurhash.d =================================================================== --- libphobos/src/std/digest/murmurhash.d (revision 268614) +++ libphobos/src/std/digest/murmurhash.d (working copy) @@ -516,9 +516,11 @@ struct MurmurHash3(uint size /* 32 or 128 */ , uin // Do main work: process chunks of `Element.sizeof` bytes. const numElements = data.length / Element.sizeof; const remainderStart = numElements * Element.sizeof; - foreach (ref const Element block; cast(const(Element[]))(data[0 .. remainderStart])) + for (auto start = 0; start < remainderStart; start += Element.sizeof) { - putElement(block); + BufferUnion buffer; + buffer.data[0 .. $] = data[start .. start + Element.sizeof]; + putElement(buffer.block); } // +1 for bufferLeeway Element. element_count += (numElements + 1) * Element.sizeof;