libgit sometimes crashes if a chunk is both staged and modified
It has happened twice to me so far, I think I've pinpointed the issue to the following scenario:
- I stage some code/chunk into git
- Try to modify the same chunk that was staged, and save the file
- Current state of the git repo is,
M M foobar.py
- Try to modify the same place/chunk of the file again
- Builder crashes with the following assertion
ide-git-buffer-change-monitor:ERROR:../src/plugins/git/ide-git-buffer-change-monitor.c:525:find_or_add_line: assertion failed: (line >= 0)
Here is a gdb backtrace
➜ ~ flatpak run --command=sh org.gnome.Builder/x86_64/master
sh-4.4$ gdb gnome-builder
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gnome-builder...Reading symbols from /usr/lib/debug//app/bin/gnome-builder.debug...done.
done.
(gdb) r
Starting program: /app/bin/gnome-builder
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffed5d6700 (LWP 9)]
[New Thread 0x7fffecdd5700 (LWP 10)]
(gnome-builder:5): Gdk-WARNING **: 03:34:45.000: Failed to read portal settings: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.Settings” on object at path /org/freedesktop/portal/desktop
[New Thread 0x7fffec5d4700 (LWP 11)]
[New Thread 0x7fffebd09700 (LWP 12)]
(gnome-builder:5): Gtk-WARNING **: 03:34:45.376: Theme parsing error: gtk-contained.css:1962:26: The 'icon-shadow' property has been renamed to '-gtk-icon-shadow'
(gnome-builder:5): Gtk-WARNING **: 03:34:45.376: Theme parsing error: gtk-contained.css:1965:30: The 'icon-shadow' property has been renamed to '-gtk-icon-shadow'
[Detaching after fork from child process 13]
[New Thread 0x7fffe9cab700 (LWP 15)]
[Thread 0x7fffe9cab700 (LWP 15) exited]
(gnome-builder:5): Gtk-WARNING **: 03:34:47.753: Theme parsing error: gtk-contained-dark.css:1942:26: The 'icon-shadow' property has been renamed to '-gtk-icon-shadow'
(gnome-builder:5): Gtk-WARNING **: 03:34:47.753: Theme parsing error: gtk-contained-dark.css:1945:30: The 'icon-shadow' property has been renamed to '-gtk-icon-shadow'
[New Thread 0x7fffe9cab700 (LWP 16)]
[Thread 0x7fffec5d4700 (LWP 11) exited]
[New Thread 0x7fffec5d4700 (LWP 17)]
[New Thread 0x7fffe8333700 (LWP 18)]
[New Thread 0x7fffe7b32700 (LWP 19)]
[New Thread 0x7fffe7331700 (LWP 20)]
[Thread 0x7fffe7b32700 (LWP 19) exited]
[Thread 0x7fffe7331700 (LWP 20) exited]
[Thread 0x7fffe8333700 (LWP 18) exited]
[Thread 0x7fffec5d4700 (LWP 17) exited]
[New Thread 0x7fffec5d4700 (LWP 21)]
[Detaching after fork from child process 22]
(gnome-builder:5): Gtk-CRITICAL **: 03:35:02.517: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
(gnome-builder:5): Gtk-CRITICAL **: 03:35:02.550: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
[New Thread 0x7fffe7331700 (LWP 25)]
[New Thread 0x7fffe8333700 (LWP 26)]
[Detaching after fork from child process 27]
[Detaching after fork from child process 29]
[Detaching after fork from child process 31]
[Detaching after fork from child process 32]
[Detaching after fork from child process 34]
[Detaching after fork from child process 36]
[Detaching after fork from child process 37]
[Detaching after fork from child process 39]
[Detaching after fork from child process 41]
[Detaching after fork from child process 43]
[Detaching after fork from child process 44]
[Detaching after fork from child process 45]
[Detaching after fork from child process 47]
[Detaching after fork from child process 48]
[Detaching after fork from child process 50]
[Detaching after fork from child process 52]
[Detaching after fork from child process 54]
[Detaching after fork from child process 56]
[Detaching after fork from child process 58]
[Detaching after fork from child process 59]
[Detaching after fork from child process 60]
[Detaching after fork from child process 61]
[Detaching after fork from child process 63]
[Detaching after fork from child process 64]
[Detaching after fork from child process 65]
[Detaching after fork from child process 67]
[Detaching after fork from child process 69]
[Detaching after fork from child process 71]
[Detaching after fork from child process 73]
[Detaching after fork from child process 75]
[Detaching after fork from child process 77]
[Detaching after fork from child process 79]
[Detaching after fork from child process 80]
[Thread 0x7fffe9cab700 (LWP 16) exited]
[New Thread 0x7fffe9cab700 (LWP 82)]
[Thread 0x7fffe9cab700 (LWP 82) exited]
[New Thread 0x7fffe9cab700 (LWP 83)]
[New Thread 0x7fffe7b32700 (LWP 84)]
[Thread 0x7fffe7331700 (LWP 25) exited]
[Thread 0x7fffe7b32700 (LWP 84) exited]
[New Thread 0x7fffe7b32700 (LWP 85)]
[New Thread 0x7fffe7331700 (LWP 86)]
[Thread 0x7fffe7331700 (LWP 86) exited]
[New Thread 0x7fffe7331700 (LWP 87)]
[Detaching after fork from child process 88]
[Thread 0x7fffe9cab700 (LWP 83) exited]
[Thread 0x7fffe7b32700 (LWP 85) exited]
(gnome-builder:5): Gtk-CRITICAL **: 03:35:18.764: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
(gnome-builder:5): Gtk-CRITICAL **: 03:35:18.789: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
[Detaching after fork from child process 91]
[Detaching after fork from child process 100]
[Detaching after fork from child process 132]
[Detaching after fork from child process 141]
[Detaching after fork from child process 143]
[Detaching after fork from child process 144]
[Detaching after fork from child process 146]
[Detaching after fork from child process 148]
[Detaching after fork from child process 149]
[Detaching after fork from child process 150]
[Detaching after fork from child process 151]
[Detaching after fork from child process 152]
[Detaching after fork from child process 153]
[Detaching after fork from child process 154]
[Detaching after fork from child process 155]
[Detaching after fork from child process 157]
[Detaching after fork from child process 159]
[Detaching after fork from child process 161]
[Detaching after fork from child process 163]
[Detaching after fork from child process 165]
[Detaching after fork from child process 167]
[Detaching after fork from child process 169]
[Detaching after fork from child process 170]
[Detaching after fork from child process 171]
[Detaching after fork from child process 173]
[Detaching after fork from child process 175]
[Detaching after fork from child process 176]
[Detaching after fork from child process 178]
[Detaching after fork from child process 180]
[Detaching after fork from child process 182]
[New Thread 0x7fffe7b32700 (LWP 184)]
[New Thread 0x7fffe9cab700 (LWP 185)]
[Thread 0x7fffe7331700 (LWP 87) exited]
[Thread 0x7fffe9cab700 (LWP 185) exited]
**
ide-git-buffer-change-monitor:ERROR:../src/plugins/git/ide-git-buffer-change-monitor.c:525:find_or_add_line: assertion failed: (line >= 0)
Thread 14 "gnome-builder" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe8333700 (LWP 26)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 return ret;
(gdb) p line
No symbol "line" in current context.
(gdb) t a a bt
Thread 21 (Thread 0x7fffe7b32700 (LWP 184)):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007ffff77049ee in g_cond_wait_until (cond=cond@entry=0x555555e1cdc8, mutex=mutex@entry=0x555555e1cdc0, end_time=end_time@entry=96290865516) at ../glib/gthread-posix.c:1449
#2 0x00007ffff768a261 in g_async_queue_pop_intern_unlocked (queue=0x555555e1cdc0, wait=wait@entry=1, end_time=96290865516) at ../glib/gasyncqueue.c:422
#3 0x00007ffff768a8d1 in g_async_queue_timeout_pop_unlocked (queue=<optimized out>, timeout=timeout@entry=500000) at ../glib/gasyncqueue.c:574
#4 0x00007ffff76e31b2 in g_thread_pool_wait_for_new_task (pool=<optimized out>) at ../glib/gthreadpool.c:263
#5 g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:297
#6 0x00007ffff76e2619 in g_thread_proxy (data=0x555559661e00) at ../glib/gthread.c:784
#7 0x00007ffff6cbff7b in start_thread (arg=<optimized out>) at pthread_create.c:463
#8 0x00007ffff6bf13af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 14 (Thread 0x7fffe8333700 (LWP 26)):
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007ffff6b17525 in __GI_abort () at abort.c:79
#2 0x00007ffff7685dd3 in g_assertion_message (domain=<optimized out>, file=<optimized out>, line=<optimized out>, func=0x7ffff7929a70 <__func__.94734> "find_or_add_line", message=<optimized out>)
at ../glib/gtestutils.c:2621
#3 0x00007ffff76e183e in g_assertion_message_expr (domain=domain@entry=0x7ffff7929569 "ide-git-buffer-change-monitor", file=file@entry=0x7ffff7929720 "../src/plugins/git/ide-git-buffer-change-monitor.c",
line=line@entry=525, func=func@entry=0x7ffff7929a70 <__func__.94734> "find_or_add_line", expr=expr@entry=0x7ffff792959b "line >= 0") at ../glib/gtestutils.c:2647
#4 0x00007ffff787fa76 in find_or_add_line (array=0x5555568e5290, line=-2) at ../src/plugins/git/ide-git-buffer-change-monitor.c:525
#5 0x00007ffff787fc41 in diff_line_cb (delta=<optimized out>, hunk=0x5555595eb9c0, line=<optimized out>, user_data=0x7fffe8332b10) at ../src/plugins/git/ide-git-buffer-change-monitor.c:636
#6 0x00007ffff32c38ef in ggit_diff_line_callback_wrapper (delta=<optimized out>, hunk=<optimized out>, line=0x7fffe83320c0, user_data=0x7fffe83329f0) at ../libgit2-glib/ggit-diff.c:293
#7 0x00007ffff03c42c9 in git_xdiff_cb (priv=0x7fffe8332450, bufs=0x7fffe8332130, len=2) at src/diff_xdiff.c:156
#8 0x00007ffff0439da0 in xdl_emit_diffrec (rec=<optimized out>, size=<optimized out>, pre=pre@entry=0x7ffff0444e49 "-", psize=<optimized out>, ecb=ecb@entry=0x7fffe8332670) at src/xdiff/xutils.c:55
#9 0x00007ffff04360ec in xdl_emit_record (xdf=xdf@entry=0x7fffe83322c0, ri=ri@entry=45, pre=pre@entry=0x7ffff0444e49 "-", ecb=ecb@entry=0x7fffe8332670) at src/xdiff/xemit.c:47
#10 0x00007ffff04366a3 in xdl_emit_diff (xe=xe@entry=0x7fffe83322c0, xscr=xscr@entry=0x555559635e00, ecb=ecb@entry=0x7fffe8332670, xecfg=xecfg@entry=0x7fffe8332638) at src/xdiff/xemit.c:265
#11 0x00007ffff0435e63 in xdl_diff (mf1=mf1@entry=0x7fffe8332500, mf2=mf2@entry=0x7fffe8332510, xpp=xpp@entry=0x7fffe8332668, xecfg=xecfg@entry=0x7fffe8332638, ecb=ecb@entry=0x7fffe8332670)
at src/xdiff/xdiffi.c:607
#12 0x00007ffff03c4698 in git_xdiff (output=0x7fffe8332600, patch=0x7fffe8332680) at src/diff_xdiff.c:218
#13 0x00007ffff03f5c92 in patch_generated_create (patch=patch@entry=0x7fffe8332680, output=output@entry=0x7fffe8332600) at src/patch_generate.c:388
#14 0x00007ffff03f60b8 in diff_single_generate (xo=0x7fffe8332600, pd=0x7fffe8332680) at src/patch_generate.c:443
#15 patch_generated_from_sources (pd=pd@entry=0x7fffe8332680, xo=xo@entry=0x7fffe8332600, oldsrc=oldsrc@entry=0x7fffe8332910, newsrc=newsrc@entry=0x7fffe8332930, opts=opts@entry=0x0) at src/patch_generate.c:490
#16 0x00007ffff03f622c in diff_from_sources (oldsrc=oldsrc@entry=0x7fffe8332910, newsrc=newsrc@entry=0x7fffe8332930, opts=opts@entry=0x0, file_cb=file_cb@entry=0x0, binary_cb=binary_cb@entry=0x0,
hunk_cb=hunk_cb@entry=0x0, data_cb=0x7ffff32c3880 <ggit_diff_line_callback_wrapper>, payload=0x7fffe83329f0) at src/patch_generate.c:548
#17 0x00007ffff03f685f in git_diff_blob_to_buffer (old_blob=<optimized out>, old_path=old_path@entry=0x5555595eb160 "fractal-gtk/src/passwd.rs",
buf=buf@entry=0x555557a48000 "use secret_service;\n\n#[derive(Debug)]\npub enum Error {\n SecretServiceError,\n}\n\nderror!(secret_service::SsError, Error::SecretServiceError);\n\npub trait PasswordStorage {\n fn delete_pass(&self, ke"..., buflen=<optimized out>, buf_path=buf_path@entry=0x5555595eb160 "fractal-gtk/src/passwd.rs", opts=opts@entry=0x0, file_cb=0x0, binary_cb=0x0, hunk_cb=0x0,
data_cb=0x7ffff32c3880 <ggit_diff_line_callback_wrapper>, payload=0x7fffe83329f0) at src/patch_generate.c:636
#18 0x00007ffff32c4cec in ggit_diff_blob_to_buffer (old_blob=<optimized out>, old_as_path=old_as_path@entry=0x5555595eb160 "fractal-gtk/src/passwd.rs",
buffer=0x555557a48000 "use secret_service;\n\n#[derive(Debug)]\npub enum Error {\n SecretServiceError,\n}\n\nderror!(secret_service::SsError, Error::SecretServiceError);\n\npub trait PasswordStorage {\n fn delete_pass(&self, ke"..., buffer_len=<optimized out>, buffer_as_path=buffer_as_path@entry=0x5555595eb160 "fractal-gtk/src/passwd.rs", diff_options=diff_options@entry=0x0, file_cb=0x0, binary_cb=0x0,
hunk_cb=0x0, line_cb=0x7ffff787fba0 <diff_line_cb>, user_data=0x7fffe8332b10, error=0x7fffe8332b00) at ../libgit2-glib/ggit-diff.c:1017
#19 0x00007ffff78809e4 in ide_git_buffer_change_monitor_calculate_threaded (error=0x7fffe8332b00, diff=0x5555595fb7a0, self=<optimized out>) at ../src/plugins/git/ide-git-buffer-change-monitor.c:778
#20 ide_git_buffer_change_monitor_worker (data=0x555556b5e080) at ../src/plugins/git/ide-git-buffer-change-monitor.c:814
#21 0x00007ffff76e2619 in g_thread_proxy (data=0x555556bc0f00) at ../glib/gthread.c:784
#22 0x00007ffff6cbff7b in start_thread (arg=<optimized out>) at pthread_create.c:463
#23 0x00007ffff6bf13af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 12 (Thread 0x7fffec5d4700 (LWP 21)):
#0 futex_wait_cancelable (private=0, expected=0, futex_word=0x7fffe6a54a3c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1 __pthread_cond_wait_common (abstime=0x0, mutex=0x555558511890, cond=0x7fffe6a54a10) at pthread_cond_wait.c:502
#2 __pthread_cond_wait (cond=0x7fffe6a54a10, mutex=0x555558511890) at pthread_cond_wait.c:655
--Type <RET> for more, q to quit, c to continue without paging--
#3 0x00007ffff6a1b1f0 in __gthread_cond_wait (__mutex=<optimized out>, __cond=0x7fffe6a54a10)
at /usr/lib/debug/source/gcc.bst/bst_build_dir/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu/bits/gthr-default.h:864
#4 std::condition_variable::wait (this=this@entry=0x7fffe6a54a10, __lock=...) at ../../../../../libstdc++-v3/src/c++11/condition_variable.cc:53
#5 0x00007ffff2277a3c in std::_V2::condition_variable_any::wait<std::unique_lock<bmalloc::Mutex> > (__lock=<synthetic pointer>..., this=<optimized out>) at /usr/include/c++/8.2.0/bits/std_mutex.h:238
#6 std::_V2::condition_variable_any::wait<std::unique_lock<bmalloc::Mutex>, bmalloc::Scavenger::threadRunLoop()::<lambda()> > (__p=..., __lock=..., this=<optimized out>)
at /usr/include/c++/8.2.0/condition_variable:272
#7 bmalloc::Scavenger::threadRunLoop (this=0x7fffe6a549f8) at ../Source/bmalloc/bmalloc/Scavenger.cpp:380
#8 0x00007ffff2277d8f in bmalloc::Scavenger::threadEntryPoint (scavenger=<optimized out>) at ../Source/bmalloc/bmalloc/Scavenger.cpp:359
#9 0x00007ffff6a21483 in std::execute_native_thread_routine (__p=0x555557ec0960) at ../../../../../libstdc++-v3/src/c++11/thread.cc:80
#10 0x00007ffff6cbff7b in start_thread (arg=<optimized out>) at pthread_create.c:463
#11 0x00007ffff6bf13af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 5 (Thread 0x7fffebd09700 (LWP 12)):
#0 0x00007ffff6be66f1 in __GI___poll (fds=0x555555d7ac20, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007ffff76b9516 in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0x555555d7ac20, timeout=<optimized out>, context=0x555555e19c30) at ../glib/gmain.c:4230
#2 g_main_context_iterate (context=context@entry=0x555555e19c30, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:3924
#3 0x00007ffff76b9640 in g_main_context_iteration (context=context@entry=0x555555e19c30, may_block=may_block@entry=1) at ../glib/gmain.c:3990
#4 0x00007fffebdbefed in dconf_gdbus_worker_thread (user_data=0x555555e19c30) at ../gdbus/dconf-gdbus-thread.c:82
#5 0x00007ffff76e2619 in g_thread_proxy (data=0x555555e4e690) at ../glib/gthread.c:784
#6 0x00007ffff6cbff7b in start_thread (arg=<optimized out>) at pthread_create.c:463
#7 0x00007ffff6bf13af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 3 (Thread 0x7fffecdd5700 (LWP 10)):
#0 0x00007ffff6be66f1 in __GI___poll (fds=0x555556800510, nfds=6, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007ffff76b9516 in g_main_context_poll (priority=<optimized out>, n_fds=6, fds=0x555556800510, timeout=<optimized out>, context=0x555555e19600) at ../glib/gmain.c:4230
#2 g_main_context_iterate (context=0x555555e19600, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:3924
#3 0x00007ffff76b98d2 in g_main_loop_run (loop=0x555555e13640) at ../glib/gmain.c:4125
#4 0x00007ffff75ae27a in gdbus_shared_thread_func (user_data=0x555555e0a9a0) at ../gio/gdbusprivate.c:275
#5 0x00007ffff76e2619 in g_thread_proxy (data=0x555555e17540) at ../glib/gthread.c:784
#6 0x00007ffff6cbff7b in start_thread (arg=<optimized out>) at pthread_create.c:463
#7 0x00007ffff6bf13af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 2 (Thread 0x7fffed5d6700 (LWP 9)):
#0 0x00007ffff6be66f1 in __GI___poll (fds=0x555556077e40, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007ffff76b9516 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0x555556077e40, timeout=<optimized out>, context=0x555555e194a0) at ../glib/gmain.c:4230
#2 g_main_context_iterate (context=context@entry=0x555555e194a0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:3924
#3 0x00007ffff76b9640 in g_main_context_iteration (context=0x555555e194a0, may_block=may_block@entry=1) at ../glib/gmain.c:3990
#4 0x00007ffff76b9691 in glib_worker_main (data=<optimized out>) at ../glib/gmain.c:5870
#5 0x00007ffff76e2619 in g_thread_proxy (data=0x555555e16960) at ../glib/gthread.c:784
#6 0x00007ffff6cbff7b in start_thread (arg=<optimized out>) at pthread_create.c:463
#7 0x00007ffff6bf13af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 1 (Thread 0x7fffed98aac0 (LWP 5)):
#0 0x00007ffff6be66f1 in __GI___poll (fds=0x5555577fc2a0, nfds=12, timeout=84) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007ffff76b9516 in g_main_context_poll (priority=<optimized out>, n_fds=12, fds=0x5555577fc2a0, timeout=<optimized out>, context=0x555555dea0b0) at ../glib/gmain.c:4230
#2 g_main_context_iterate (context=context@entry=0x555555dea0b0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:3924
#3 0x00007ffff76b9640 in g_main_context_iteration (context=context@entry=0x555555dea0b0, may_block=may_block@entry=1) at ../glib/gmain.c:3990
#4 0x00007ffff7573c45 in g_application_run (application=0x555555dc2110, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5e8) at ../gio/gapplication.c:2516
#5 0x00005555555564b1 in main (argc=<optimized out>, argv=<optimized out>) at ../src/main.c:122
(gdb)