Crashing at OnContextMenuOpening

Shell for WPF Forum

The latest build of this product (v24.1.3) was released 1 month ago, which was before this thread was created.
Posted 25 days ago by rex hui
Version: 24.1.3
Avatar

Our customer has reported a crash:

Unhandled exception at 0x00007FFB5ACBB699 (KERNELBASE.dll) in FlexFtp.exe_240917_133453.dmp: 0xC000041D: An unhandled exception was encountered during a user callback.

The crash dump shows the location of the crash at TreeListBoxItem.cs at the close bracket of the catch:
protected override void OnContextMenuOpening(ContextMenuEventArgs e)
{
base.OnContextMenuOpening(e);
if (e == null || e.Handled || !ContextMenuService.GetIsEnabled(this) || GqF == null)
{
return;
}
TreeListBox treeListBox = GqF.TaA();
if (treeListBox == null)
{
return;
}
Point? pointerLocation = null;
if (e.CursorLeft >= 0.0 && e.CursorTop >= 0.0)
{
pointerLocation = new Point(e.CursorLeft, e.CursorTop);
Visual visual = e.OriginalSource as Visual;
if (visual == null && e.OriginalSource is FrameworkContentElement frameworkContentElement)
{
visual = frameworkContentElement.Parent as Visual;
}
if (visual != null && visual != this)
{
try
{
if (visual.FindCommonVisualAncestor(this) != null)
{
pointerLocation = visual.TransformToVisual(this).Transform(pointerLocation.Value);
}
}
catch (InvalidOperationException)
{
}

Do you have any idea?

Comments (7)

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

Hi Rex,

Could you tell us what the exception type or message was?

We aren't aware of any issues with that method's logic.  Do you have a way to reproduce it?


Actipro Software Support

Posted 24 days ago by rex hui
Avatar

As mentioned above, this was the exception when we debugged the crash dump:

Unhandled exception at 0x00007FFB5ACBB699 (KERNELBASE.dll) in FlexFtp.exe_240917_133453.dmp: 0xC000041D: An unhandled exception was encountered during a user callback.


No, we were not able to recreate the crash on our side but the customer was able to consistently recreate it.

I saw on the latest maintenance release and wonder if that is related:
"Fixed an issue where Shell context menus could throw an exception in a certain scenario."

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

Hi Rex,

Your original post seemed to indicate you were on the latest maintenance release.  If that is not the case, which one are you on?  And I would definitely suggest trying v24.1.3 to see if the update for that release history item you mentioned makes a difference.  I believe the related error for that item was an Access Violation.


Actipro Software Support

Posted 21 days ago by rex hui
Avatar

He was using the previous version but I had him tried with the latest v24.1.3 build and still having the same issue.

But I am wondering if the fix for this latest maintenance release is somewhat related to this crash?

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

The Shell fix was in methods called by the method whose code you originally posted above.  If you are sure the problem is directly in the code posted above, then it is likely something else.

Unfotunately we don't have much to go on since neither of us can reproduce it.  Does your customer have Visual Studio?  I wonder if they could attach to the application process to gather more information like the exception type, message, and exactly what line throws the exception and in which type/method.


Actipro Software Support

Posted 19 days ago by rex hui
Avatar

It seems the fix you did for v24.1.3 does not fix the crash.

The user has provided us a new crash dump with the v24.1.3 build and it points to line 970 of TreeListBoxItem.cs:
if (!treeListBoxItemMenuEventArgs.Cancel && treeListBoxItemMenuEventArgs.Menu != null)

And following the stack trace points to line 241 of DUCE.cs:
MS.Internal.HRESULT.Check(MilCoreApi.MilComposition_SyncFlush(_hChannel));

And the exception is:

Unhandled exception at 0x00007FFC15B8B699 (KERNELBASE.dll) in FlexFtp.exe_240925_132934.dmp: 0xC000041D: An unhandled exception was encountered during a user callback.

Will it help if we send you the crash dump along with our program files?

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

Hello,

Unfortunately I don't see how an exception could occur on that particular TreeListBoxItem line you referenced.  The event arguments variable shouldn't be null there since it was just created a couple lines above, and the properties it references are basic properties.  I don't think the crash dump is pointing to the right thing, at least in our code portion.

The presence of the second line you mentioned with HRESULT would mean something is going on in Microsoft's code with Win32.  I believe DUCE is related to the WPF render thread.

https://learn.microsoft.com/en-gb/troubleshoot/developer/dotnet/framework/general/wpf-render-thread-failures

That article says:

The most common bucket of WPF render thread failures is associated with video hardware or driver problems.

You could have them try updating their graphics card drivers to see if it helps at all.

Is your app attaching to the DispatcherUnhandledException event?  The generic crash dump info above really doesn't tell us much, like the true .NET Exception cause of the issue.  Perhaps by handling that event, you could gather more information about the true Exception that triggered things.  Then we might know if it's an out of memory issue, or invalid operation, or something else.  And it would be helpful to have a true full stack trace out of that Exception, including the stack trace and information from any inner Exceptions that may also be present.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.