johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
50 stars 9 forks source link

Segmentation fault #73

Closed tom-ab closed 3 years ago

tom-ab commented 3 years ago

Attempts to update the ports tree are failing with a segmentation fault. I've emptied /usr/ports and /var/db/gitup and tried using the clone option with the same result:

tab@v1:~ % freebsd-version
12.2-RELEASE-p9
tab@v1:~ % gitup -V
gitup version 0.95
tab@v1:~ % sudo gitup -c ports
# Scanning local repository...
# Host: github.com
# Port: 443
# Repository Path: /freebsd/freebsd-ports
# Target Directory: /usr/ports
# Commit History: yes
# Want: c9c0132387559dfedb29f59712332eeab5305c27
# Branch: main
Segmentation fault
tom-ab commented 3 years ago

I've no experience of debugging, but hopefully this is useful to you:

Core file '/usr/ports/net/gitup/work/stage/usr/local/bin/gitup.core' (x86_64) was loaded.
(lldb) bt all
* thread #1, name = 'gitup', stop reason = signal SIGSEGV
  * frame #0: 0x00000008007fc030 libc.so.7`memchr + 16
    frame #1: 0x0000000800722f9c libc.so.7`strstr + 908
    frame #2: 0x00000000002145bb gitup`store_object(session=0x00007fffffff9aa8, type=1, buffer="tree fae5960929e96ebaaf93a81fae584acacdeb45fe\nparent f3d69b8facb62067486e98f69c20e6a0af073640\nauthor Alexey Dokuchaev <danfe@FreeBSD.org> 1627264512 +0000\ncommitter Alexey Dokuchaev <danfe@FreeBSD.org> 1627264522 +0000\n\nsecurity/distcache: fix strip-related comment and take maintainership\n\nThe comment said ``INSTALL_TARGET=install-strip isn't working'', that\nis, does not strip shared libraries as expected, while actually this is\nnot a bug but intended behavior, per this quote from the INSTALL file:\n\n  [...] Fortunately, the GNU autotools have built-in support for this\n  functionality, all you need to do is to specify \"make install-strip\"\n  instead of \"make install\".  Note however that only executables are\n  stripped, libraries are not touched [...]\n:\n\n    Find all ports whose names contain \"pear-\" but not \"html\" or \"http\":\n\n      make search name=pear- xname='ht(tp|ml)'\n\n    Find ports whose names contain \"pear-\" and which don't have apache\n    listed in build-time dependencies:\n\n      make search name=pear- "..., buffer_size=759, pack_offset=15546, index_delta=0, ref_delta_hash=0x0000000000000000) at gitup.c:2100:58
    frame #3: 0x00000000002164f7 gitup`unpack_objects(session=0x00007fffffff9aa8) at gitup.c:2297:3
    frame #4: 0x00000000002119b5 gitup`fetch_pack(session=0x00007fffffff9aa8, command="0011command=fetch0001000dthin-pack000fno-progress000dofs-delta0012filter tree:0\n0032want 6223eec380d91f3a51d85d88223bb0e2a770dd5e\n0009done\n0000") at gitup.c:2028:2
    frame #5: 0x000000000021101a gitup`load_pack(session=0x00007fffffff9aa8, file=0x0000000000000000, history_file=true) at gitup.c:1925:3
    frame #6: 0x000000000020de72 gitup`main(argc=2, argv=0x00007fffffffec30) at gitup.c:3863:3
    frame #7: 0x00000000002060b0 gitup`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7

(lldb) fr select 2
frame #2: 0x00000000002145bb gitup`store_object(session=0x00007fffffff9aa8, type=1, buffer="tree fae5960929e96ebaaf93a81fae584acacdeb45fe\nparent f3d69b8facb62067486e98f69c20e6a0af073640\nauthor Alexey Dokuchaev <danfe@FreeBSD.org> 1627264512 +0000\ncommitter Alexey Dokuchaev <danfe@FreeBSD.org> 1627264522 +0000\n\nsecurity/distcache: fix strip-related comment and take maintainership\n\nThe comment said ``INSTALL_TARGET=install-strip isn't working'', that\nis, does not strip shared libraries as expected, while actually this is\nnot a bug but intended behavior, per this quote from the INSTALL file:\n\n  [...] Fortunately, the GNU autotools have built-in support for this\n  functionality, all you need to do is to specify \"make install-strip\"\n  instead of \"make install\".  Note however that only executables are\n  stripped, libraries are not touched [...]\n:\n\n    Find all ports whose names contain \"pear-\" but not \"html\" or \"http\":\n\n      make search name=pear- xname='ht(tp|ml)'\n\n    Find ports whose names contain \"pear-\" and which don't have apache\n    listed in build-time dependencies:\n\n      make search name=pear- "..., buffer_size=759, pack_offset=15546, index_delta=0, ref_delta_hash=0x0000000000000000) at gitup.c:2100:58
   2097                 if (type == 1) {
   2098                         temp = buffer;
   2099
-> 2100                         while ((temp + 47 - buffer < buffer_size) && ((temp = strstr(temp, "parent ")) != NULL)) {
   2101                                 ok    = true;
   2102                                 temp += 47;
   2103
(lldb) fr variable
(connector *) session = 0x00007fffffff9aa8
(int) type = 1
(char *) buffer = 0x0000000800b56c00 "tree fae5960929e96ebaaf93a81fae584acacdeb45fe\nparent f3d69b8facb62067486e98f69c20e6a0af073640\nauthor Alexey Dokuchaev <danfe@FreeBSD.org> 1627264512 +0000\ncommitter Alexey Dokuchaev <danfe@FreeBSD.org> 1627264522 +0000\n\nsecurity/distcache: fix strip-related comment and take maintainership\n\nThe comment said ``INSTALL_TARGET=install-strip isn't working'', that\nis, does not strip shared libraries as expected, while actually this is\nnot a bug but intended behavior, per this quote from the INSTALL file:\n\n  [...] Fortunately, the GNU autotools have built-in support for this\n  functionality, all you need to do is to specify \"make install-strip\"\n  instead of \"make install\".  Note however that only executables are\n  stripped, libraries are not touched [...]\n:\n\n    Find all ports whose names contain \"pear-\" but not \"html\" or \"http\":\n\n      make search name=pear- xname='ht(tp|ml)'\n\n    Find ports whose names contain \"pear-\" and which don't have apache\n    listed in build-time dependencies:\n\n      make search name=pear- "...
(int) buffer_size = 759
(int) pack_offset = 15546
(int) index_delta = 0
(char *) ref_delta_hash = 0x0000000000000000
(object_node *) object = 0x0000000802e2e870
(object_node) find = {
  link = {
    rbe_left = 0x0000000802e77c98
    rbe_right = 0x0000000802e77f18
    rbe_parent = 0xfffffffbffff46c0
    rbe_color = 275
  }
  hash = 0x0000000802e430a0 "8e20ddc545290fe2036764bbf03e967a6cb06f06"
  type = '\xbf'
  index = 8
  index_delta = 4294920000
  ref_delta_hash = 0x0000000800761fd0 ""
  pack_offset = 48724992
  buffer = 0x00007fffffff4b37 "7S0R294F30pYkJ\n TwSD8UbjO6sTbOQFgCte/OL94oNwn48ApM84fyJjKigTwx4HuLqaOE5U1txBJ88A\n eM+MfwqHQGK6sH6ykl3vx7HIQMK90+jnnHCNcGD330HErDvkl8rzWO04Szzy4vCd\n 5zoLq05yhAAdhZC3EitXYfxJnStb2kF/qQxWzOAOfm5CGeYAFwqArNn361dbR7bW\n 1NWCFVMP/T8Zrr7rPAR9+h4bmb5WGQtm30A0AEo8ucImwdG76O05lopRWuoPP1WV\n /xMVhxDDZOmE+BNCitT9awhyIFlIhTJBxzn/bNLmvHjqbBdCzIA//A1Jf4PwXR1K\n 8/oKu2resyN75RkmK9WxZ3VhikKK3T0J81Jd46k+M6b1SnAfwys=\n =y7t4\n -----END PGP SIGNATURE-----\n\ntextproc/libnumbertext: Update to 1.0.7\nd by\ndefault and eventually removed.\n\nBeginning with the krb5-1.18 release, single-DES encryption types have\nbeen removed.\n\nMajor changes in 1.19.2 and 1.18.4 (2021-07-22)\n===============================================\n\nThese are bug fix releases.\n\n* Fix a denial of service attack against the KDC encrypted challenge\n  code [CVE-2021-36222].\n\n* Fix a memory leak when gss_inquire_cred() is called without a\n  credential handle.\n\nMFH:\t\t2021Q3\nSecurity:\tCVE-2021-36222\n\x80▒▒
  buffer_size = 130849255
  file_offset = 0
  can_free = true
  parent = 0x06c9982b46ef2223
  parents = '\xd0'
}
(char *) hash = 0x0000000802e430a0 "8e20ddc545290fe2036764bbf03e967a6cb06f06"
(char *) temp = 0x0000000800b56c5d "\nauthor Alexey Dokuchaev <danfe@FreeBSD.org> 1627264512 +0000\ncommitter Alexey Dokuchaev <danfe@FreeBSD.org> 1627264522 +0000\n\nsecurity/distcache: fix strip-related comment and take maintainership\n\nThe comment said ``INSTALL_TARGET=install-strip isn't working'', that\nis, does not strip shared libraries as expected, while actually this is\nnot a bug but intended behavior, per this quote from the INSTALL file:\n\n  [...] Fortunately, the GNU autotools have built-in support for this\n  functionality, all you need to do is to specify \"make install-strip\"\n  instead of \"make install\".  Note however that only executables are\n  stripped, libraries are not touched [...]\n:\n\n    Find all ports whose names contain \"pear-\" but not \"html\" or \"http\":\n\n      make search name=pear- xname='ht(tp|ml)'\n\n    Find ports whose names contain \"pear-\" and which don't have apache\n    listed in build-time dependencies:\n\n      make search name=pear- xbdeps=apache\n\n    The positive variables (name, key, maint, etc) are AND-ed, their\n    negat"...
(char [41]) parent = "f3d69b8facb62067486e98f69c20e6a0af073640"
(bool) ok = true
(lldb)
johnmehr commented 3 years ago

I'm not having any luck recreating the segfault. Looking at the output of your initial post, "# Commit History: yes" is appearing and it might be related to this (the commit history functionality is not finished yet and it should be reporting 'no'). Could you please copy the contents of your gitup.conf here? Thanks!

tom-ab commented 3 years ago

Yes, here it is:

# $FreeBSD$
#
# Default configuration options for gitup.conf.
{
        "defaults" : {
                "host"           : "github.com",
                "port"           : "443",
                "verbosity"      : "1",
                "work_directory" : "/var/db/gitup",
        },

        "ports" : {
                "repository" : "/freebsd/freebsd-ports",
                "branch"     : "main",
                "target"     : "/usr/ports",
                "ignore"     : [
                        "/usr/ports/distfiles",
                        "/usr/ports/packages",
                ],
        },

        "quarterly" : {
                "repository" : "/freebsd/freebsd-ports",
                "branch"     : "quarterly",
                "target"     : "/usr/ports",
                "ignore"     : [
                        "/usr/ports/distfiles",
                        "/usr/ports/packages",
                ]
        },

        "release" : {
                "repository" : "/freebsd/freebsd",
                "branch"     : "releng/11.4",
                "target"     : "/usr/src",
                "ignore"     : [
                        "/usr/src/sys/amd64/conf",
                        "/usr/src/sys/arm64/conf",
                        "/usr/src/sys/i386/conf",
                        "/usr/src/sys/pc98/conf",
                        "/usr/src/sys/powerpc/conf",
                        "/usr/src/sys/riscv/conf",
                        "/usr/src/sys/sparc64/conf",
                ]
        },

        "stable" : {
                "repository" : "/freebsd/freebsd",
                "branch"     : "stable/12",
                "target"     : "/usr/src",
                "ignore"     : [
                        "/usr/src/sys/amd64/conf",
                        "/usr/src/sys/arm64/conf",
                        "/usr/src/sys/i386/conf",
                        "/usr/src/sys/pc98/conf",
                        "/usr/src/sys/powerpc/conf",
                        "/usr/src/sys/riscv/conf",
                        "/usr/src/sys/sparc64/conf",
                ]
        },

        "current" : {
                "repository" : "/freebsd/freebsd",
                "branch"     : "master",
                "target"     : "/usr/src",
                "ignore"     : [
                        "/usr/src/sys/amd64/conf",
                        "/usr/src/sys/arm64/conf",
                        "/usr/src/sys/i386/conf",
                        "/usr/src/sys/pc98/conf",
                        "/usr/src/sys/powerpc/conf",
                        "/usr/src/sys/riscv/conf",
                        "/usr/src/sys/sparc64/conf",
                ]
        }
}
tom-ab commented 3 years ago

Replacing my gitup.conf with gitup.conf.sample has fixed the problem, although it still shows Commit History: yes

grahamperrin commented 3 years ago

git.freebsd.org in lieu of github.com

From https://github.com/johnmehr/gitup/issues/73#issuecomment-899112567

        "defaults" : {
                "host"           : "github.com",

See https://lists.freebsd.org/pipermail/freebsd-questions/2021-August/294592.html