GNU bug report logs - #62590
Strange put-char encoding-error "conversion to port encoding failed"

Previous Next

Package: guile;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sat, 1 Apr 2023 11:44:02 UTC

Severity: normal

To reply to this bug, email your comments to 62590 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#62590; Package guile. (Sat, 01 Apr 2023 11:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Baines <mail <at> cbaines.net>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 01 Apr 2023 11:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: bug-guile <at> gnu.org
Subject: Strange put-char encoding-error "conversion to port encoding failed"
Date: Sat, 01 Apr 2023 12:37:16 +0100
Hey,

I've been seeing some strange occasional errors for a while now.

Here are some log messages from the guix-build-coordinator:


worker-thread: exception: (encoding-error put-char conversion to port encoding failed 84 #<output: file 1> s)


encoding-error (put-char conversion to port encoding failed 84 #<output: file 1> s)


encoding-error (put-char conversion to port encoding failed 84 #<output: file 1> w)


encoding-error (put-char conversion to port encoding failed
 84 #<output: file 1> 2


  encoding-error (put-char conversion to port encoding fencoding-error (put-char conversion to port encoding failed 84 #<o
utput: file 1> w)
encoding-error (put-char conversion to port encoding failed 84 #<output: file 1> w)


2022-10-02 17:23:38 (ERROR): error running build-success hook: encoding-error (put-char conversion to port encoding failed
 84 #<output: file 1> B)


Throw to key `encoding-error' with args `("put-char" "conversion to port encoding failed" 84 #<output: file 1> #\p)'.

2022-10-02 21:21:37 (ERROR): error running build-success hook: misc-error (#f ~A (error: command failed (1): (/gnu/store/6


Throw to key `encoding-error' with args `("put-char" "conversion to port encoding failed" 84 #<output: file 1> #\space)'.


Throw to key `encoding-error' with args `("put-char" "conversion to port encoding failed" 84 #<output:
 file 1> #\2)'.



I'm not sure what the 84 means? If I'm picking out the characters that
have failed to be encoded, I'm not sure why some of these would fail
(like space or w)?

Unfortunately I'm not sure how to reproduce this. Suspendable ports
might be a factor here as that is probably in use.




Information forwarded to bug-guile <at> gnu.org:
bug#62590; Package guile. (Sun, 21 Jan 2024 04:02:01 GMT) Full text and rfc822 format available.

Message #8 received at 62590 <at> debbugs.gnu.org (full text, mbox):

From: Felix Lechner <felix.lechner <at> lease-up.com>
To: 62590 <at> debbugs.gnu.org
Cc: Christopher Baines <mail <at> cbaines.net>
Subject: Re: bug#62590: Strange put-char encoding-error "conversion to port
 encoding failed"
Date: Sat, 20 Jan 2024 20:01:22 -0800
Hi,

> (encoding-error put-char conversion to port encoding failed 84
> #<output: file 1> s)

Could the error be due to the 7-bit encoding in HTTP headers? [1] The
"84" is EILSEQ from errno.h. [2] Wingo added the functionality here. [3]

I also submitted a patch to resolve in the errno. [4]

A similar issue appeared in Guix's Cuirass. [5]

Kind regards
Felix

[1] https://lists.gnu.org/archive/html/guile-user/2020-09/msg00015.html
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/errno.h#n67
[3] https://git.savannah.gnu.org/cgit/guile.git/commit/?id=43b6feeb1adafe54170304e7cc3c29a15c1d3808
[4] https://debbugs.gnu.org/68624
[5] https://debbugs.gnu.org/59510




Information forwarded to bug-guile <at> gnu.org:
bug#62590; Package guile. (Tue, 11 Feb 2025 18:30:02 GMT) Full text and rfc822 format available.

Message #11 received at 62590 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: 62590 <at> debbugs.gnu.org
Subject: Re: bug#62590: Strange put-char encoding-error "conversion to port
 encoding failed"
Date: Tue, 11 Feb 2025 18:29:43 +0000
[Message part 1 (text/plain, inline)]
Christopher Baines <mail <at> cbaines.net> writes:

> I've been seeing some strange occasional errors for a while now.

...

> I'm not sure what the 84 means? If I'm picking out the characters that
> have failed to be encoded, I'm not sure why some of these would fail
> (like space or w)?
>
> Unfortunately I'm not sure how to reproduce this. Suspendable ports
> might be a factor here as that is probably in use.

Still seeing these errors, including today. I've managed to stumble on a
reliable and somewhat minimal way of reproducing them:

  /gnu/store/lnlw64i4k06yphjbyr3ciy07mz9snlwg-guile-next-3.0.10-0.5d3f561/bin/guile  put-char-exn.scm > /dev/null

The output is somewhat variable, but on my system within a few seconds
it will output something like:

current-output-port: #<output: file 1> (encoding: UTF-8)

In ice-9/boot-9.scm:
  1762:12 17 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In unknown file:
          16 (apply-smob/0 #<thunk 7f5dd6953fa0>)
In ice-9/threads.scm:
   165:20 15 (_)
In unknown file:
          14 (call-with-unblocked-asyncs #<procedure 7f5dd6953f40 at ice-9/thread…>)
In ice-9/boot-9.scm:
  1756:15 13 (with-exception-handler #<procedure 7f5dd6956fc0 at ice-9/boot-9.sc…> …)
  1762:12 12 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
   2217:5 11 (%start-stack thread _)
   2219:9 10 (_)
  1762:12  9 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In /home/chris/Projects/Guile/guile/put-char-exn.scm:
    43:12  8 (_)
In unknown file:
           7 (simple-format #<output: file 1> "exception: ~A\n" #<&compound-excep…>)
In ice-9/boot-9.scm:
   1058:8  6 (default-record-printer #<&compound-exception components: (#<&exter…> …)
In unknown file:
           5 (write (#<&external-error> #<&origin origin: "fport_write"> #<&m…> …) …)
In ice-9/boot-9.scm:
   1050:4  4 (default-record-printer #<&origin origin: "fport_write"> #<output: f…>)
In unknown file:
           3 (display &origin #<output: file 1>)
In ice-9/boot-9.scm:
  1683:22  2 (raise-exception _ #:continuable? _)
In /home/chris/Projects/Guile/guile/put-char-exn.scm:
    29:25  1 (_ #<&compound-exception components: (#<&error> #<&origin origin: "p…>)
In unknown file:
           0 (make-stack #t)
ERROR: In procedure display:
ERROR:
  1. &error
  2. &origin: "put-char"
  3. &message: "conversion to port encoding failed"
  4. &irritants: 84
  5. &exception-with-kind-and-args:
      kind: encoding-error
      args: ("put-char" "conversion to port encoding failed" 84 #<output: file 1> #\&)


put-char-exn.scm:

[put-char-exn.scm (text/plain, inline)]
(use-modules (ice-9 suspendable-ports)
             (ice-9 binary-ports)
             (rnrs bytevectors)
             (ice-9 exceptions)
             (ice-9 threads)
             (system repl debug))

(install-suspendable-ports!)

(setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) 'line)

(define s
  (socket PF_UNIX
          (logior SOCK_STREAM SOCK_CLOEXEC SOCK_NONBLOCK)
          0))

(simple-format (current-error-port)
               "current-output-port: ~A (encoding: ~A)\n\n"
               (current-output-port)
               (port-encoding (current-output-port)))

(for-each
 (lambda (i)
   (call-with-new-thread
    (lambda ()
      (with-exception-handler
          (lambda (exn)
            (let ((stack (make-stack #t)))
              (print-frames (stack->vector stack)
                            (current-error-port)
                            #:count (stack-length stack))
              (print-exception
               (current-error-port)
               (stack-ref stack 3)
               '%exception
               (list exn)))
            (force-output (current-error-port))

            (primitive-exit 1))
        (lambda ()
          (while #t
            (with-exception-handler
                (lambda (exn)
                  (simple-format (current-output-port)
                                 "exception: ~A\n"
                                 exn))
              (lambda ()
                (with-throw-handler #t
                  (lambda ()
                    (put-bytevector s
                                    (string->utf8 "foo")))
                  (lambda (key . args)
                    (let* ((stack (make-stack #t 3))
                           (backtrace
                            (call-with-output-string
                              (lambda (port)
                                (display-backtrace stack port)
                                (newline port)))))
                      (display
                       backtrace
                       (current-output-port))))))
              #:unwind? #t)))))))
 (iota 2))

(sleep 60)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#62590; Package guile. (Tue, 11 Feb 2025 19:07:02 GMT) Full text and rfc822 format available.

Message #14 received at 62590 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: 62590 <at> debbugs.gnu.org
Subject: Re: bug#62590: Strange put-char encoding-error "conversion to port
 encoding failed"
Date: Tue, 11 Feb 2025 19:06:46 +0000
[Message part 1 (text/plain, inline)]
Christopher Baines <mail <at> cbaines.net> writes:

> Christopher Baines <mail <at> cbaines.net> writes:
>
>> I've been seeing some strange occasional errors for a while now.
>
> ...
>
>> I'm not sure what the 84 means? If I'm picking out the characters that
>> have failed to be encoded, I'm not sure why some of these would fail
>> (like space or w)?
>>
>> Unfortunately I'm not sure how to reproduce this. Suspendable ports
>> might be a factor here as that is probably in use.
>
> Still seeing these errors, including today. I've managed to stumble on a
> reliable and somewhat minimal way of reproducing them:

Here's a slightly simplified version with some comments:

[put-char-exn.scm (text/plain, inline)]
(use-modules (ice-9 binary-ports)
             (rnrs bytevectors)
             (ice-9 exceptions)
             (ice-9 threads)
             (system repl debug))

(setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) 'line)

(simple-format (current-error-port)
               "current-output-port: ~A (encoding: ~A)\n\n"
               (current-output-port)
               (port-encoding (current-output-port)))

(for-each
 (lambda (i)
   (call-with-new-thread
    (lambda ()
      (with-exception-handler
          (lambda (exn)
            (let ((stack (make-stack #t)))
              (print-frames (stack->vector stack)
                            (current-error-port)
                            #:count (stack-length stack))
              (print-exception
               (current-error-port)
               (stack-ref stack 3)
               '%exception
               (list exn)))
            (force-output (current-error-port))

            (primitive-exit 1))
        (lambda ()
          (while #t
            (with-exception-handler
                (lambda (exn)
                  ;; The put-char error seems to happen around here
                  (simple-format (current-output-port)
                                 "exception: ~A\n"
                                 exn)
                  #f)
              (lambda ()
                (with-throw-handler #t
                  (lambda ()
                    ;; Cause some error, I think any error will do
                    (+ 'a 1))
                  (lambda (key . args)
                    (let* ((stack (make-stack #t 3))
                           (backtrace
                            (call-with-output-string
                              (lambda (port)
                                (display-backtrace stack port)
                                (newline port)))))
                      (display
                       ;; Printing the backtrace seems significant,
                       ;; other strings don't seem to reproduce the
                       ;; behaviour
                       backtrace
                       (current-output-port))
                      #f))))
              #:unwind? #t)))))))
 (iota 2))

(sleep 60)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#62590; Package guile. (Tue, 11 Feb 2025 21:57:01 GMT) Full text and rfc822 format available.

Message #17 received at 62590 <at> debbugs.gnu.org (full text, mbox):

From: bokr <at> bokr.com
To: Christopher Baines <mail <at> cbaines.net>
Cc: 62590 <at> debbugs.gnu.org
Subject: Re: bug#62590: Strange put-char encoding-error "conversion to port
 encoding failed"
Date: Tue, 11 Feb 2025 13:55:37 -0800
I'm wondering what writing the backtrace to a /tmp/file and doing a cat -nA on it would show.
(to get the traceback bits presented by independent alternate formatting machinery
from what produced what you've seen so far).


On +2025-02-11 19:06:46 +0000, Christopher Baines wrote:
> Christopher Baines <mail <at> cbaines.net> writes:
> 
> > Christopher Baines <mail <at> cbaines.net> writes:
> >
> >> I've been seeing some strange occasional errors for a while now.
> >
> > ...
> >
> >> I'm not sure what the 84 means? If I'm picking out the characters that
> >> have failed to be encoded, I'm not sure why some of these would fail
> >> (like space or w)?
> >>
> >> Unfortunately I'm not sure how to reproduce this. Suspendable ports
> >> might be a factor here as that is probably in use.
> >
> > Still seeing these errors, including today. I've managed to stumble on a
> > reliable and somewhat minimal way of reproducing them:
> 
> Here's a slightly simplified version with some comments:
> 

> (use-modules (ice-9 binary-ports)
>              (rnrs bytevectors)
>              (ice-9 exceptions)
>              (ice-9 threads)
>              (system repl debug))
> 
> (setvbuf (current-output-port) 'line)
> (setvbuf (current-error-port) 'line)
> 
> (simple-format (current-error-port)
>                "current-output-port: ~A (encoding: ~A)\n\n"
>                (current-output-port)
>                (port-encoding (current-output-port)))
> 
> (for-each
>  (lambda (i)
>    (call-with-new-thread
>     (lambda ()
>       (with-exception-handler
>           (lambda (exn)
>             (let ((stack (make-stack #t)))
>               (print-frames (stack->vector stack)
>                             (current-error-port)
>                             #:count (stack-length stack))
>               (print-exception
>                (current-error-port)
>                (stack-ref stack 3)
>                '%exception
>                (list exn)))
>             (force-output (current-error-port))
> 
>             (primitive-exit 1))
>         (lambda ()
>           (while #t
>             (with-exception-handler
>                 (lambda (exn)
>                   ;; The put-char error seems to happen around here
>                   (simple-format (current-output-port)
>                                  "exception: ~A\n"
>                                  exn)
>                   #f)
>               (lambda ()
>                 (with-throw-handler #t
>                   (lambda ()
>                     ;; Cause some error, I think any error will do
>                     (+ 'a 1))
>                   (lambda (key . args)
>                     (let* ((stack (make-stack #t 3))
>                            (backtrace
>                             (call-with-output-string
>                               (lambda (port)
>                                 (display-backtrace stack port)
>                                 (newline port)))))
>                       (display
>                        ;; Printing the backtrace seems significant,
>                        ;; other strings don't seem to reproduce the
>                        ;; behaviour
>                        backtrace
>                        (current-output-port))
>                       #f))))
>               #:unwind? #t)))))))
>  (iota 2))
> 
> (sleep 60)







This bug report was last modified 20 days ago.

Previous Next


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