Templar icon indicating copy to clipboard operation
Templar copied to clipboard

segfault on fibonacci trace from metashell

Open cppljevans opened this issue 7 years ago • 0 comments

Using the feature/templight2 Templar executable on trace file produced by metashell's template_metashell causes a segfault:

evansl@lje-OptiPlex-9020:~/prog_dev/metashell$ make templight
templight_metashell -Xtemplight -profiler -Xtemplight -ignore-system -c -std=c++11 fib.cpp
evansl@lje-OptiPlex-9020:~/prog_dev/metashell$ pushd
~/dwnlds/templar/Templar ~/prog_dev/metashell
evansl@lje-OptiPlex-9020:~/dwnlds/templar/Templar$ ./Templar
QObject::connect: No such slot QTableView::sortByColumn(int,)
QObject::connect: No such slot QGraph::follow()
TraceReader::build( "/home/evansl/prog_dev/metashell/fib.o.trace.pbf" )
Segmentation fault (core dumped)
evansl@lje-OptiPlex-9020:~/dwnlds/templar/Templar$ git branch
* feature/templight2
  feature/templight2_mp_fork
  master
evansl@lje-OptiPlex-9020:~/dwnlds/templar/Templar$ 

After debug build, examined the core dump with gdb. The 1st several lines in bt were:

evansl@lje-OptiPlex-9020:~/dwnlds/templar/build$ gdb Templar core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from Templar...done.
[New LWP 11459]
[New LWP 11468]
[New LWP 11461]
[New LWP 11462]
[New LWP 11467]
[New LWP 11471]
[New LWP 11460]
[New LWP 11464]
[New LWP 11469]
[New LWP 11470]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./Templar'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000046b7ea in QString::~QString (this=0xffffffffffffff88, __in_chrg=<optimized out>)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1053
1053	inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); }
[Current thread is 1 (Thread 0x7fca3c4a2740 (LWP 11459))]
(gdb) bt
#0  0x000000000046b7ea in QString::~QString (this=0xffffffffffffff88, __in_chrg=<optimized out>)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1053
#1  0x000000000049c21e in std::pair<QString, QColor>::~pair (this=0xffffffffffffff88, __in_chrg=<optimized out>)
    at /usr/include/c++/5/bits/stl_pair.h:96
#2  0x000000000049c4b1 in std::_Destroy<std::pair<QString, QColor> > (__pointer=0xffffffffffffff88)
    at /usr/include/c++/5/bits/stl_construct.h:93
#3  0x000000000049c3a1 in std::_Destroy_aux<false>::__destroy<std::pair<QString, QColor>*> (
    __first=0xffffffffffffff88, __last=0x0) at /usr/include/c++/5/bits/stl_construct.h:103
#4  0x000000000049c1d6 in std::_Destroy<std::pair<QString, QColor>*> (__first=0xffffffffffffff88, __last=0x0)
    at /usr/include/c++/5/bits/stl_construct.h:126
#5  0x000000000049bdb9 in std::_Destroy<std::pair<QString, QColor>*, std::pair<QString, QColor> > (
    __first=0xffffffffffffff88, __last=0x0) at /usr/include/c++/5/bits/stl_construct.h:151
#6  0x000000000049befc in std::vector<std::pair<QString, QColor>, std::allocator<std::pair<QString, QColor> > >::_M_erase_at_end (this=0x20a55a8, __pos=0xffffffffffffff88) at /usr/include/c++/5/bits/stl_vector.h:1438
#7  0x000000000049c105 in std::vector<std::pair<QString, QColor>, std::allocator<std::pair<QString, QColor> > >::_M_erase (this=0x20a55a8, __first=<error reading variable: Cannot access memory at address 0xffffffffffffff88>, 
    __last=<error reading variable: Cannot access memory at address 0x0>)
    at /usr/include/c++/5/bits/vector.tcc:160
#8  0x000000000049bcce in std::vector<std::pair<QString, QColor>, std::allocator<std::pair<QString, QColor> > >::erase (this=0x20a55a8, __first=<error reading variable: Cannot access memory at address 0xffffffffffffff88>, 
    __last=<error reading variable: Cannot access memory at address 0x0>)
    at /usr/include/c++/5/bits/stl_vector.h:1177
#9  0x000000000049b5f1 in Templar::EditorHandler::rewind (this=0x20a5590, count=6)
    at /home/evansl/dwnlds/templar/Templar/templateeventhandlers/editorhandler.cpp:73
#10 0x000000000047ad4a in Templar::DebugManager::rewind (this=0x208abc0)
    at /home/evansl/dwnlds/templar/Templar/gui/debugmanager.cpp:172
#11 0x00000000004a688e in Templar::DebugManager::qt_static_metacall (_o=0x208abc0, 
    _c=QMetaObject::InvokeMetaMethod, _id=3, _a=0x7ffdd03a0eb0)
    at /home/evansl/dwnlds/templar/build/moc_debugmanager.cpp:88
#12 0x00007fca3adb4d2a in QMetaObject::activate(QObject*, int, int, void**) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#13 0x00007fca3bd9b412 in QAction::triggered(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007fca3bd9d898 in QAction::activate(QAction::ActionEvent) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007fca3bea35a0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
---Type <return> to continue, or q <return> to quit---

The dump occurred when I pressed the rewind button (the one with the icon that resembles 2 left arrows).

When editorhandler.cpp was changed as follows:

 void EditorHandler::rewind(unsigned int count)
 {
-    undoList.erase(undoList.end() - count + 1, undoList.end());
+    std::size_t list_size=undoList.size();
+    std::size_t undo=(list_size<count)?list_size:count;
+    undoList.erase(undoList.end() - undo, undoList.end());
     undoEvent();
 }

The program ran without a segfault; however, the [rewind] and [fast forward] buttons made no change in the graphic in the top righthand corner of the Templar window.

HTH.

-regards, Larry

cppljevans avatar Aug 18 '17 17:08 cppljevans