From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id EJ1tMBHaM2ezAAAA62LTzQ:P1 (envelope-from ) for ; Tue, 12 Nov 2024 22:43:29 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id EJ1tMBHaM2ezAAAA62LTzQ (envelope-from ) for ; Tue, 12 Nov 2024 23:43:29 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=hUKjrAVh; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=CxJR7cOq; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731451409; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8zzF1Q9wqZZ8fAWC0n0dDDv7kBLrSxEeJO4a1FbiEKc=; b=WrfsU4W6nNNwYi9NFE0Wa3Z0HSx4CAw5+iHmY9NeCcclRKjBrVnyhXA2D+Kf3NokWWA+Lc wZxHqyRPngviacBkts0XDtVZFUhklDwBGF4XVSJqIZ3g1tJzXrFk7EUdF/ED+JFUiJmlHj iP/ZGHGl/vDlqoASy+Fxwo50QiDuD9XrsPrqdykx15qIttSR0q2BXGMPGghesQTRe8pkFL prHqaL905fVguvvrjzX9sxXC88FknKa4CT7Pq7dKAx/poFA/87CmBUb8uU3qJQNLFHd1C1 PnY01WQ2SVQlEWnp67veB1DBOV7nU6uYGtwx3+R8EDCsmnRrH74QSw8ljX41Mg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731451409; a=rsa-sha256; cv=none; b=Udj2cLTy0+7gXqEVV8KxnKz5B+JweIVhvvJNc5O3AeiTC7PZjD9N4wN63CUL3enr2M1VTU 2j4JAG7Rgfnq93aa/5fySJgkh2ZjzIGsAsTOT45n4MzgIyScETZpB/ZnhGf4aSdYO+GEkF E6BMbvKhWSVGuaT5L3D998V6y4JyXw/4pRl9m5sdzRLuE81qxhxMF8o4o0H9uZgQ01MMtz mTo736cAndmRNpZDgujtgB9du5uihh9IFuq0IqLU0kvGKjtyQ90GWP4i0pYd5p/fOjUKAb 0WXv8CZM6fQhCoz8Oj/UAIOTnNOBbw18B+Sj8/bpq6UgqX0icm9BUxCJfYld/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=hUKjrAVh; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=CxJR7cOq; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 759767E52E for ; Tue, 12 Nov 2024 23:43:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAzbG-00022e-Ar; Tue, 12 Nov 2024 17:43:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAzbC-00022N-Of for guix-patches@gnu.org; Tue, 12 Nov 2024 17:43:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tAzbC-0003El-GU for guix-patches@gnu.org; Tue, 12 Nov 2024 17:43:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=8zzF1Q9wqZZ8fAWC0n0dDDv7kBLrSxEeJO4a1FbiEKc=; b=hUKjrAVhZqXIuJ3XgVi9jQ2bAWLg+qeunB39B+B+z18+iGF/1xKtAoQbuZHYDSkOd0JkwPyISBJCujVf633e6+UcIT8BAdHd1hcxPFTV+rX3RKZFNGcPMN8WOQXH1TLpF3ScbzksU3Jz2JGkpZPqyt97I/L9YHfyPbLv1U7vMn8/9h0ioBJMzAq0xzmAjndljLC4oA3Y6Aa51yyRxxL3PPXQDiMllBCZcT/shFFS5AYmWruRD1LY4V7Gf2MlBqMdBJItzOSw8yvmCI6vlBf/zYaTul0pBZsdDNDUMRS2cuob+hl279ze9jWm1Q36KJPkbApZ25QCbbcxtYSK4BqGYA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tAzbC-0000gB-4g for guix-patches@gnu.org; Tue, 12 Nov 2024 17:43:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74296] [PATCH 0/1] Fix abi mismatch error on boot for cross-compiled images Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 12 Nov 2024 22:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74296 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christoph Buck Cc: Josselin Poiret , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , 74296@debbugs.gnu.org, Christopher Baines Received: via spool by 74296-submit@debbugs.gnu.org id=B74296.17314513532573 (code B ref 74296); Tue, 12 Nov 2024 22:43:02 +0000 Received: (at 74296) by debbugs.gnu.org; 12 Nov 2024 22:42:33 +0000 Received: from localhost ([127.0.0.1]:39821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAzai-0000fO-C4 for submit@debbugs.gnu.org; Tue, 12 Nov 2024 17:42:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAzag-0000fC-4n for 74296@debbugs.gnu.org; Tue, 12 Nov 2024 17:42:31 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAzYR-00032j-Vc; Tue, 12 Nov 2024 17:40:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=8zzF1Q9wqZZ8fAWC0n0dDDv7kBLrSxEeJO4a1FbiEKc=; b=CxJR7cOqTd3mpsaiAfTs mpWmuz+aW5JWQ5nnPus72O8pvnuiAlTQ7jYqQ9nBxLTlvP2wGP7w5A+5STa9vbhRbrzxWm5s1/T3v ZsZ5Mp4oTaVhWNNgkn0gzd1ksInLVDMLnXTTwLFnpK3bpngmqDHPsHC+ybpHGOQtoOIGlV876MLow YTmAwPaxienFdDEm2PK01emt733TsfS6nFxtC/xjzmuq4NmekokZnhxd98kFy2F7QBw4qRVvmUC35 4rV3DH7TndLxoiU9KFk+UOIObFS9wcSDwjL7SWki0EYIFDEBucOKQobOwvwrWggwjigzs26eL8x8l 0/Gz3waqiHyorw==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (Christoph Buck's message of "Sun, 10 Nov 2024 17:43:39 +0100") References: Date: Tue, 12 Nov 2024 23:40:08 +0100 Message-ID: <87o72krs8n.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -1.83 X-Spam-Score: -1.83 X-Migadu-Queue-Id: 759767E52E X-Migadu-Scanner: mx13.migadu.com X-TUID: KeKef6Y/Cl4p Hi Christoph, Christoph Buck skribis: > During compilation guix stores a hash of the record field names in the > compiled go files. On runtime this has is recalcuated and checked against= the > stored hash to verify that no abi mismatch occured. As described in [1] t= his > hash differs if the corresponding record was compiled in a cross-compiled > context. Guile uses internally an `unsigned long` to store the hash, which > results in hashes of different sizes depending on the platform the guile > compiler is executed on. Guix already tries to work around this problem by > limiting the size of the hash in a cross-compile context to the most posi= tive > fixnum size of the target, but this is insufficient, because, as one can = look > up in the guile source code, the size is limited by an modulo operation a= fter > the hash was already calculated for an 8byte unsigned long. Therefore the > resulting hashes during compilation and execution are different and an abi > mismatch error is erroneously reported during runtime. > > An easy workaround is documented in the guile src namely in an comment of= the > `JENKINS_LOOKUP3_HASHWORD2`, which is used to calculate the hash: > >> Scheme can access symbol-hash, which exposes this value. For >>cross-compilation reasons, we ensure that the high 32 bits of the hash on= a >>64-bit system are equal to the hash on a 32-bit system. The low 32 bits = just >>add more entropy. > > This suggest the following workaround. Always limit the hash size to 32bit > even if executed on a 64bit platform (or to be more specific a platform w= here > ulong is 8bytes big). Do this by right shift the hash value 32bits and do= n't > rely on the size parameter of the `string-hash` function. This is what th= is > patch tries to accomplish. Woow, thanks for the investigation & explanation! (I would say that the =E2=80=98scm_ihash=E2=80=99 implementation as a mere = modulo is dubious, but that=E2=80=99s hard to change anyway.) > Imho this approach has two drawbacks. Lost entropy on 64 bit machines and= the > abi break because on new compilation the hash values on 64bit platforms w= ill > change. The lost entropy is irrelevant because the hash is not used in an > cryptophically relevant context. For the abi break i am not sure how seve= re > this change is. Capping at 32-bits means that potentially some ABI changes could go unnoticed, but that=E2=80=99s extremely unlikely if the hash function is go= od enough. I believe the ABI break is fine too: developers will have to =E2=80=9Cmake clean-go && make=E2=80=9D, but that=E2=80=99s okay. Thoughts? Opinions? Ludo=E2=80=99.