Subject: [bug#52975] [PATCH] gnu: guile-ssh: Update to 0.15.0

From: Ludovic Courtès <[email-masked]>
Date: Wed, 26 Jan 2022 15:44:28 +0100

Hi Artyom,

Did you have a chance to look into it?  Would be nice to make sure Guix
can use the latest and greatest Guile-SSH!

Ludo’.

Ludovic Courtès <[email-masked]> skribis:

> Hi Artyom,
>
> [email-masked] (Artyom V. Poptsov) skribis:
>
>> Note that I haven't properly tested GNU Guix with the new release of
>> Guile-SSH.
>>
>> As Guix itself uses Guile-SSH and my update may break something, please
>> check if it works as expected before merging the update and report any
>> bugs to me.
>
> I tested it on x86_64-linux and quickly got a segfault:
>
> $ ./pre-inst-env guix offload test
> guix offload: testing 3 build machines defined in '/etc/guix/machines.scm'...
> guix offload: Guix is usable on 'overdrive1.guix.gnu.org' (test returned "/gnu/store/883yjkl46dxw9mzykykmbs0yzwyxm17z-test")
> guix offload: Guix is usable on 'localhost' (test returned "/gnu/store/883yjkl46dxw9mzykykmbs0yzwyxm17z-test")
>
> [...]
>
> Backtrace:
> In ice-9/boot-9.scm:
>     724:2 19 (call-with-prompt _ _ #<procedure default-prompt-handler (k proc)>)
> In ice-9/eval.scm:
>     619:8 18 (_ #(#(#<directory (guile-user) 7f439cd99c80>)))
> In guix/ui.scm:
>    2206:7 17 (run-guix . _)
>   2169:10 16 (run-guix-command _ . _)
> In ice-9/boot-9.scm:
>   1752:10 15 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
> In guix/scripts/offload.scm:
>     724:6 14 (check-machine-availability _ _)
> In srfi/srfi-1.scm:
>    669:15 13 (for-each #<procedure assert-node-can-import (session node name daemon-socket)> (#<session hydra@o…> …) …)
> In ice-9/boot-9.scm:
>   1752:10 12 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
> In guix/store.scm:
>    658:37 11 (thunk)
> In guix/scripts/offload.scm:
>     683:6 10 (_ _)
> In ice-9/boot-9.scm:
>   1752:10  9 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
> In guix/store.scm:
>    658:37  8 (thunk)
> In guix/ssh.scm:
>     370:2  7 (send-files #<store-connection 256.99 7f4398a324b0> _ #<store-connection 256.99 7f4398a32500> # _ # _)
>     219:2  6 (remote-run (begin (use-modules (guix) (srfi srfi-34) (rnrs io ports) (rnrs bytevectors)) (define …) …) …)
> In ice-9/read.scm:
>    850:12  5 (%read #<input-output: channel (open) 7f4398a599a0> #<procedure 7f4398a49640 at ice-9/read.scm:859:8 …> …)
>    118:17  4 (next-non-whitespace)
> In unknown file:
>            3 (read-char #<input-output: channel (open) 7f4398a599a0>)
> In ice-9/boot-9.scm:
>   1685:16  2 (raise-exception _ #:continuable? _)
>   1685:16  1 (raise-exception _ #:continuable? _)
>   1685:16  0 (raise-exception _ #:continuable? _)
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Adres-eraro(nekropsio elŝutita)
> $ gdb ./guile core
> GNU gdb (GDB) 10.2
> Copyright (C) 2021 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Type "show copying" and "show warranty" for details.
> This GDB was configured as "x86_64-unknown-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <https://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
>     <http://www.gnu.org/software/gdb/documentation/>.
>
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from ./guile...
>
> warning: Can't open file /var/db/nscd/hosts during file-backed mapping note processing
>
> warning: core file may not match specified executable file.
> [New LWP 27814]
> [New LWP 27818]
> [New LWP 27821]
> [New LWP 27820]
> [New LWP 27819]
> [New LWP 27822]
> Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error
>
> warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/gnu/store/2fk1gz2s7ppdicynscra9b19byrrr866-glibc-2.33/lib/libthread_db.so.1".
> Core was generated by `/home/ludo/src/guix/guile \ /home/ludo/src/guix/scripts/guix offload test'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0  scm_ipruk (hdr=0x7f439f4b4132 "immediate", ptr=0x7000700070007, port=0x7f4397cf9c80) at print.c:969
> 969	print.c: Dosiero aŭ dosierujo ne ekzistas.
> [Current thread is 1 (Thread 0x7f439ee26740 (LWP 27814))]
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling /gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/lib/libguile-3.0.so.1.4.0-gdb.scm
> ;;; /gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/lib/libguile-3.0.so.1.4.0-gdb.scm:293:20: warning: possibly unbound variable `program-debug-info-name'
> ;;; /gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/lib/libguile-3.0.so.1.4.0-gdb.scm:326:9: warning: possibly unbound variable `find-source-for-addr'
> ;;; /gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/lib/libguile-3.0.so.1.4.0-gdb.scm:326:31: warning: possibly unbound variable `program-debug-info-addr'
> ;;; /gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/lib/libguile-3.0.so.1.4.0-gdb.scm:327:31: warning: possibly unbound variable `program-debug-info-context'
> ;;; compiled /home/ludo/.cache/guile/ccache/3.0-LE-8-4.2/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/lib/libguile-3.0.so.1.4.0-gdb.scm.go
> ;;; compiling /gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/share/guile/3.0/system/base/types.scm
> ;;; compiled /home/ludo/.cache/guile/ccache/3.0-LE-8-4.2/gnu/store/3h3jn0745ngd87zp83k5smwhykxvdfgf-guile-3.0.7/share/guile/3.0/system/base/types.scm.go
> (gdb) bt
> #0  scm_ipruk (hdr=0x7f439f4b4132 "immediate", ptr=unmatched-scm, 
>     port=#<port #<port-type string 7f439cc8bab0> 7f4397cf9c80>) at print.c:969
> #1  0x00007f439f46f617 in scm_i_variable_print (exp=#<variable 201b010>, 
>     port=#<port #<port-type string 7f439cc8bab0> 7f4397cf9c80>, pstate=0x7f439793d938) at variable.c:46
> #2  0x00007f439f4447dc in scm_prin1 (exp=exp@entry=#<variable 201b010>, 
>     port=port@entry=#<port #<port-type string 7f439cc8bab0> 7f4397cf9c80>, writingp=writingp@entry=1) at print.c:840
> #3  0x00007f439f4456d2 in scm_write (obj=obj@entry=#<variable 201b010>, 
>     port=port@entry=#<port #<port-type string 7f439cc8bab0> 7f4397cf9c80>) at print.c:1099
> #4  0x00007f439f469b99 in scm_object_to_string (obj=#<variable 201b010>, printer=<optimized out>) at strports.c:249
> #5  0x00007f439f476915 in vm_regular_engine (thread=0x7f439eb00d80) at vm-engine.c:972
> #6  0x00007f439f479029 in scm_call_n (proc=<optimized out>, argv=argv@entry=0x7ffc66910a30, nargs=nargs@entry=4)
>     at vm.c:1608
> #7  0x00007f439f3f2e54 in scm_call_4 (proc=<optimized out>, 
>     arg1=arg1@entry=#<port #<port-type file 7f439cc8bb40> 7f439ccdab40>, arg2=arg2@entry=#<unmatched-tag 12f>, 
>     arg3=arg3@entry=wrong-type-arg, 
>     arg4=arg4@entry=("gssh_channel_from_scm" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "channel-port" #<variable 201b010>) (#<variable 201b010>))) at eval.c:517
> #8  0x00007f439f3e569f in scm_print_exception (port=port@entry=#<port #<port-type file 7f439cc8bb40> 7f439ccdab40>, 
>     frame=frame@entry=#<unmatched-tag 12f>, key=key@entry=wrong-type-arg, 
>     args=args@entry=("gssh_channel_from_scm" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "channel-port" #<variable 201b010>) (#<variable 201b010>))) at backtrace.c:121
> #9  0x00007f439f3edd86 in print_exception_and_backtrace (
>     args=("gssh_channel_from_scm" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "channel-port" #<variable 201b010>) (#<variable 201b010>)), tag=wrong-type-arg, port=#<port #<port-type file 7f439cc8bb40> 7f439ccdab40>)
>     at continuations.c:415
> #10 pre_unwind_handler (error_port=0x7f439ccdab40, tag=wrong-type-arg, 
>     args=("gssh_channel_from_scm" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "channel-port" #<variable 201b010>) (#<variable 201b010>))) at continuations.c:453
> #11 0x00007f439f46e80a in catch_pre_unwind_handler (data=0x7ffc669128f0, exn="#<struct &compound-exception>" = {...})
>     at throw.c:135
> #12 0x00007f439f476915 in vm_regular_engine (thread=0x7f439eb00d80) at vm-engine.c:972
> #13 0x00007f439f479029 in scm_call_n (proc=proc@entry=#<program 7f439cd0b620>, argv=<optimized out>, nargs=5)
>     at vm.c:1608
> #14 0x00007f439f3f3151 in scm_apply_0 (proc=#<program 7f439cd0b620>, args=()) at eval.c:603
> #15 0x00007f439f3f3d3d in scm_apply_1 (proc=<optimized out>, arg1=arg1@entry=wrong-type-arg, 
>     args=args@entry=("gssh_channel_from_scm" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "channel-port" #<variable 201b010>) (#<variable 201b010>))) at eval.c:609
> #16 0x00007f439f46eca7 in scm_throw (key=key@entry=wrong-type-arg, 
>     args=("gssh_channel_from_scm" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "channel-port" #<variable 201b010>) (#<variable 201b010>))) at throw.c:262
> #17 0x00007f439f46edf9 in scm_ithrow (key=key@entry=wrong-type-arg, args=<optimized out>, 
>     no_return=no_return@entry=1) at throw.c:457
> #18 0x00007f439f3f12e5 in scm_error_scm (key=key@entry=wrong-type-arg, subr=<optimized out>, 
>     message=message@entry="Wrong type argument in position ~A (expecting ~A): ~S", 
>     args=args@entry=(1 "channel-port" #<variable 201b010>), data=data@entry=(#<variable 201b010>)) at error.c:90
> #19 0x00007f439f3f1380 in scm_error (key=wrong-type-arg, subr=subr@entry=0x7f4399385700 "gssh_channel_from_scm", 
>     message=message@entry=0x7f439f4afc90 "Wrong type argument in position ~A (expecting ~A): ~S", 
>     args=(1 "channel-port" #<variable 201b010>), rest=rest@entry=(#<variable 201b010>)) at error.c:62
> #20 0x00007f439f3f1740 in scm_wrong_type_arg_msg (subr=0x7f4399385700 "gssh_channel_from_scm", pos=1, 
>     bad_value=#<variable 201b010>, szMessage=<optimized out>) at error.c:282
> #21 0x00007f439937fe0f in gssh_channel_from_scm ()
>    from /gnu/store/3ckynw84w4lgx5ys9v8pkhdxh6b1cx5n-guile-ssh-0.15.0/lib/libguile-ssh.so
> #22 0x00007f439937fe1c in ?? () from /gnu/store/3ckynw84w4lgx5ys9v8pkhdxh6b1cx5n-guile-ssh-0.15.0/lib/libguile-ssh.so
> #23 0x00007f43992fae5e in channel_rcv_close (session=0x20d6600, type=<optimized out>, packet=<optimized out>, 
>     user=<optimized out>) at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/channels.c:689
> #24 0x00007f43993100f1 in ssh_packet_process (session=session@entry=0x20d6600, type=97 'a')
>     at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/packet.c:1494
> #25 0x00007f4399310897 in ssh_packet_socket_callback (data=data@entry=0x20db2c4, receivedlen=receivedlen@entry=36, 
>     user=user@entry=0x20d6600) at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/packet.c:1336
> #26 0x00007f4399310d04 in ssh_packet_socket_callback (data=0x20db290, receivedlen=88, user=0x20d6600)
>     at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/packet.c:1358
> #27 0x00007f439931aaf8 in ssh_socket_pollcallback (p=<optimized out>, fd=<optimized out>, revents=<optimized out>, 
>     v_s=0x20d6fb0) at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/socket.c:314
> #28 0x00007f4399316e43 in ssh_poll_ctx_dopoll (ctx=ctx@entry=0x20d84f0, timeout=timeout@entry=-1)
>     at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/poll.c:702
> #29 0x00007f4399317f0c in ssh_handle_packets (session=session@entry=0x20d6600, timeout=timeout@entry=-1)
>     at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/session.c:661
> #30 0x00007f4399317fdb in ssh_handle_packets_termination (session=session@entry=0x20d6600, timeout=timeout@entry=-1, 
>     fct=fct@entry=0x7f43992f8f10 <ssh_channel_read_termination>, user=user@entry=0x7ffc66912040)
>     at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/session.c:730
> #31 0x00007f43992fc421 in ssh_channel_read_timeout (channel=0x22d49e0, dest=0x7f4398a65d10, count=1, 
>     is_stderr=<optimized out>, timeout_ms=<optimized out>)
>     at /tmp/guix-build-libssh-0.9.6.drv-0/libssh-0.9.6/src/channels.c:2931
> #32 0x00007f4399380147 in ?? () from /gnu/store/3ckynw84w4lgx5ys9v8pkhdxh6b1cx5n-guile-ssh-0.15.0/lib/libguile-ssh.so
> #33 0x00007f439f43d7d2 in scm_i_read_bytes (port=port@entry=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, 
>     dst="#<vu8vector>" = {...}, start=start@entry=0, count=1) at ports.c:1566
> #34 0x00007f439f4419f7 in scm_fill_input (port=port@entry=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, 
>     minimum_size=1, minimum_size@entry=0, cur_out=cur_out@entry=0x7ffc66912170, 
>     avail_out=avail_out@entry=0x7ffc66912178) at ports.c:2693
> #35 0x00007f439f441d14 in peek_byte_or_eof (port=port@entry=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, 
>     buf_out=buf_out@entry=0x7ffc669121c8, cur_out=cur_out@entry=0x7ffc669121d0) at ports.c:1526
> #36 0x00007f439f441da5 in maybe_consume_bom (port=port@entry=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, 
>     bom=bom@entry=0x7f439f4b8776 <scm_utf8_bom> "", bom_len=bom_len@entry=3) at ports.c:2468
> #37 0x00007f439f441b54 in port_clear_stream_start_for_bom_read (io_mode=BOM_IO_TEXT, 
>     port=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>) at ports.c:2504
> #38 scm_fill_input (port=port@entry=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, minimum_size=1, 
>     minimum_size@entry=0, cur_out=cur_out@entry=0x7ffc66912270, avail_out=avail_out@entry=0x7ffc66912278)
>     at ports.c:2648
> #39 0x00007f439f441d14 in peek_byte_or_eof (port=port@entry=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, 
>     buf_out=buf_out@entry=0x7ffc669122c8, cur_out=cur_out@entry=0x7ffc669122d0) at ports.c:1526
> #40 0x00007f439f441e4c in peek_utf8_codepoint (port=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>, 
>     buf_out=buf_out@entry=0x7ffc66912338, cur_out=cur_out@entry=0x7ffc66912330, len_out=len_out@entry=0x7ffc66912328)
>     at ports.c:1790
> #41 0x00007f439f442594 in peek_codepoint (len=0x7ffc66912328, cur=0x7ffc66912330, buf=0x7ffc66912338, 
>     port=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>) at ports.c:1984
> #42 scm_getc (port=#<port #<port-type channel 7f439cc8b2d0> 7f4398a599a0>) at ports.c:2001
> #43 0x00007f439f4425e8 in scm_read_char (port=<optimized out>) at ports.c:2026
> #44 0x00007f439caa5b7b in ?? ()
> #45 0x00007f439cb7d724 in ?? ()
> #46 0x00007f43993d3320 in ?? ()
> #47 0x00000000020e4ed8 in ?? ()
> #48 0x00007f439f41cb1c in scm_jit_enter_mcode (thread=thread@entry=0x7f439eb00d80, mcode=0x205b8b8 "\034\232\003")
>     at jit.c:6038
> #49 0x00007f439f476512 in vm_regular_engine (thread=0x7f439eb00d80) at vm-engine.c:360
> #50 0x00007f439f479029 in scm_call_n (proc=<optimized out>, argv=argv@entry=0x7ffc66912558, nargs=nargs@entry=1)
>     at vm.c:1608
> #51 0x00007f439f3f3ea7 in scm_primitive_eval (exp=<optimized out>, 
>     exp@entry=((@ (ice-9 control) %) (begin ((@@ (ice-9 command-line) load/lang) "/home/ludo/src/guix/scripts/guix") (main (command-line)) (quit)))) at eval.c:671
> #52 0x00007f439f3f3f06 in scm_eval (
>     exp=((@ (ice-9 control) %) (begin ((@@ (ice-9 command-line) load/lang) "/home/ludo/src/guix/scripts/guix") (main (command-line)) (quit))), module_or_state=module_or_state@entry="#<struct module>" = {...}) at eval.c:705
> #53 0x00007f439f44ee76 in scm_shell (argc=8, argv=0x206aca0) at script.c:357
> #54 0x00007f439f40c36d in invoke_main_func (body_data=0x7ffc66912a80) at init.c:313
> #55 0x00007f439f3edbea in c_body (d=0x7ffc669129c0) at continuations.c:430
> #56 0x00007f439f476915 in vm_regular_engine (thread=0x7f439eb00d80) at vm-engine.c:972
> #57 0x00007f439f479029 in scm_call_n (proc=<optimized out>, argv=argv@entry=0x7ffc66912780, nargs=nargs@entry=2)
>     at vm.c:1608
> #58 0x00007f439f3f2dfa in scm_call_2 (proc=<optimized out>, arg1=<optimized out>, arg2=<optimized out>) at eval.c:503
> #59 0x00007f439f3f4529 in scm_c_with_exception_handler (type=type@entry=#t, 
>     handler=handler@entry=0x7f439f46e750 <catch_post_unwind_handler>, 
>     handler_data=handler_data@entry=0x7ffc669128f0, thunk=thunk@entry=0x7f439f46e890 <catch_body>, 
>     thunk_data=thunk_data@entry=0x7ffc669128f0) at exceptions.c:170
> #60 0x00007f439f46ea8d in scm_c_catch (tag=tag@entry=#t, body=body@entry=0x7f439f3edbe0 <c_body>, 
>     body_data=body_data@entry=0x7ffc669129c0, handler=handler@entry=0x7f439f3ede80 <c_handler>, 
>     handler_data=handler_data@entry=0x7ffc669129c0, 
>     pre_unwind_handler=pre_unwind_handler@entry=0x7f439f3edcd0 <pre_unwind_handler>, 
>     pre_unwind_handler_data=0x7f439ccdab40) at throw.c:168
> #61 0x00007f439f3ee238 in scm_i_with_continuation_barrier (body=0x7f439f3edbe0 <c_body>, body_data=0x7ffc669129c0, 
>     handler=0x7f439f3ede80 <c_handler>, handler_data=0x7ffc669129c0, 
>     pre_unwind_handler=0x7f439f3edcd0 <pre_unwind_handler>, pre_unwind_handler_data=0x7f439ccdab40)
>     at continuations.c:368
> #62 0x00007f439f3ee295 in scm_c_with_continuation_barrier (func=<optimized out>, data=<optimized out>)
>     at continuations.c:464
> #63 0x00007f439f46d549 in with_guile (base=base@entry=0x7ffc66912a28, data=data@entry=0x7ffc66912a50)
>     at threads.c:645
> #64 0x00007f439f34a0ba in GC_call_with_stack_base (fn=fn@entry=0x7f439f46d470 <with_guile>, 
>     arg=arg@entry=0x7ffc66912a50) at extra/../misc.c:2106
> #65 0x00007f439f46d848 in scm_i_with_guile (dynamic_state=<optimized out>, data=data@entry=0x7ffc66912a30, 
>     func=func@entry=0x7f439f40c350 <invoke_main_func>) at threads.c:688
> #66 scm_with_guile (func=func@entry=0x7f439f40c350 <invoke_main_func>, data=data@entry=0x7ffc66912a80)
>     at threads.c:694
> #67 0x00007f439f40c4e2 in scm_boot_guile (argc=argc@entry=5, argv=argv@entry=0x7ffc66912bd8, 
>     main_func=main_func@entry=0x401290 <inner_main>, closure=closure@entry=0x0) at init.c:296
> #68 0x0000000000401191 in main (argc=5, argv=0x7ffc66912bd8) at gnu/packages/aux-files/guile-launcher.c:93
>
> The segfault itself might be a Guile bug showing up while printing the
> backtrace.  It would seem that the core issue is the SSH channel being
> closed unexpected, leading to a wrong-type-arg error in Guile-SSH
> (frames 19 to 23).
>
> Does that ring a bell?
>
> Thanks in advance,
> Ludo’.