Repository navigation
Description
Description
SourceGit 2026.24.0 (win-x64) exited abruptly while I was switching the active repository in the sidebar 鈥?no error dialog, no chance to save anything, the window just disappeared. Windows logged the process as terminated by fail-fast (0xc0000409) right after an unhandled exception on the UI thread.
It is a UI-thread crash inside CommitRefsPresenter.MeasureOverride, i.e. the branch/tag badge cell of the history grid, during the layout pass that materializes new DataGrid rows.
Environment
- SourceGit
2026.24.0.0(latest release, 2026-11-09) - Windows 10 22H2 (
10.0.19045), .NET 10.0.14, git 2.56.1.windows.1 ShowTagsInGraph= true,UseCompactBranchNamesInGraph= true,MaxHistoryCommits= 20000, customThemeOverridesJSON- Repos are small on the ref side (2 local branches, 7 tags, 5 remote refs, ~500 commits), so ref count is not extreme.
Steps to reproduce
Observed once, after ~7.5 h uptime with several repository tabs open; not reproduced on demand yet.
- Open several repositories in one workspace.
- Click another repository in the sidebar so the history view is rebuilt.
- The process died during the layout pass, before the new history finished rendering.
Crash log
%APPDATA%\SourceGit\crashes\2026-11-23_00-08-47.log (top of the 76-line stack):
Crash::: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
Version: 2026.24.0.0 | OS: Microsoft Windows NT 10.0.19045.0 | Framework: .NETCoreApp,Version=v10.0
App Start Time: 2026/11/22 17:16:28 | Exception Time: 2026/11/23 00:08:47 | Memory Usage: 413 MB
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at SourceGit.Views.CommitRefsPresenter.MeasureOverride(Size availableSize) + 0x94a
at Avalonia.Layout.Layoutable.MeasureCore(Size) + 0x399
at Avalonia.Controls.Grid.MeasureCell(Int32, Boolean) + 0x16e
at Avalonia.Controls.Border.MeasureOverride(Size) + 0x96
at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size) + 0x71
at Avalonia.Controls.Primitives.DataGridCellsPresenter.MeasureOverride(Size) + 0xb2e
at Avalonia.Controls.DataGridRow.MeasureOverride(Size) + 0x6c
at Avalonia.Controls.DataGrid.InsertDisplayedElement(Int32, Control, Boolean, Boolean) + 0xc1
at Avalonia.Controls.DataGrid.AddSlotElement(Int32, Control) + 0x38
at Avalonia.Controls.DataGrid.AddSlots(Int32) + 0xf7
at Avalonia.Controls.DataGrid.RefreshRows(Boolean, Boolean) + 0x1c0
at Avalonia.Controls.DataGrid.RefreshRowsAndColumns(Boolean) + 0x116
at Avalonia.Controls.DataGrid.MeasureOverride(Size) + 0x2f
at Avalonia.Layout.LayoutManager.ExecuteLayoutPass() + 0x26d
at Avalonia.Media.MediaContext.Render() + 0x17
at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean) + 0x387
at Avalonia.Win32.Win32Platform.WndProc(...) + 0x58
Windows Application log, same instant: Event 1026 .NET Runtime ("process was terminated due to an unhandled exception", same exception) and Event 1000 Application Error (0xc0000409).
Where it probably comes from
CommitRefsPresenter.MeasureOverride (v2026.24, still unchanged on master) has two indexed accesses that can throw ArgumentOutOfRangeException on a List<T>:
Models.CommitGraph.Pens[commit.Color]鈥?Pensis aList<Pen>thatSetPensclears and repopulates, so a stalecommit.Colorcan be out of range.- The decorator loop:
var refs = commit.Decorators; // List<Decorator>, mutated in place
var count = refs.Count; // snapshot taken once
...
var decorator = refs[i]; // OOR if the list shrank after count was readCommit.Decorators is a plain List<Decorator> mutated by ParseDecorators (adds then sorts), with no synchronization against the UI thread that measures/renders the rows. Switching repositories reloads refs and history at the same time as the grid materializes rows (RefreshRows 鈫?AddSlots 鈫?MeasureOverride), which matches the timing; +0x94a looks more like the decorator loop than the pen lookup, but I can't prove it from the offset.
Suggested hardening:
- Iterate over an immutable snapshot (
commit.Decorators.ToArray()), or publish decorators as an immutable array replaced wholesale instead of mutated in place; likewise don'tClear()CommitGraph.Penswhere a render can observe it. - Given a layout exception on the UI thread is fatal for the whole process (no dialog, unsaved work lost), a bounds guard here is cheap insurance.
Expected behavior
Switching repositories must never kill the process; worst case the badge cell renders empty for one frame and is refreshed on the next layout pass.
Activity
fix: guard against out-of-range access in CommitRefsPresenter and Com…
JC-Chung commentedon Nov 23, 2026
Done. Both indexed accesses in
CommitRefsPresenter.MeasureOverrideare now guarded (bounds-checkedGetPen()+ decorator snapshot). Since it wasn't reproducible on demand, please reopen if you see the same stack again. Latest CI build is available from GitHub Actions.