Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking Commit causes a crash #3827

Closed
default0 opened this issue Jul 8, 2017 · 10 comments
Closed

Clicking Commit causes a crash #3827

default0 opened this issue Jul 8, 2017 · 10 comments
Assignees
Milestone

Comments

@default0
Copy link

default0 commented Jul 8, 2017

Do you want to request a feature or report a bug?
This is a bug report.

What is the current behavior?
If I open my repository and click the "Commit" button I immediately get a NullReferenceException, crashing the application.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Run the application without an attached debugger (building and running a built version w/ attached debugger made this issue cease to trigger). Now, after the application started, you can attach a debugger. Click "Commit" (and maybe make sure there are technically things to commit).

What is the expected behavior?
The Commit dialog opens

Which versions of GitExtensions, GIT and Windows are affected by this issue? Did this work in previous versions of our tool?
Versions affected were 2.50, 2.50.01 and all builds I could produce with the code from commit 76aa0ea.

The above steps trigger a NullReferenceException on EditNetSpell.cs on line 932, where the debugger shows that _customUnderlines is null. A quick inspection of the code lead me to believe that there's no conceivable way it should ever be null, since it's given a value in the constructor, so maybe the debugger is failing me, or there are other things going on that I won't understand unless I dig into the infrastructure of the project, which I would like to avoid.

Advice/encouragement/a bugfix for this would be highly appreciated, as this effectively renders GitExtensions 2.50+ useless for me.

@RussKie
Copy link
Member

RussKie commented Jul 11, 2017

Can you post the full stack trace?
Perhaps it got disposed (

_customUnderlines.Dispose();
) and that's why you get null. Though it doesn't explain why that happens.

You can try this fix, though arguably it is a mere workaround rather than fix:

if (_customUnderlines == null || _customUnderlines.IsImeStartingComposition)
{
    return;
}

@default0
Copy link
Author

Exception Stack Trace:

at GitUI.SpellChecker.EditNetSpell.UpdateOrShowAutoComplete(Boolean calledByUser) in C:\\Users\\Gregory\\Documents\\gitextensions\\GitUI\\SpellChecker\\EditNetSpell.cs:Zeile 932.

Little screenshot of the callstack:
http://i.imgur.com/BtroZkF.png

It's German, but "Zeile" means "Line".

Hope this helps.

The bandaid fix does work, to be sure.

@RussKie
Copy link
Member

RussKie commented Jul 12, 2017

I am unable to repro the issue. Built in both Debug and Release, attached or detached, I've tried it on W7, W10 and Ubuntu.

Does it happen for all git repos or only specific ones?
What OS are you on, VS version etc?
Can there be anything special about your setup?

Can you perhaps put a breakpoint in Dispose method and see if it gets disposed.

@default0
Copy link
Author

Im on windows 7 , it happens for all repos, Im building this using VS2015.
I dont think theres anything specific about my setup, but I may be wrong, just nothing I can think of really that should affect this.

A breakpoint on the first line of EditNetSpell.Dispose is not hit.

The exact Windows Version is: 6.1.7601 build 1130 (SP 1)

@EbenZhang
Copy link
Contributor

Can you upload your gitui.dll? I am afraid that you may have some changes to the editnetspell.cs?

@default0
Copy link
Author

Wouldn't it be easier if I uploaded a complete windows build?
I didn't change any files from the commit I referenced in the OP (76aa0ea).

@Aldaviva
Copy link

Total C# novice here, but it sort of looks like the EditNetSpell constructor's call to the SpellCheckEditControl constructor causes a call to TextBox_SelectionChanged which runs UpdateOrShowAutoComplete(false), all before the SpellCheckEditControl or EditNetSpell constructors have returned, so _customUnderlines is still null inside UpdateOrShowAutoComplete.

Here's my stacktrace:

    GitUI.dll!GitUI.SpellChecker.EditNetSpell.UpdateOrShowAutoComplete(bool calledByUser) Line 932  C#
    GitUI.dll!GitUI.SpellChecker.EditNetSpell.TextBox_SelectionChanged(object sender, System.EventArgs e) Line 711  C#
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.OnSelectionChanged(System.EventArgs e)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.WmSelectionChange(System.Windows.Forms.NativeMethods.SELCHANGE selChange) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.WmReflectNotify(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)    Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.Control.SendMessage(int msg, System.IntPtr wparam, System.IntPtr lparam)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.ReflectMessageInternal(System.IntPtr hWnd, ref System.Windows.Forms.Message m)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WmNotify(ref System.Windows.Forms.Message m)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ParkingWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)    Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)    Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.SetCharFormat(int charRange, System.Windows.Forms.NativeMethods.CHARFORMATA cf)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.InternalSetForeColor(System.Drawing.Color value)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.OnHandleCreated(System.EventArgs e)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WmCreate(ref System.Windows.Forms.Message m)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.RichTextBox.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)    Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(int dwExStyle, string lpszClassName, string lpszWindowName, int style, int x, int y, int width, int height, System.Runtime.InteropServices.HandleRef hWndParent, System.Runtime.InteropServices.HandleRef hMenu, System.Runtime.InteropServices.HandleRef hInst, object pvParam)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle()    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.TextBoxBase.CreateHandle()    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.Handle.get()  Unknown
    GitUI.dll!GitUI.SpellChecker.SpellCheckEditControl.SpellCheckEditControl(System.Windows.Forms.RichTextBox richTextBox) Line 29  C#
>   GitUI.dll!GitUI.SpellChecker.EditNetSpell.EditNetSpell() Line 66    C#
    GitUI.dll!GitUI.CommandsDialogs.FormCommit.InitializeComponent() Line 118   C#
    GitUI.dll!GitUI.CommandsDialogs.FormCommit.FormCommit(GitUI.GitUICommands aCommands, GitUI.CommandsDialogs.CommitKind commitKind, GitCommands.GitRevision editedCommit) Line 160    C#
    GitUI.dll!GitUI.GitUICommands.StartCommitDialog.AnonymousMethod__0() Line 682   C#
    GitUI.dll!GitUI.GitUICommands.DoActionOnRepo(System.Windows.Forms.IWin32Window owner, bool requiresValidWorkingDir, bool changesRepo, GitUIPluginInterfaces.GitUIEventHandler preEvent, GitUIPluginInterfaces.GitUIPostActionEventHandler postEvent, System.Func<bool> action) Line 450 C#
    GitUI.dll!GitUI.GitUICommands.StartCommitDialog(System.Windows.Forms.IWin32Window owner, bool showOnlyWhenChanges) Line 692 C#
    GitUI.dll!GitUI.CommandsDialogs.FormBrowse.StatusClick(object sender, System.EventArgs e) Line 2229 C#
    System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.RaiseEvent(object key, System.EventArgs e)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.ToolStripMenuItem.OnClick(System.EventArgs e) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleClick(System.EventArgs e) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleMouseUp(System.Windows.Forms.MouseEventArgs e)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.OnMouseUp(System.Windows.Forms.MouseEventArgs mea)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.WndProc(ref System.Windows.Forms.Message m) Unknown
    GitUI.dll!GitUI.ToolStripEx.WndProc(ref System.Windows.Forms.Message m) Line 37 C#
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)    Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
    GitUI.dll!GitUI.GitUICommands.StartBrowseDialog(System.Windows.Forms.IWin32Window owner, string filter, string selectedCommit) Line 1499    C#
    GitUI.dll!GitUI.GitUICommands.StartBrowseDialog() Line 291  C#
    GitExtensions.exe!GitExtensions.Program.Main()  Unknown

@RussKie
Copy link
Member

RussKie commented Jul 14, 2017

@Aldaviva I think you might just hit the jackpot here.
It may be that the instantiation of SpellCheckEditControl needs to happen on ParentChanged or Activated events (writing from a phone so could get events wrong)

@RussKie RussKie self-assigned this Jul 31, 2017
RussKie added a commit to RussKie/gitextensions that referenced this issue Aug 1, 2017
In some circumstances SpellCheckEditControl could be initialised and
start raising events before EditNetSpell control completed instantiation
sequence. This would lead to NRE.

The initialisation sequence adjusted to initialise SpellCheckEditControl
after EditNetSpell control has loaded.

Fixes gitextensions#3827
@RussKie
Copy link
Member

RussKie commented Aug 2, 2017

@default0 could you please try this build and see if the problem is fixed?
https://ci.appveyor.com/api/buildjobs/a6tp93smfcgmlvg2/artifacts/GitExtensions-2.50.01.487-Mono.zip

@default0
Copy link
Author

default0 commented Aug 2, 2017

Yep, that fixes it.
Thanks a lot!

RussKie added a commit that referenced this issue Aug 6, 2017
In some circumstances SpellCheckEditControl could be initialised and
start raising events before EditNetSpell control completed instantiation
sequence. This would lead to NRE.

The initialisation sequence adjusted to initialise SpellCheckEditControl
after EditNetSpell control has loaded.

Fixes #3827

(cherry picked from commit a9bd622)
@RussKie RussKie added this to the 2.50.02 milestone Aug 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants