Sporadic crash in editor

SyntaxEditor for WPF Forum

Posted 19 days ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Version: 24.1.4
Platform: .NET 4.8
Environment: Windows 11 (64-bit)
Avatar

Hi,

we have received a customer report over sporadic crashes that happen when the editor is opened:

Unhandled Hardware Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.LTh()
   at ActiproSoftware.Internal.Efn.DdQ()
   at ActiproSoftware.Internal.Efn.ad6(Object  , Object  )
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)

The method seems to be "OnPointerHoverTimerTick".

I am not really sure what happens here. The only thing I can think of is, that this is a multi-thread issue where "pointerHoverEventArgs" is changed in a different thread. But that does not seem likely. Maybe you have a better idea?

The problem occurs when multiple files are loaded to restore the document layout. So I could imagine that the timer is started when the editor is visible. But by the time the tick event is handled, the editor is no longer visible.

We actually have a couple of services that implement "IEditorViewPointerInputEventSink", but the callback for "NotifyPointerHovered" is always empty. So I don't think they are the problem here.

[Modified 19 days ago]


Best regards, Tobias Lingemann.

Comments (3)

Posted 19 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

Can you tell us the exact versions of the Actipro assemblies and .NET used when that stack trace was created?  I tried to deobfuscate it with the latest version but it didn't succeed so it could be you use an older version/build.

We use DispatcherTimer to drive an internal mechanism for any kind of timer needs, and it can fire for many things.  For EditorView specifically, we use the timer mechanism for tracking pointer hovers (OnPointerHoverTimerTick), possible drag/drop start determination (OnPointerActionTimerTick), and selection extension while the pointer button is pressed (also OnPointerActionTimerTick).  Let's narrow down which method it is first.

Try to get the exact version information requested above, and also see if you can reproduce it yourself.  Is the mouse button down at all when this occurs or no?  If not, it likely is the hover handler.  Thanks!


Actipro Software Support

Posted 19 days ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Right, that would be 23.1.4, but we recently updated to 24.1.4 and the source code seems to be identical at this point.

I already said that the crash occurs in "OnPointerHoverTimerTick" and I don't think the mouse button is pressed at this point. This happens while multiple documents are loaded to restore the document layout. We never ran into this issue or had other customer report the same problem. So I think, this could be specific to the client configuration (maybe a specific version or update of the .net framework). But apparently the user has .net framework 4.8.1 (533320), the same version we use here.

However there is one specialty I should mention. We need to force the views to load directly when opened, because there are some old WinForms control in use that don't work correctly if we don't. So after a view is created we add a dummy operation to the dispatcher and wait for it:

var dummyOperation = dispatcher.BeginInvoke(DispatcherPriority.Loaded, (Action)(() => { }));
dummyOperation.Wait();

This forces all documents to be briefly visible and I suppose this could start the hover timer if the mouse is moved.

Another thing that caught my attention was the text "Unhandled Hardware Exception". I am not sure what could cause this. Maybe this is caused by the .net framework when Windows runs out of user handles?

Another idea I had was that this could be due to insufficient memory, but the user has 100 Gigs of free memory, when the application is started. So this should be enough :D


Best regards, Tobias Lingemann.

Answer - Posted 18 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

OnPointerHoverTimerTick has the same method signature as OnPointerActionTimerTick and is called by the same code stack trace, which is why I asked.  Now knowing the version used, I was able to verify with the deobfuscator that it is indeed OnPointerHoverTimerTick.

I'm not sure what the Unhandled Hardware Exception is related to.

We've done some refactoring of the OnPointerHoverTimerTick method to try and prevent any possible null ref exceptions, even if something async alters state elsewhere.  This update will be in the next build.


Actipro Software Support

The latest build of this product (v24.1.5) was released 4 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.