git-up / GitUp

The Git interface you've been missing all your life has finally arrived.
http://gitup.co
GNU General Public License v3.0
11.48k stars 1.25k forks source link

Gitup crashes on some actions when nothing was staged yet #901

Open svdo opened 1 year ago

svdo commented 1 year ago

Since a while (month or so I guess) Gitup crashes when I try to stage a file and nothing else was staged yet. After restarting the file has been staged successfully, any other files can be staged afterwards without issues. Also unstaging works.

Also when nothing is staged and I open the settings and change the "diff generation", it also crashes.

When I run GitUp from the command line (/Applications/GitUp.app/Contents/MacOS/GitUp), the error is:

GitUp(46152,0x1116a6600) malloc: *** error for object 0x105fa4320: pointer being freed was not allocated
GitUp(46152,0x1116a6600) malloc: *** set a breakpoint in malloc_error_break to debug
svdo commented 1 year ago

I have run Gitup in Xcode to see if I get more information that way. Running it normally (debug mode), everything seems to work (no crash). However after enabling the diagnostics "malloc scribble", "malloc guard edges" and "guard malloc" in the scheme, it does crash:

Screenshot 2023-01-12 at 14 01 59
lucasderraugh commented 1 year ago

Thanks for filing. I assume this is with latest master?

svdo commented 1 year ago

Actually that was with commit 16adf50, but latest master has the same behaviour.

svdo commented 1 year ago

Maybe also good to know: when I enable the "undefined behavior sanitizer" I get a lot of messages like this:

/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:391:2: runtime error: load of misaligned address 0x000127c18f05 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f05: note: pointer points here
 65 6e 74 20 35 38 38  33 36 64 33 39 63 63 64  33 62 36 32 38 37 66 65  61 65 39 33 33 62 66 65  39
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:391:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:396:2: runtime error: load of misaligned address 0x000127c18f09 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f09: note: pointer points here
 35 38 38  33 36 64 33 39 63 63 64  33 62 36 32 38 37 66 65  61 65 39 33 33 62 66 65  39 66 35 39 38
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:396:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:401:2: runtime error: load of misaligned address 0x000127c18f0d for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f0d: note: pointer points here
 36 64 33 39 63 63 64  33 62 36 32 38 37 66 65  61 65 39 33 33 62 66 65  39 66 35 39 38 31 39 61  37
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:401:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:406:2: runtime error: load of misaligned address 0x000127c18f11 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f11: note: pointer points here
 63 63 64  33 62 36 32 38 37 66 65  61 65 39 33 33 62 66 65  39 66 35 39 38 31 39 61  37 34 66 34 66
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:406:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:411:2: runtime error: load of misaligned address 0x000127c18f15 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f15: note: pointer points here
 62 36 32 38 37 66 65  61 65 39 33 33 62 66 65  39 66 35 39 38 31 39 61  37 34 66 34 66 0a 61 75  74
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:411:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:416:2: runtime error: load of misaligned address 0x000127c18f19 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f19: note: pointer points here
 37 66 65  61 65 39 33 33 62 66 65  39 66 35 39 38 31 39 61  37 34 66 34 66 0a 61 75  74 68 6f 72 20
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:416:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:421:2: runtime error: load of misaligned address 0x000127c18f1d for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f1d: note: pointer points here
 65 39 33 33 62 66 65  39 66 35 39 38 31 39 61  37 34 66 34 66 0a 61 75  74 68 6f 72 20 53 74 65  66
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:421:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:426:2: runtime error: load of misaligned address 0x000127c18f21 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f21: note: pointer points here
 62 66 65  39 66 35 39 38 31 39 61  37 34 66 34 66 0a 61 75  74 68 6f 72 20 53 74 65  66 61 6e 20 76
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:426:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:431:2: runtime error: load of misaligned address 0x000127c18f25 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f25: note: pointer points here
 66 35 39 38 31 39 61  37 34 66 34 66 0a 61 75  74 68 6f 72 20 53 74 65  66 61 6e 20 76 61 6e 20  64
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:431:2 in 
/Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:436:2: runtime error: load of misaligned address 0x000127c18f29 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x000127c18f29: note: pointer points here
 31 39 61  37 34 66 34 66 0a 61 75  74 68 6f 72 20 53 74 65  66 61 6e 20 76 61 6e 20  64 65 6e 20 4f
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/<redacted>/Documents/Projects/3dParty/GitUp/GitUpKit/Third-Party/libgit2/src/hash/sha1/sha1dc/sha1.c:436:2 in 
svdo commented 1 year ago

I'm on a MacBook Pro 15" (2019) running macOS Monterey 12.6.1 by the way.

svdo commented 1 year ago

@lucasderraugh Have you also experienced this issue, or someone else, or am I the only one?

Just to provide a bit more information, this is probably an interesting point in that stack trace when the crash occurs:

Screenshot 2023-01-14 at 20 09 51
svdo commented 1 year ago

It occurred to me that ~/.gitconfig might also play a role here. And indeed, I reduced it down to having a ~/.gitconfig that contains only this:

[core]
    autocrlf = input

That causes it to crash, comment that line out and it works again.

lucasderraugh commented 1 year ago

Thanks, I was unable to reproduce so I was going to ask for more info on your setup. We just had our second child so I'm in a bit of a hectic time (sleep deprived), but I have some time at night to look at these issues.

I'll look into what that flag changes to make this crash when time permits.

svdo commented 1 year ago

Sure @lucasderraugh, and my heart-felt congratulations to your family!!! Take your time, family is more important :) Anyway at least I can now use Gitup again, and I also have lazygit as backup, so I'm good enough :)

Brandon-T commented 1 year ago
==77148==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00010c9898c0 in thread T0
    #0 0x10a293019 in wrap_free+0xa9 (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x4b019)
    #1 0x10c0e6db4 in stdalloc__free+0x14 (GitUpKit:x86_64+0x3e8db4)
    #2 0x10c198f17 in git_diff_file_content__unload+0x157 (GitUpKit:x86_64+0x49af17)
    #3 0x10c199344 in git_diff_file_content__clear+0x14 (GitUpKit:x86_64+0x49b344)
    #4 0x10c315775 in patch_generated_free+0x405 (GitUpKit:x86_64+0x617775)
    #5 0x10c31054c in git_patch__free+0x8c (GitUpKit:x86_64+0x61254c)
    #6 0x10c31042c in git_patch_free+0x7c (GitUpKit:x86_64+0x61242c)
    #7 0x10bd5547a in -[GCDiffPatch dealloc] GCDiff.m:95
    #8 0x10bd5a347 in -[GCDiffDelta .cxx_destruct] GCDiff.m:161
    #9 0x7ff806691059 in object_cxxDestructFromClass(objc_object*, objc_class*)+0x52 (libobjc.A.dylib:x86_64h+0x11059)
    #10 0x7ff8066899a2 in objc_destructInstance+0x62 (libobjc.A.dylib:x86_64h+0x99a2)
    #11 0x7ff806be068e in -[NSObject(NSObject) __dealloc_zombie]+0x9e (CoreFoundation:x86_64h+0x18f68e)
    #12 0x7ff806a73d51 in -[__NSArrayM dealloc]+0xcf (CoreFoundation:x86_64h+0x22d51)
    #13 0x10bd5db20 in -[GCDiff .cxx_destruct] GCDiff.m:308
    #14 0x7ff806691059 in object_cxxDestructFromClass(objc_object*, objc_class*)+0x52 (libobjc.A.dylib:x86_64h+0x11059)
    #15 0x7ff8066899a2 in objc_destructInstance+0x62 (libobjc.A.dylib:x86_64h+0x99a2)
    #16 0x7ff806be068e in -[NSObject(NSObject) __dealloc_zombie]+0x9e (CoreFoundation:x86_64h+0x18f68e)
    #17 0x10bd5bed8 in -[GCDiff dealloc] GCDiff.m:334
    #18 0x7ff80668d671 in AutoreleasePoolPage::releaseUntil(objc_object**)+0xa7 (libobjc.A.dylib:x86_64h+0xd671)
    #19 0x7ff80668a52e in objc_autoreleasePoolPop+0xe2 (libobjc.A.dylib:x86_64h+0xa52e)
    #20 0x7ff806a93e1c in _CFAutoreleasePoolPop+0x15 (CoreFoundation:x86_64h+0x42e1c)
    #21 0x7ff8078ff711 in -[NSAutoreleasePool drain]+0x84 (Foundation:x86_64+0x33711)
    #22 0x7ff809c107e8 in -[NSApplication run]+0x27b (AppKit:x86_64+0x2f7e8)
    #23 0x7ff809be47f6 in NSApplicationMain+0x330 (AppKit:x86_64+0x37f6)
    #24 0x109dc9981 in main main.m:19
    #25 0x7ff8066c230f  (<unknown module>)

Address 0x00010c9898c0 is a wild pointer inside of access range of size 0x000000000001.
SUMMARY: AddressSanitizer: bad-free (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x4b019) in wrap_free+0xa9
==77148==ABORTING
AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.

Having the same issue here.

Used to have:

[user]
        name = Brandon
        email = MyEmail@domain.com

[user]
  signingkey = ssh-algor gdgsgdagdsagsa

[gpg]
  format = ssh

[gpg "ssh"]
  program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"

[commit]
  gpgsign = true

[core]
  autocrlf = input

[pull]
        rebase = true

Removing:

[core]
    autocrlf = input

causes the crash to go away. I removed it via: git config --global --edit

lucasderraugh commented 1 year ago

@svdo Alrighty, back from paternity leave 😅. I'm not sure I see how https://github.com/git-up/GitUp/commit/16adf5023704393d38e12b58954fd3ce3f48bcdf would be an issue considering it's an if conditional verifying a non-null value, but I'll try running address sanitizer on the code to see what comes up.

svdo commented 1 year ago

@lucasderraugh I didn't mean to say that commit introduced the issue, it was just what I happened to be running. I hope that everything is well with your family and small one, by the way!

svdo commented 1 year ago

I just tried compiling different versions and running those in Xcode with the memory debugging options enabled, and it seems that v1.3.3 is the first version where it fails for me.