Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28507

Loop at CppEditor::SemanticHighlighter::onHighlighterResultAvailable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • None
    • Qt Creator 9.0.0
    • C/C++/Obj-C++ Support
    • None
    • Linux/Wayland
    • b6bd59fc5 (master)

    Description

      I use multi line editor function by shortcut "Alt+Shift", qtcreator started becoming unresponsive after I deleted two character. The CPU usage of qtcreator process is 98%, The following is gdb call stack:

      gdb

      Thread 1 "qtcreator" received signal SIGINT, Interrupt.
      0x00007f72c8490eb5 in ?? () from /usr/lib/qtcreator/plugins/libCppEditor.so
      (gdb) bt
      #0 0x00007f72c8490eb5 in () at /usr/lib/qtcreator/plugins/libCppEditor.so
      #1 0x00007f72c8472f30 in CppEditor::SemanticHighlighter::onHighlighterResultAvailable(int, int) () at /usr/lib/qtcreator/plugins/libCppEditor.so
      #2 0x00007f72fa9802e3 in () at /usr/lib/libQt6Core.so.6
      #3 0x00007f72faa8e9fd in QFutureWatcherBase::resultsReadyAt(int, int) () at /usr/lib/libQt6Core.so.6
      #4 0x00007f72faa8ec4e in QFutureWatcherBase::event(QEvent*) () at /usr/lib/libQt6Core.so.6
      #5 0x00007f72fb975adc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt6Widgets.so.6
      #6 0x00007f72fa92a118 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt6Core.so.6
      #7 0x00007f72fa92a2eb in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt6Core.so.6
      #8 0x00007f72fab4f528 in () at /usr/lib/libQt6Core.so.6
      #9 0x00007f72f971687b in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
      #10 0x00007f72f976d279 in () at /usr/lib/libglib-2.0.so.0
      #11 0x00007f72f9715132 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
      #12 0x00007f72fab4d562 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt6Core.so.6
      #13 0x00007f72fa9354c4 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt6Core.so.6
      #14 0x00007f72fa92cd3b in QCoreApplication::exec() () at /usr/lib/libQt6Core.so.6
      #15 0x000055a801453d9b in ()
      #16 0x00007f72fa23c290 in () at /usr/lib/libc.so.6
      #17 0x00007f72fa23c34a in __libc_start_main () at /usr/lib/libc.so.6
      #18 0x000055a801454ca5 in ()

      According to my analysis, I think the following code is stuck in an infinite loop:

      for (QTextBlock block = firstBlockForResult; block != endBlock; block = block.next()) {
                      Parentheses syntacticParens = getClearedParentheses(block);
      
                      // Remove mis-detected parentheses inserted by syntactic highlighter.
                      // This typically happens with raw string literals.
                      if (result.textStyles.mainStyle != C_PUNCTUATION) {
                          for (auto it = syntacticParens.begin(); it != syntacticParens.end();) {
                              const int absParenPos = block.position() + it->pos;
                              if (absParenPos >= startRange && absParenPos < endRange)
                                  it = syntacticParens.erase(it);
                              else
                                  ++it;
                          }
                      }
                      TextDocumentLayout::setParentheses(block, syntacticParens);
      }
      

      The following code is the operator target of multi line edit:
      The "|" symbol is I begin edit position, but I can't recurrence the bug.

                      struct wl_signal |motion;
      		struct wl_signal |motion_absolute;
      		struct wl_signal |button;
      		struct wl_signal |axis;
      		struct wl_signal |frame;
      		struct wl_signal |swipe_begin;
      		struct wl_signal |swipe_update;
      		struct wl_signal |swipe_end;
      		struct wl_signal |pinch_begin;
      		struct wl_signal |pinch_update;
      		struct wl_signal |pinch_end;
      		struct wl_signal |hold_begin;
      		struct wl_signal |hold_end;
      
      		struct wl_signal |touch_up;
      		struct wl_signal |touch_down;
      		struct wl_signal |touch_motion;
      		struct wl_signal |touch_cancel;
      		struct wl_signal |touch_frame;
      
      		struct wl_signal |tablet_tool_axis;
      		struct wl_signal |tablet_tool_proximity;
      		struct wl_signal |tablet_tool_tip;
      		struct wl_signal |tablet_tool_button;
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTCREATORBUG-28507
          # Subject Branch Project Status CR V

          Activity

            People

              kandeler Christian Kandeler
              zccrs JiDe Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes