kdevelop/formatters/astyle/lib/ASBeautifier.cpp: 843│ // and then remove it from the active beautifier stack and delete it. 844│ if (!backslashEndsPrevLine && isInDefineDefinition && !isInDefine) 845│ { 846│ string beautifiedLine; 847│ ASBeautifier* defineBeautifier; 848│ 849│ isInDefineDefinition = false; 850│ defineBeautifier = activeBeautifierStack->back(); 851│ activeBeautifierStack->pop_back(); 852│ 853├> beautifiedLine = defineBeautifier->beautify(line); 854│ delete defineBeautifier; 855│ return beautifiedLine; 856│ } 857│ 858│ // unless this is a multi-line #define, return this precompiler line as is. 859│ if (!isInDefine && !isInDefineDefinition) 860│ return originalLine; 861│ } 862│ 863│ // if there exists any worker beautifier in the activeBeautifierStack, ------- (gdb) print defineBeautifier $1 = (astyle::ASBeautifier *) 0x21 (gdb) print activeBeautifierStack->size() $2 = 17592176799899 (gdb) stacktrace: #0 astyle::ASBeautifier::beautify (this=0x2973e60, originalLine=...) at /home/marcin/projects/c++-local/kdevelop/formatters/astyle/lib/ASBeautifier.cpp:853 #1 0x00007fffbf7a4a7c in astyle::ASFormatter::nextLine (this=0x2973e60) at /home/marcin/projects/c++-local/kdevelop/formatters/astyle/lib/ASFormatter.cpp:1304 #2 0x00007fffbf78bf1b in AStyleFormatter::formatSource (this=0x2973e60, text=..., leftContext=..., rightContext=...) at /home/marcin/projects/c++-local/kdevelop/formatters/astyle/astyle_forma tter.cpp:54 #3 0x00007fffbf783792 in AStylePlugin::formatSourceWithStyle (this=this@entry=0x2973d00, s=..., text=..., mime=..., leftContext=..., rightContext=...) at /home/marcin/projects/c++-local/kdeve lop/formatters/astyle/astyle_plugin.cpp:96 #4 0x00007fffbf783292 in AStylePlugin::formatSource (this=0x2973d00, text=..., url=..., mime=..., leftContext=..., rightContext=...) at /home/marcin/projects/c++-local/kdevelop/formatters/ast yle/astyle_plugin.cpp:101 #5 0x00007ffff745c561 in KDevelop::SourceFormatterController::formatDocument (this=this@entry=0xdd6870, doc=doc@entry=0x3578ab0, formatter=formatter@entry=0x2973d28, mime=...) at /home/marcin /projects/c++-local/kdevplatform/shell/sourceformattercontroller.cpp:369 #6 0x00007ffff745dc13 in KDevelop::SourceFormatterController::beautifySource (this=0xdd6870) at /home/marcin/projects/c++-local/kdevplatform/shell/sourceformattercontroller.cpp:324 #7 0x00007ffff5dad0ef in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #8 0x00007ffff5138152 in QAction::triggered(bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #9 0x00007ffff5139580 in QAction::activate(QAction::ActionEvent) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #10 0x00007ffff51396e7 in QAction::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #11 0x00007ffff62458a7 in KAction::event(QEvent*) () from /usr/lib/libkdeui.so.5 #12 0x00007ffff513e8ec in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #13 0x00007ffff514125b in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #14 0x00007ffff63211a6 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5 #15 0x00007ffff5d9863e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #16 0x00007ffff5171754 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #17 0x00007ffff5171bb3 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #18 0x00007ffff5142dd0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #19 0x00007ffff63211a6 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5 #20 0x00007ffff5d9863e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #21 0x00007ffff51e1649 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #22 0x00007ffff51e1a81 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #23 0x00007ffff51b8859 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #24 0x00007ffff51e40b2 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #25 0x00007fffeece1f05 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #26 0x00007fffeece2248 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #27 0x00007fffeece2304 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #28 0x00007ffff5dc7036 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #29 0x00007ffff51e41ae in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #30 0x00007ffff5d9738f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #31 0x00007ffff5d97618 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #32 0x00007ffff5d9ccf6 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #33 0x000000000040e556 in main (argc=<optimised out>, argv=<optimised out>) at /home/marcin/projects/c++-local/kdevelop/app/main.cpp:499 Reproducible: Always Steps to Reproduce: 1. Paste this wrong macro: ---content-- #if 1 # define macro(param) \ #endif --/content-- 2. Save the .cpp file. 3. Make reformat source function. I wanted to clone whole line and move second one below by ctrl+shift+down_arrow, but reformat sources makes crash too. Compiles from sources, from master branch, HEAD on 97f1c7ada837765e11c7363e22273cfc8d38f9d1.
Mind providing a patch, Marcin?
Can i pick this ticket ?
Sure. You can post the patch on reviewboard: http://techbase.kde.org/Development/Review_Board
Any updates, adu?
Followed the steps to reproduce with current master and wasn't able to trigger the described crash. Also tried a couple of file types (C, C++) with different formatters. Either some prerequisite to trigger the crash wasn't mentioned in the steps to reproduce, or the crash got fixed by some other changes made since ticket creation (almost four years ago).
Thanks for the feedback. I can't reproduce either. This issue could've been fixed by this commit: * ffc9dc9cf9 - astyle: Update libastyle copy to 2.04 (2 years, 8 months ago) <Kevin Funk>