Subject: ‘update-cached-checkout’(Guile-Git/libgit2) can sometimes get stuck forever

From: Ludovic Courtès <[email-masked]>
Date: Fri, 28 Jun 2024 12:30:55 +0200

‘update-cached-checkout’ can sometimes get stuck on a connection
forever.  This is problematic for ‘cuirass register’, as it means that
it’ll silently stay forever in an unfinished ‘remote-fetch’, thus
without updating repos anymore:

--8<---------------cut here---------------start------------->8---
(gdb) info threads
  Id   Target Id                                        Frame
* 1    Thread 0x7f3996c1a380 (LWP 13322) "guile"        0x00007f3996d20626 in epoll_wait ()
   from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6

[...]

  29   Thread 0x7f3975000640 (LWP 31125) "git-checkout" 0x00007f3996d21cf6 in recv ()
   from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
(gdb) thread 29
[Switching to thread 29 (Thread 0x7f3975000640 (LWP 31125))]
#0  0x00007f3996d21cf6 in recv () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
(gdb) bt
#0  0x00007f3996d21cf6 in recv () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
#1  0x00007f398c17ba7b in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#2  0x00007f398c17a3ec in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#3  0x00007f398c8f8a37 in ?? () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libcrypto.so.3
#4  0x00007f398c8f6ee7 in BIO_read () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libcrypto.so.3
#5  0x00007f398ce9dd16 in ?? () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libssl.so.3
#6  0x00007f398cea12da in ?? () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libssl.so.3
#7  0x00007f398ce9ff68 in ?? () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libssl.so.3
#8  0x00007f398cebce6a in ?? () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libssl.so.3
#9  0x00007f398ceb1995 in ?? () from /gnu/store/kl7vp2gvcp2f2r2xrsiyzcvl794wz6sh-openssl-3.0.8/lib/libssl.so.3
#10 0x00007f398c17aa4d in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#11 0x00007f398c186271 in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#12 0x00007f398c187b35 in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#13 0x00007f398c185ca8 in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#14 0x00007f398c189fd1 in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#15 0x00007f398c18c598 in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#16 0x00007f398c18a3ad in ?? () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#17 0x00007f398c16679f in git_remote_connect_ext () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#18 0x00007f398c168185 in git_remote_fetch () from /gnu/store/pgswhlw3wn7i705vjlkzj4aycc0hsaif-libgit2-1.7.2/lib/libgit2.so
#19 0x00007f3997100052 in ?? () from /gnu/store/l0y8jkmip7qpa7x33972mn0dsfy8ac01-libffi-3.4.4/lib/libffi.so.8
#20 0x00007f39970fec85 in ?? () from /gnu/store/l0y8jkmip7qpa7x33972mn0dsfy8ac01-libffi-3.4.4/lib/libffi.so.8
#21 0x00007f39970ff68e in ffi_call () from /gnu/store/l0y8jkmip7qpa7x33972mn0dsfy8ac01-libffi-3.4.4/lib/libffi.so.8
#22 0x00007f399725cd37 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#23 0x00007f399724cf55 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#24 0x00007f3980d93330 in ?? ()
#25 0x00007f39966db5a8 in ?? ()
#26 0x00007f3980d015b0 in ?? ()
#27 0x00007f395ee64b40 in ?? ()
#28 0x00007f39971e2edc in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#29 0x00007f399723f215 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#30 0x00007f399724cdb5 in scm_call_n () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#31 0x00007f39971b3b3e in scm_call_with_unblocked_asyncs () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#32 0x00007f3980d014f2 in ?? ()
#33 0x00007f39966db1dc in ?? ()
#34 0x00007f3980d00000 in ?? ()
#35 0x00007f395ee64b40 in ?? ()
#36 0x00007f39971e2edc in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#37 0x00007f399723f215 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#38 0x00007f399724cdb5 in scm_call_n () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#39 0x00007f39972390f3 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#40 0x00007f39971b5e1a in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#41 0x00007f39880d3522 in ?? ()
#42 0x00007f39968977f0 in ?? ()
#43 0x00007f3991e40480 in ?? ()
#44 0x00007f395ee64b40 in ?? ()
#45 0x00007f39971e2edc in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#46 0x00007f399723f215 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#47 0x00007f399724cdb5 in scm_call_n () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#48 0x00007f39971b75ca in scm_call_2 () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#49 0x00007f399725e092 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#50 0x00007f3997239e1f in scm_c_catch () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#51 0x00007f39971b8396 in scm_c_with_continuation_barrier ()
   from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#52 0x00007f3997239049 in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#53 0x00007f399711c7fa in GC_call_with_stack_base () from /gnu/store/k1ha4n9v8d7myiiszvl2ic7xnb56l219-libgc-8.2.2/lib/libgc.so.1
#54 0x00007f3997232c5d in ?? () from /gnu/store/bhynhk0c6ssq3fqqc59fvhxjzwywsjbb-guile-3.0.9/lib/libguile-3.0.so.1
#55 0x00007f3996ca03aa in start_thread () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
#56 0x00007f3996d20f7c in clone3 () from /gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libc.so.6
--8<---------------cut here---------------end--------------->8---

Forcing “return (int)0” of that ‘recv’ frame from GDB unblocks it, but
it’s not convenient.  :-)

AFAICS, there’s no timeout option in libgit2 unfortunately:

  https://libgit2.org/libgit2/#HEAD/type/git_fetch_options

Ludo’, thinking how to set up a job that periodically attaches GDB to Cuirass.