bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Utf8 error


From: Ludovic Courtès
Subject: Re: Utf8 error
Date: Wed, 30 Jan 2013 23:23:38 +0100
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)

Andreas Enge <address@hidden> skribis:

>  385: 2 [process-stderr #]
>  170: 1 [read-string #<input-output: socket 5>]
> In unknown file:
>    ?: 0 [utf8->string #vu8(115 97 109 112 108 101 95 114 97 116 101 95 105 

That’s because the build log contains a non-UTF-8 sequence, and
store.scm expects UTF-8 (for no good reason).

The attached patch removes that UTF-8 assumption.  Can you test whether
it fixes the problem?

diff --git a/guix/store.scm b/guix/store.scm
index 668bc9a..560e567 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -175,6 +175,14 @@
         (get-bytevector-n p (- 8 m)))
     str))
 
+(define (read-latin1-string p)
+  (let* ((len (read-int p))
+         (m   (modulo len 8))
+         (str (get-string-n p len)))
+    (or (zero? m)
+        (get-bytevector-n p (- 8 m)))
+    str))
+
 (define (write-string-list l p)
   (write-int (length l) p)
   (for-each (cut write-string <> p) l))
@@ -362,7 +370,11 @@ operate, should the disk become full.  Return a server 
object."
   "Read standard output and standard error from SERVER, writing it to
 CURRENT-BUILD-OUTPUT-PORT.  Return #t when SERVER is done sending data, and
 #f otherwise; in the latter case, the caller should call `process-stderr'
-again until #t is returned or an error is raised."
+again until #t is returned or an error is raised.
+
+Since the build process's output cannot be assumed to be UTF-8, we
+conservatively consider it to be Latin-1, thereby avoiding possible
+encoding conversion errors."
   (define p
     (nix-server-socket server))
 
@@ -375,18 +387,18 @@ again until #t is returned or an error is raised."
 
   (let ((k (read-int p)))
     (cond ((= k %stderr-write)
-           (read-string p)
+           (read-latin1-string p)
            #f)
           ((= k %stderr-read)
            (let ((len (read-int p)))
-             (read-string p)                      ; FIXME: what to do?
+             (read-latin1-string p)               ; FIXME: what to do?
              #f))
           ((= k %stderr-next)
-           (let ((s (read-string p)))
+           (let ((s (read-latin1-string p)))
              (display s (current-build-output-port))
              #f))
           ((= k %stderr-error)
-           (let ((error  (read-string p))
+           (let ((error  (read-latin1-string p))
                  (status (if (>= (nix-server-minor-version server) 8)
                              (read-int p)
                              1)))
Thanks,
Ludo’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]