unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Philip McGrath <philip@philipmcgrath.com>,
	Jack Hill <jackhill@jackhill.us>,
	47064@debbugs.gnu.org
Subject: bug#47064: [racket-users] bytevector-uncompress: internal error uncompressing
Date: Wed, 14 Apr 2021 01:54:54 -0400	[thread overview]
Message-ID: <87o8ehquk6.fsf@netris.org> (raw)
In-Reply-To: <53940c03-4f40-3954-0cb4-3d4ae01c39a2@philipmcgrath.com>

Hi Philip,  [removed 'racket-users' from the recipient list]

Philip McGrath <philip@philipmcgrath.com> writes:

> My guess is that Racket CS is compressing string literals in compiled 
> code. Currently, Guix patches Racket source files to include the 
> absolute paths to foreign libraries in the store as string literals. 
> There are a bunch of grafts for GTK and such: if I'm right, Guix somehow 
> mangles the compiled code while attempting to apply the grafts.

I think I know what happened here.

Recall that the grafting code performs a set of substitutions, replacing
store item names (i.e. file names in /gnu/store) with replacement store
items of the same length, with rules like:
"fx3979c88s9yxdbchyf36qryawgzpwb5-libx11-1.6.10" =>
"rwkqxykm91a75w9afhb41saj0dmf30hw-libx11-1.6.12".

The grafting code currently only checks the first 33 bytes, consisting
of the nix-base32 hash and the "-".  It *assumes* that the remainder of
the associated store item name immediately follows, and blindly writes
the replacement string over whatever is there.

In this case, I suspect that within a *.zo file, a Guix store item name
was split into pieces, with the hash and "-" together in one piece but
split somewhere between the "-" and the last byte of the store item.
This results in corruption of the bytes following that piece.

I've recently observed the splitting of store item names in *.zo files
(see <https://bugs.gnu.org/47614>), but in that case the "-" was
separated from the hash, and as a result the reference was _invisible_
to the grafter.

For the record, when I originally wrote this fast(er) grafting code
(commit 5a1add373ab427a3b336981d857252e703a9f8d1), by design it only
rewrote the hashes, and so naturally it had the following desirable
property: it never overwrote any byte without first checking it against
an expected value.  Later, starting in commit
57bdd79e485801ccf405ca7389bd099809fe5d67, the grafting code was modified
to allow rewriting the entire store item name (notably including the
version number).  Unfortunately, although the set of overwritten bytes
was extended past the "-", the set of bytes *checked* was left
unchanged, and thus the aforementioned desirable property was lost.

I think we ought to restore that property.  I'm already working on some
other changed to the grafting code (supporting UTF-16 and UTF-32 encoded
references), so I'll try to find the time to fix this problem as well.

    Regards,
      Mark




  parent reply	other threads:[~2021-04-14  5:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.DEB.2.21.2103150040230.8138@marsh.hcoop.net>
2021-03-15 21:38 ` bug#47064: [racket-users] bytevector-uncompress: internal error uncompressing Philip McGrath
2021-03-15 22:26   ` Philip McGrath
2021-03-15 22:38     ` Philip McGrath
2021-03-16  0:28       ` jackhill
2021-03-16  3:01         ` Philip McGrath
2021-04-14  5:54       ` Mark H Weaver [this message]
2021-04-14 22:03         ` Philip McGrath
2021-04-15  8:44           ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8ehquk6.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=47064@debbugs.gnu.org \
    --cc=jackhill@jackhill.us \
    --cc=philip@philipmcgrath.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).