Unplanned
Last Updated: 01 Mar 2024 07:13 by ADMIN
Christian
Created on: 21 Mar 2022 08:26
Category: RichTextBox
Type: Bug Report
5
Crash in PasteOptionsPopup (null ref exception in LayoutElement.SetParent)

Working with PasteOptionsPopup may cause an exception in LayoutElement.SetParent. Very difficult to reproduce, having no consistent steps. Maybe it is related to undo of paste command, but there are no other clues aside from this.

   bei Telerik.Windows.Documents.Layout.LayoutElement.SetParent(LayoutElement newParent)
   bei Telerik.Windows.Documents.Layout.LayoutBox.EnsureParent()
   bei Telerik.Windows.Documents.Layout.LayoutBox.get_Parent()
   bei Telerik.Windows.Documents.Layout.FormattingSymbolLayoutBox.get_IsEndOfCell()
   bei Telerik.Windows.Documents.Layout.FormattingSymbolLayoutBox.GetFormattingSymbolVisual()
   bei Telerik.Windows.Documents.Layout.FormattingSymbolLayoutBox.get_Text()
   bei Telerik.Windows.Documents.SpanBoxPositionHandler.get_Location()
   bei Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.GetViewPointFromDocumentPosition(DocumentPosition position)
   bei Telerik.Windows.Controls.RichTextBoxUI.PasteOptionsPopup.CalculateLocation()
   bei Telerik.Windows.Controls.RichTextBoxUI.PasteOptionsPopup.OnOwnerLayoutUpdated(Object sender, EventArgs e)
   bei System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
   bei System.Windows.ContextLayoutManager.UpdateLayout()
   bei System.Windows.UIElement.UpdateLayout()
9 comments
ADMIN
Dimitar
Posted on: 01 Mar 2024 07:13

Hello Valentin,

Sure I will pass on your feedback. A clear way to reproduce this ensures that your exact case will be fixed and we will not be guessing what is going on and this is why I have asked for details. 

I hope the options can serve as a workaround. Let me know if I can be of further assistance.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Valentin
Posted on: 01 Mar 2024 02:49
We just came across the option to turn off the Paste Options pop-up and we will likely do so in the short term and use the default paste option of keeping source formatting. Perhaps this will alleviate the problem in the short term.
Valentin
Posted on: 29 Feb 2024 19:21

Hello Dimitar, one of our users experienced issue this again today. As the other posters have said, the issue pops up rather randomly, making it very hard to get feedback other than "I was copy/pasting". We will continue to try to narrow down what they are doing.

In the mean time though, I thought my analysis of the stack trace points to what seems to be an obvious bad assumption in LayoutElement SetParent. 

Are you going to pass my feedback along to your development team?

ADMIN
Dimitar
Posted on: 29 Feb 2024 08:05

Hello Valentin,

It will be of great help if you can reproduce it in a sample project or provide the exact steps for reproducing. I am asking since we do not have a good way to reproduce this, making it harder for our developers to pinpoint the exact reason. 

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Valentin
Posted on: 29 Feb 2024 05:24

Looking at the source code one can see that LayoutElement SetParent does this:

...

#if DEBUG
            this.ValidateParent(newParent);
#endif
            this.DocumentCollection = newParent.DocumentCollection;

...

Note how it does not check newParent for null before dereferencing it, yet looking at ValidateParent, which is called only in debug mode, if I read the isValid expression right one can see that the last valid value is

...

|| newParent == null;

...

so a null newParent seems to be valid? There are code paths that return null when calling LayoutBox GetParent() and eventually DocumentStructureCollection.GetParent(this) and this potential, if unlikely, null result is fed to SetParent.

I suspect this causes the null reference exception that's triggering the infinite loop in our case.

Could the fix be as simple as a null check here if null is expected?

Valentin
Posted on: 29 Feb 2024 03:49

We're experiencing this issue as well, and in our case it causes the infinite loop described here https://feedback.telerik.com/wpf/1461453-pasteoptionspopup-throws-an-unhandled-dispatcher-exception-in-an-infinite-loop. I added a comment in that feedback thread but since it's closed and it eventually leads here I figure I'd post it here as well.

A search yielded this https://stackoverflow.com/questions/14211306/stack-overflow-after-an-exception-in-control-layoutupdated-if-dispatcherunhandle.

It turns out that our application does register a handler for DispatcherUnhandledException in which we display a MessageBox.

The SO post seems to say that displaying the MessageBox triggers another layout pass which then likely throws the initial exception again and so on, in a loop which in our application results in a cascade of MessageBoxes like in the attached screenshot.

We're trying to obtain more information from our user to hopefully create a reproducible scenario.

 

Attached Files:
ADMIN
Dimitar
Posted on: 27 May 2022 04:34

Hello,

Thank you both for your feedback, I will pass it to the team. We can see if we can increase the priority of this issue. 

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Luc
Posted on: 25 May 2022 19:59
me too got this error!!
jdirienzi
Posted on: 20 May 2022 12:47

We have the same issue with 2021.1.223.45. Same StackTrace.

400 users, at least 4 crashes a day with this error.

We can't repro, but users say it may be when they copy/paste from Word/browser/Outlook and/or use backspace button.