GNU bug report logs - #74296
[PATCH 0/1] Fix abi mismatch error on boot for cross-compiled images

Previous Next

Package: guix-patches;

Reported by: Christoph Buck <dev <at> icepic.de>

Date: Sun, 10 Nov 2024 17:42:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#74296: closed ([PATCH 0/1] Fix abi mismatch error on boot for
 cross-compiled images)
Date: Mon, 18 Nov 2024 10:08:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 18 Nov 2024 11:07:24 +0100
with message-id <87cyisg8ir.fsf <at> gnu.org>
and subject line Re: [bug#74296] [PATCH 0/1] Fix abi mismatch error on boot for cross-compiled images
has caused the debbugs.gnu.org bug report #74296,
regarding [PATCH 0/1] Fix abi mismatch error on boot for cross-compiled images
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
74296: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74296
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Christoph Buck <dev <at> icepic.de>
To: guix-patches <at> gnu.org
Cc: Christoph Buck <dev <at> icepic.de>
Subject: [PATCH 0/1] Fix abi mismatch error on boot for cross-compiled images
Date: Sun, 10 Nov 2024 17:43:39 +0100
Hi!

The following patch fixes the `record-abi-mismatch-error` early on boot during
execution of initrd.cpio.gz if the image was cross-compiled on x64 for an
32bit platform (e.g arm32 or i868).

For a comprehensive analysis see the correspond thread [1] on the guix-help
mailing list.

The root cause of the issue is as follows:

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] this
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 positive
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 after
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 where
ulong is 8bytes big). Do this by right shift the hash value 32bits and don't
rely on the size parameter of the `string-hash` function. This is what this
patch tries to accomplish.

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 will
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 severe
this change is.


[1] ABI mismatch on boot on arm32 system

(https://lists.gnu.org/archive/html/help-guix/2024-11/msg00022.html)


Christoph Buck (1):
  guix: records: Fix abi check in cross compile context

 guix/records.scm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)


base-commit: 2a6d96425eea57dc6dd48a2bec16743046e32e06
-- 
2.45.1



[Message part 3 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: Christoph Buck <dev <at> icepic.de>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, 74296-done <at> debbugs.gnu.org,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#74296] [PATCH 0/1] Fix abi mismatch error on boot for
 cross-compiled images
Date: Mon, 18 Nov 2024 11:07:24 +0100
Hi,

Christoph Buck <dev <at> icepic.de> skribis:

> Ludovic Courtès <ludo <at> gnu.org> writes:

[...]

>> I believe the ABI break is fine too: developers will have to
>> “make clean-go && make”, but that’s okay.
>
> Good to know.

I added a summary of your explanation as a comment in the code, so our
future selves get an idea of why things are done this way, and pushed as
23cbbe6860782c5d4a0ba599ea1cda0642e91661.

Time for “make clean-go && make”!

Thanks,
Ludo’.


This bug report was last modified 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.