johnmehr / gitup

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

Segmentation fault #74

Closed michael-o closed 3 years ago

michael-o commented 3 years ago

Using f5b0dcb89571f52448f90ee5ee5aafda371d6f1e on 12-STABLE gives me now:

# gitup src
# Scanning local repository...
# Host: git.freebsd.org
# Port: 443
# Repository Path: /src.git
# Target Directory: /usr/src
# Commit History: yes
# Have: b65d87e5d7b58fd06cf4a3061b564d62f1033999
# Want: 2d26a28153d21ed059b6f2fc854e3eaf9e85e6d7
# Branch: stable/12
# Action: pull
Segmentation fault (Speicherabzug geschrieben)

Core:

# lldb $(which gitup) -c gitup.core
(lldb) target create "/usr/local/sbin/gitup" --core "gitup.core"
Core file '/root/gitup/gitup.core' (x86_64) was loaded.
(lldb) bt all
* thread #1, name = 'gitup', stop reason = signal SIGSEGV
  * frame #0: 0x00000008007f507c libc.so.7`strcmp at strcmp.S:46
    frame #1: 0x000000000020f7b8 gitup`load_object [inlined] file_node_compare_p                                                                                                                                   ath(a=<unavailable>, b=0x000000080122cc40) at gitup.c:196:10
    frame #2: 0x000000000020f7ac gitup`load_object [inlined] Tree_Local_Path_RB_                                                                                                                                   FIND(head=<unavailable>, elm=<unavailable>) at gitup.c:249
    frame #3: 0x000000000020f790 gitup`load_object(session=0x00007fffffff8930, h                                                                                                                                   ash="00dd541c840626c066162c5a76e2f5177c71ca89", path=0x0000000000000000) at gitu                                                                                                                                   p.c:1081
    frame #4: 0x000000000020ceaf gitup`apply_deltas(session=<unavailable>) at gi                                                                                                                                   tup.c:2435:4
    frame #5: 0x000000000020aec9 gitup`main(argc=<unavailable>, argv=<unavailabl                                                                                                                                   e>) at gitup.c:3899:3
    frame #6: 0x00000000002060c0 gitup`_start(ap=<unavailable>, cleanup=<unavail                                                                                                                                   able>) at crt1.c:76:7
(lldb) fr 1
invalid command 'frame 1'.
(lldb) fr select 2
frame #2: 0x000000000020f7ac gitup`load_object [inlined] Tree_Local_Path_RB_FIND                                                                                                                                   (head=<unavailable>, elm=<unavailable>) at gitup.c:249
   246
   247  static RB_HEAD(Tree_Local_Path, file_node) Local_Path = RB_INITIALIZER(&                                                                                                                                   Local_Path);
   248  RB_PROTOTYPE(Tree_Local_Path, file_node, link_path, file_node_compare_pa                                                                                                                                   th)
-> 249  RB_GENERATE(Tree_Local_Path,  file_node, link_path, file_node_compare_pa                                                                                                                                   th)
   250
   251  static RB_HEAD(Tree_Local_Hash, file_node) Local_Hash = RB_INITIALIZER(&                                                                                                                                   Local_Hash);
   252  RB_PROTOTYPE(Tree_Local_Hash, file_node, link_hash, file_node_compare_ha                                                                                                                                   sh)
(lldb) bt all
* thread #1, name = 'gitup', stop reason = signal SIGSEGV
    frame #0: 0x00000008007f507c libc.so.7`strcmp at strcmp.S:46
    frame #1: 0x000000000020f7b8 gitup`load_object [inlined] file_node_compare_path(a=<unavailable>, b=0x000000080122cc40) at gitup.c:196:10
  * frame #2: 0x000000000020f7ac gitup`load_object [inlined] Tree_Local_Path_RB_FIND(head=<unavailable>, elm=<unavailable>) at gitup.c:249
    frame #3: 0x000000000020f790 gitup`load_object(session=0x00007fffffff8930, hash="00dd541c840626c066162c5a76e2f5177c71ca89", path=0x0000000000000000) at gitup.c:1081
    frame #4: 0x000000000020ceaf gitup`apply_deltas(session=<unavailable>) at gitup.c:2435:4
    frame #5: 0x000000000020aec9 gitup`main(argc=<unavailable>, argv=<unavailable>) at gitup.c:3899:3
    frame #6: 0x00000000002060c0 gitup`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7
(lldb) fr select 2
frame #2: 0x000000000020f7ac gitup`load_object [inlined] Tree_Local_Path_RB_FIND(head=<unavailable>, elm=<unavailable>) at gitup.c:249
   246
   247  static RB_HEAD(Tree_Local_Path, file_node) Local_Path = RB_INITIALIZER(&Local_Path);
   248  RB_PROTOTYPE(Tree_Local_Path, file_node, link_path, file_node_compare_path)
-> 249  RB_GENERATE(Tree_Local_Path,  file_node, link_path, file_node_compare_path)
   250
   251  static RB_HEAD(Tree_Local_Hash, file_node) Local_Hash = RB_INITIALIZER(&Local_Hash);
   252  RB_PROTOTYPE(Tree_Local_Hash, file_node, link_hash, file_node_compare_hash)

gitup.conf:

# less /usr/local/etc/gitup.conf
# $FreeBSD$
#
# Default configuration options for gitup.conf.
{
    "defaults" : {
        "host"           : "git.freebsd.org",
        "port"           : 443,
        "verbosity"      : 1,
        "work_directory" : "/var/db/gitup",
    },

    "ports" : {
        "repository_path"  : "/ports.git",
        "branch"           : "main",
        "target_directory" : "/usr/ports",
        "ignores"          : [
            "distfiles",
            "packages",
        ],
    },

    "src" : {
        "repository_path"  : "/src.git",
        "branch"           : "stable/12",
        "target_directory" : "/usr/src",
        "ignores"          : [
            "sys/amd64/conf",
            "sys/arm64/conf",
            "sys/i386/conf",
            "sys/pc98/conf",
            "sys/powerpc/conf",
            "sys/riscv/conf",
            "sys/sparc64/conf",
        ]
    },

    "src-12.2" : {
        "repository_path"  : "/src.git",
        "branch"           : "releng/12.2",
        "target_directory" : "/usr/src",
        "ignores"          : [
            "sys/amd64/conf",
            "sys/arm64/conf",
            "sys/i386/conf",
            "sys/pc98/conf",
            "sys/powerpc/conf",
            "sys/riscv/conf",
            "sys/sparc64/conf",
        ]
    }
}

How can I assist to fix this issue?

johnmehr commented 3 years ago

I just pushed a commit that should prevent the segmentation fault while I still look for the source of the underlying problem...

johnmehr commented 3 years ago

The function ignore_file() was keeping the local copy of sys/i386/conf/NOTES from being loaded (which was updated in 9ffb4c0adab4853ab752ecda6a5ff59ea943af4e). The patch I just committed should fix this. How does it look on your end?

michael-o commented 3 years ago

Testing...

michael-o commented 3 years ago

Fantastic, works for me!