Received: by mail.netbsd.org (Postfix, from userid 605) id 4D1A1853BD; Fri, 6 May 2022 04:49:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 02DE284CF8 for ; Fri, 6 May 2022 04:49:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id v8jBwfHdUWV9 for ; Fri, 6 May 2022 04:49:14 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 11C82853B4 for ; Fri, 6 May 2022 04:49:13 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id E8584FB1A; Fri, 6 May 2022 04:49:13 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Fri, 6 May 2022 04:49:13 +0000 From: "Rin Okuyama" Subject: CVS commit: src/lib/libc/gmon To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20220506044913.E8584FB1A@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Rin Okuyama" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: rin Date: Fri May 6 04:49:13 UTC 2022 Modified Files: src/lib/libc/gmon: gmon.c Log Message: PR lib/56395 PR toolchain/56771 Fix profiling on CPUs that do not support unaligned memory access; Allocate objects (referenced from struct gmonparam) with proper alignments. For monstartup(), objects are allocated on heap. Break is not guaranteed to be aligned at all, unlike stack pointer. For _m_gmon_alloc(), objects are allocated on anonymous memory. p->tos is not aligned properly in general. This fixes quasi-random crashes for *_profile tests, at least on SH-4 and PowerPC 403 [1]. Also, no regression is observed for others as far as I can see. This change does not cause any ABI breakage, as long as application uses proper pointers; use p->tos instead of evil pointer arithmetic like (struct tostruct *)((char *)p->froms + p->fromssize) [2]. [1] Timeout should be increased for some tests. "pic" variants still fail as expected. Dynamically-linked binaries also crash in rtld for SH-4, but this seems different problem... [2] This example did not work even before, since the order of froms[] and tos[] is reversed depending on which of monstartup() or _m_gmon_alloc() is used for allocation. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libc/gmon/gmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.