Closed Bug 1396976 Opened 2 years ago Closed 2 years ago

Assertion failure: !HasAddedNodesDuringDocumentChange() [@ mozilla::IMEContentObserver::BeginDocumentUpdate]

Categories

(Core :: DOM: Events, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox-esr52 --- unaffected
firefox55 --- wontfix
firefox56 --- wontfix
firefox57 --- fixed

People

(Reporter: tsmith, Assigned: Nika)

References

(Blocks 1 open bug)

Details

(Keywords: assertion, testcase)

Attachments

(3 files)

Attached file test_case.html
Assertion failure: !HasAddedNodesDuringDocumentChange(), at /builds/worker/workspace/build/src/dom/events/IMEContentObserver.cpp:1379

#0 0x7ff6b1b478d4 in mozilla::IMEContentObserver::BeginDocumentUpdate() /src/dom/events/IMEContentObserver.cpp:1379:3
#1 0x7ff6b0054b9a in nsDocument::BeginUpdate(unsigned int) /src/dom/base/nsDocument.cpp:5349:3
#2 0x7ff6b0110d34 in nsINode::doRemoveChildAt(unsigned int, bool, nsIContent*, nsAttrAndChildArray&) /src/dom/base/nsINode.cpp:1919:20
#3 0x7ff6afee0895 in mozilla::dom::FragmentOrElement::RemoveChildAt(unsigned int, bool) /src/dom/base/FragmentOrElement.cpp:1369:5
#4 0x7ff6b010a31d in nsINode::RemoveChild(nsINode&, mozilla::ErrorResult&) /src/dom/base/nsINode.cpp:604:3
#5 0x7ff6b3121a5c in mozilla::DeleteNodeTransaction::DoTransaction() /src/editor/libeditor/DeleteNodeTransaction.cpp:73:16
#6 0x7ff6b31239b8 in mozilla::EditAggregateTransaction::DoTransaction() /src/editor/libeditor/EditAggregateTransaction.cpp:42:24
#7 0x7ff6b312295e in mozilla::DeleteRangeTransaction::DoTransaction() /src/editor/libeditor/DeleteRangeTransaction.cpp:86:43
#8 0x7ff6b31239b8 in mozilla::EditAggregateTransaction::DoTransaction() /src/editor/libeditor/EditAggregateTransaction.cpp:42:24
#9 0x7ff6b32682c5 in nsTransactionManager::BeginTransaction(nsITransaction*, nsISupports*) /src/editor/txmgr/nsTransactionManager.cpp:661:21
#10 0x7ff6b3267f7c in nsTransactionManager::DoTransaction(nsITransaction*) /src/editor/txmgr/nsTransactionManager.cpp:74:8
#11 0x7ff6b312a9b7 in mozilla::EditorBase::DoTransaction(mozilla::dom::Selection*, nsITransaction*) /src/editor/libeditor/EditorBase.cpp:758:20
#12 0x7ff6b314305c in mozilla::EditorBase::DeleteSelectionImpl(short, short) /src/editor/libeditor/EditorBase.cpp:4144:17
#13 0x7ff6b323f959 in mozilla::TextEditor::DeleteSelection(short, short) /src/editor/libeditor/TextEditor.cpp:630:10
#14 0x7ff6b32352b8 in mozilla::TextEditRules::WillInsertText(EditAction, mozilla::dom::Selection*, bool*, bool*, nsAString const*, nsAString*, int) /src/editor/libeditor/TextEditRules.cpp:669:23
#15 0x7ff6b323457f in mozilla::TextEditRules::WillDoAction(mozilla::dom::Selection*, mozilla::RulesInfo*, bool*, bool*) /src/editor/libeditor/TextEditRules.cpp:279:14
#16 0x7ff6b323ff06 in mozilla::TextEditor::InsertText(nsAString const&) /src/editor/libeditor/TextEditor.cpp:669:24
#17 0x7ff6b32410f1 in mozilla::TextEditor::SetText(nsAString const&) /src/editor/libeditor/TextEditor.cpp:808:14
#18 0x7ff6b1e33e9c in nsTextEditorState::SetValue(nsAString const&, nsAString const*, unsigned int) /src/dom/html/nsTextEditorState.cpp:2694:25
#19 0x7ff6b1dc37fa in mozilla::dom::HTMLTextAreaElement::SetValueInternal(nsAString const&, unsigned int) /src/dom/html/HTMLTextAreaElement.cpp:388:15
#20 0x7ff6b1dc56c2 in mozilla::dom::HTMLTextAreaElement::Reset() /src/dom/html/HTMLTextAreaElement.cpp:853:17
#21 0x7ff6b1dc8505 in mozilla::dom::HTMLTextAreaElement::ContentChanged(nsIContent*) /src/dom/html/HTMLTextAreaElement.cpp:1092:5
#22 0x7ff6b01553fd in nsNodeUtils::ContentAppended(nsIContent*, nsIContent*, int) /src/dom/base/nsNodeUtils.cpp:167:3
#23 0x7ff6af310094 in nsHtml5TreeOperation::Append(nsIContent*, nsIContent*, nsHtml5DocumentBuilder*) /src/parser/html/nsHtml5TreeOperation.cpp:186:5
#24 0x7ff6af31115d in nsHtml5TreeOperation::AppendText(char16_t const*, unsigned int, nsIContent*, nsHtml5DocumentBuilder*) /src/parser/html/nsHtml5TreeOperation.cpp:169:10
#25 0x7ff6af30a7d5 in nsHtml5TreeBuilder::appendCharacters(void*, char16_t*, int, int) /src/parser/html/nsHtml5TreeBuilderCppSupplement.h:597:19
#26 0x7ff6af2da384 in nsHtml5TreeBuilder::flushCharacters() /src/parser/html/nsHtml5TreeBuilder.cpp:4581:5
#27 0x7ff6af2f9f6b in nsHtml5TreeBuilder::eof() /src/parser/html/nsHtml5TreeBuilder.cpp:510:3
#28 0x7ff6af2d7232 in nsHtml5Tokenizer::eof() /src/parser/html/nsHtml5Tokenizer.cpp:4444:17
#29 0x7ff6af2dde39 in nsHtml5StringParser::Tokenize(nsAString const&, nsIDocument*, bool) /src/parser/html/nsHtml5StringParser.cpp:122:17
#30 0x7ff6af2dd8d7 in nsHtml5StringParser::ParseFragment(nsAString const&, nsIContent*, nsIAtom*, int, bool, bool) /src/parser/html/nsHtml5StringParser.cpp:61:10
#31 0x7ff6afd38336 in nsContentUtils::ParseFragmentHTML(nsAString const&, nsIContent*, nsIAtom*, int, bool, bool) /src/dom/base/nsContentUtils.cpp:5156:26
#32 0x7ff6afec579f in mozilla::dom::FragmentOrElement::SetInnerHTMLInternal(nsAString const&, mozilla::ErrorResult&) /src/dom/base/FragmentOrElement.cpp:2521:14
#33 0x7ff6b1396478 in mozilla::dom::ElementBinding::set_innerHTML(JSContext*, JS::Handle<JSObject*>, mozilla::dom::Element*, JSJitSetterCallArgs) /src/obj-firefox/dom/bindings/ElementBinding.cpp:2917:9
#34 0x7ff6b1816afe in mozilla::dom::GenericBindingSetter(JSContext*, unsigned int, JS::Value*) /src/dom/bindings/BindingUtils.cpp:3011:8
#35 0x7ff6b67bba41 in js::CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&) /src/js/src/jscntxtinlines.h:293:15
#36 0x7ff6b67bb5ed in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /src/js/src/vm/Interpreter.cpp:494:16
#37 0x7ff6b67bc485 in InternalCall(JSContext*, js::AnyInvokeArgs const&) /src/js/src/vm/Interpreter.cpp:539:12
#38 0x7ff6b67bc69c in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) /src/js/src/vm/Interpreter.cpp:558:10
#39 0x7ff6b67bdb93 in js::CallSetter(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::Handle<JS::Value>) /src/js/src/vm/Interpreter.cpp:687:12
#40 0x7ff6b753d2f9 in SetExistingProperty(JSContext*, JS::Handle<js::NativeObject*>, JS::Handle<jsid>, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::Handle<js::NativeObject*>, JS::Handle<JS::PropertyResult>, JS::ObjectOpResult&) /src/js/src/vm/NativeObject.cpp:2749:10
#41 0x7ff6b753c828 in bool js::NativeSetProperty<(js::QualifiedBool)1>(JSContext*, JS::Handle<js::NativeObject*>, JS::Handle<jsid>, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::ObjectOpResult&) /src/js/src/vm/NativeObject.cpp:2785:20
#42 0x7ff6b674d2d0 in js::SetProperty(JSContext*, JS::Handle<JSObject*>, JS::Handle<jsid>, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::ObjectOpResult&) /src/js/src/vm/NativeObject.h:1555:12
#43 0x7ff6b67e129c in SetPropertyOperation(JSContext*, JSOp, JS::Handle<JS::Value>, JS::Handle<jsid>, JS::Handle<JS::Value>) /src/js/src/vm/Interpreter.cpp:268:12
#44 0x7ff6b67a1cf4 in Interpret(JSContext*, js::RunState&) /src/js/src/vm/Interpreter.cpp:2890:10
#45 0x7ff6b679cb41 in js::RunScript(JSContext*, js::RunState&) /src/js/src/vm/Interpreter.cpp:434:12
#46 0x7ff6b67bb570 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /src/js/src/vm/Interpreter.cpp:512:15
#47 0x7ff6b67bc485 in InternalCall(JSContext*, js::AnyInvokeArgs const&) /src/js/src/vm/Interpreter.cpp:539:12
#48 0x7ff6b67bc69c in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) /src/js/src/vm/Interpreter.cpp:558:10
#49 0x7ff6b7066e1b in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /src/js/src/jsapi.cpp:2937:12
#50 0x7ff6b1304fe9 in mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) /src/obj-firefox/dom/bindings/EventListenerBinding.cpp:47:8
#51 0x7ff6b1b33011 in void mozilla::dom::EventListener::HandleEvent<mozilla::dom::EventTarget*>(mozilla::dom::EventTarget* const&, mozilla::dom::Event&, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObject::ExceptionHandling, JSCompartment*) /src/obj-firefox/dist/include/mozilla/dom/EventListenerBinding.h:65:12
#52 0x7ff6b1b32b96 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /src/dom/events/EventListenerManager.cpp:1109:9
#53 0x7ff6b1b33ef5 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /src/dom/events/EventListenerManager.cpp:1283:20
#54 0x7ff6b1b1fceb in mozilla::EventTargetChainItem::HandleEvent(mozilla::EventChainPostVisitor&, mozilla::ELMCreationDetector&) /src/dom/events/EventDispatcher.cpp:313:17
#55 0x7ff6b1b1f3af in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /src/dom/events/EventDispatcher.cpp:462:16
#56 0x7ff6b1b20e8d in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) /src/dom/events/EventDispatcher.cpp:822:9
#57 0x7ff6b1b01e90 in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports*, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) /src/dom/events/EventDispatcher.cpp:888:12
#58 0x7ff6b010e06e in nsINode::DispatchEvent(nsIDOMEvent*, bool*) /src/dom/base/nsINode.cpp:1341:5
#59 0x7ff6afd32684 in nsContentUtils::DispatchEvent(nsIDocument*, nsISupports*, nsAString const&, bool, bool, bool, bool*, bool) /src/dom/base/nsContentUtils.cpp:4554:18
#60 0x7ff6afd3242b in nsContentUtils::DispatchTrustedEvent(nsIDocument*, nsISupports*, nsAString const&, bool, bool, bool*) /src/dom/base/nsContentUtils.cpp:4522:10
#61 0x7ff6b00565d3 in nsDocument::DispatchContentLoadedEvents() /src/dom/base/nsDocument.cpp:5534:3
#62 0x7ff6b00cfd95 in mozilla::detail::RunnableMethodImpl<nsDocument*, void (nsDocument::*)(), true, (mozilla::RunnableKind)0>::Run() /src/obj-firefox/dist/include/nsThreadUtils.h:1192:13
#63 0x7ff6adc2ad59 in mozilla::SchedulerGroup::Runnable::Run() /src/xpcom/threads/SchedulerGroup.cpp:396:25
#64 0x7ff6adc6013f in nsThread::ProcessNextEvent(bool, bool*) /src/xpcom/threads/nsThread.cpp:1039:14
#65 0x7ff6adc64fe0 in NS_ProcessNextEvent(nsIThread*, bool) /src/xpcom/threads/nsThreadUtils.cpp:521:10
#66 0x7ff6ae7d2a65 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /src/ipc/glue/MessagePump.cpp:97:21
#67 0x7ff6ae722267 in MessageLoop::RunInternal() /src/ipc/chromium/src/base/message_loop.cc:326:10
#68 0x7ff6ae7220f9 in MessageLoop::Run() /src/ipc/chromium/src/base/message_loop.cc:299:3
#69 0x7ff6b303405a in nsBaseAppShell::Run() /src/widget/nsBaseAppShell.cpp:158:27
#70 0x7ff6b63a2b86 in XRE_RunAppShell() /src/toolkit/xre/nsEmbedFunctions.cpp:866:22
#71 0x7ff6ae7d3665 in mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*) /src/ipc/glue/MessagePump.cpp:269:9
#72 0x7ff6ae722267 in MessageLoop::RunInternal() /src/ipc/chromium/src/base/message_loop.cc:326:10
#73 0x7ff6ae7220f9 in MessageLoop::Run() /src/ipc/chromium/src/base/message_loop.cc:299:3
#74 0x7ff6b63a23b7 in XRE_InitChildProcess(int, char**, XREChildData const*) /src/toolkit/xre/nsEmbedFunctions.cpp:691:34
#75 0x4ec0fe in content_process_main(mozilla::Bootstrap*, int, char**) /src/browser/app/../../ipc/contentproc/plugin-container.cpp:63:30
#76 0x4ec376 in main /src/browser/app/nsBrowserApp.cpp:285:18
#77 0x7ff6ccce282f in __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291
#78 0x41e1b4 in _start (firefox+0x41e1b4)
Flags: in-testsuite?
mystor was looking at this code recently, I think (as always, feel free to say 'no, go away' ;).
Flags: needinfo?(michael)
Flags: needinfo?(masayuki)
Hmm, the assertion detects unexpected nested mutation. While setting .innerHTML, <textarea> is created? Then, it causes setting text to the textarea, then, deleting default value of the <textarea>.

I wonder, when HasAddedNodesDuringDocumentChange() returns true in IMEContentObserver::BeginDocumentUpdate(), IMEContentObserver should flush pending changes?
Flags: needinfo?(masayuki)
I think masayuki's suggestion makes the most sense here - so here's a simple patch which makes that change.

It seems to me like the original code's assumption that document updates are not re-entrant was flawed.
Attachment #8907287 - Flags: review?(masayuki)
Comment on attachment 8907287 [details] [diff] [review]
Flush IME document changes when entering nested Document Update

Thanks!
Attachment #8907287 - Flags: review?(masayuki) → review+
Flags: needinfo?(michael)
Pushed by michael@thelayzells.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0d1afc4073ab
Flush IME document changes when entering nested Document Update, r=masayuki
https://hg.mozilla.org/mozilla-central/rev/0d1afc4073ab
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Can we land a crashtest for this?
Assignee: nobody → michael
Blocks: 1250823
Flags: needinfo?(michael)
I'm not sure how useful this will be as a crashtest, as this problem was just an incorrect assertion, but there's no good reason not to add it.
Attachment #8909407 - Flags: review?(masayuki)
Comment on attachment 8909407 [details] [diff] [review]
Add a crashtest for change

The important thing is not no-crash. Instead, please test text change notification(s) occurred as expected. Can you do that in runIMEContentObserverTest() of widget/tests/window_composition_text_querycontent.xul? If DOMContentLoaded event is required, you need to create an <iframe> element, though.
Attachment #8909407 - Flags: review?(masayuki) → review-
Flags: needinfo?(nika)
You need to log in before you can comment on or make changes to this bug.