From: Matthias Schmidt Subject: got/tog segfault with corrupted (?) checkout To: gameoftrees@openbsd.org Date: Wed, 27 Dec 2023 12:54:59 +0100 Hi, Yesterday, I updated my local OpenBSD ports tree via got and somewhere in between my machine crashed. Machine came back up and fsck didn't left any files in lost+found. However, the checked out ports tree seem to suffer from some kind of corruption that leads to a got and tog segfault. Here's how it looks at the moment: $ cd /var/git/ports.git/ $ got fetch Connecting to "origin" ssh://git@github.com/openbsd/ports.git server: Enumerating objects: 43, done. server: Counting objects: 100% (43/43), done. server: Compressing objects: 100% (37/37), done. server: Total 43 (delta 8), reused 28 (delta 6), pack-reused 0 92.3K fetched; indexing 100%; resolving deltas 100% Fetched 915731191575eb75b99600d2256d3ad79fa28b1d.pack Updated refs/heads/master: 18e3877779811caa6fcc5a3ca209b17a0fe5093f $ cd /usr/ports/ $ got up Segmentation fault (core dumped) I rebuilt got from latest main with -g3 -ggdb and still get a segfault. Both got and tog segfault at the exact same location in worktree_open. $ /home/xhr/Downloads/Software/got/got/obj/got up Segmentation fault (core dumped) $ egdb /home/xhr/Downloads/Software/got/got/obj/got got.core Reading symbols from /home/xhr/Downloads/Software/got/got/obj/got... [New process 358917] Core was generated by `got'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x0000002517642606 in read_meta_file (content=0x72fe35311e50, path_got=0x273f4eab00 "/usr/ports/.got", name=0x25175b3a33 "base-commit") at /home/xhr/Downloads/Software/got/got/../lib/worktree_open.c:95 95 if ((*content)[sb.st_size - 1] != '\n') { (gdb) bt #0 0x0000002517642606 in read_meta_file (content=0x72fe35311e50, path_got=0x273f4eab00 "/usr/ports/.got", name=0x25175b3a33 "base-commit") at /home/xhr/Downloads/Software/got/got/../lib/worktree_open.c:95 #1 0x0000002517641eec in open_worktree (worktree=0x72fe35311ff0, path=0x273f4d78f0 "/usr/ports", meta_dir=0x25175b2dd6 ".got") at /home/xhr/Downloads/Software/got/got/../lib/worktree_open.c:187 #2 0x0000002517641ae5 in got_worktree_open (worktree=0x72fe35311ff0, path=0x271e42a800 "/usr/ports", meta_dir=0x25175b2dd6 ".got") at /home/xhr/Downloads/Software/got/got/../lib/worktree_open.c:294 #3 0x00000025175cc651 in cmd_update (argc=0, argv=0x72fe353120f8) at /home/xhr/Downloads/Software/got/got/got.c:3574 #4 0x00000025175c7c97 in main (argc=1, argv=0x72fe353120f0) at /home/xhr/Downloads/Software/got/got/got.c:262 (gdb) l 90 if (n != sb.st_size) { 91 err = (n == -1 ? got_error_from_errno2("read", path) : 92 got_error_path(path, GOT_ERR_WORKTREE_META)); 93 goto done; 94 } 95 if ((*content)[sb.st_size - 1] != '\n') { 96 err = got_error_path(path, GOT_ERR_WORKTREE_META); 97 goto done; 98 } 99 (*content)[sb.st_size - 1] = '\0'; (gdb) I can provide binaries and core files if needed. I run OpenBSD -current and can reproduce with both 0.95 from ports and self-compiled. Cheers Matthias