Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when adding data to plot loaded from ROS bag #550

Closed
henrikkunzelmann opened this issue Oct 29, 2021 · 7 comments
Closed

Crash when adding data to plot loaded from ROS bag #550

henrikkunzelmann opened this issue Oct 29, 2021 · 7 comments
Assignees
Labels

Comments

@henrikkunzelmann
Copy link

On my system PlotJuggler sometimes crashes when simply adding data to plots. I have multiple plots of which some are X/Y plots. Everything works fine, but after some time when I add new data or load another ROS bag, then PlotJuggler simply crashes. See the attached stack trace.

My system:

  • Ubuntu 21.10 (5.10.60.1-microsoft-standard-WSL2)
  • ROS noetic compiled from source
  • libQt5 is version 5.15.2+dfsg-12
#31   Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f2cc4fe68ba, in g_main_context_dispatch
#30   Object "/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5", at 0x7f2cc2168b9d, in QXcbNativeInterface::dumpNativeWindows(unsigned long long) const
#29   Object "/lib/x86_64-linux-gnu/libQt5Gui.so.5", at 0x7f2cc65149bb, in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
#28   Object "/lib/x86_64-linux-gnu/libQt5Gui.so.5", at 0x7f2cc653f256, in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)
#27   Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc615a169, in QCoreApplication::notifyInternal2(QObject*, QEvent*)
#26   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6c466ef, in QApplicationPrivate::notify_helper(QObject*, QEvent*)
#25   Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc6159d8d, in QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject*, QEvent*)
#24   Object "/lib/x86_64-linux-gnu/libQt5Gui.so.5", at 0x7f2cc657fc1a, in QBasicDrag::eventFilter(QObject*, QEvent*)
#23   Object "/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5", at 0x7f2cc217e31d, in QXcbConnection::xi2HandleEvent(xcb_ge_event_t*)
#22   Object "/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5", at 0x7f2cc217a43b, in QXcbConnection::xi2HandleEvent(xcb_ge_event_t*)
#21   Object "/lib/x86_64-linux-gnu/libQt5Gui.so.5", at 0x7f2cc651422b, in QWindowSystemInterface::handleDrop(QWindow*, QMimeData const*, QPoint const&, QFlags<Qt::DropAction>, QFlags<Qt::MouseButton>, QFlags<Qt::KeyboardModifier>)
#20   Object "/lib/x86_64-linux-gnu/libQt5Gui.so.5", at 0x7f2cc6541162, in QGuiApplicationPrivate::processDrop(QWindow*, QMimeData const*, QPoint const&, QFlags<Qt::DropAction>, QFlags<Qt::MouseButton>, QFlags<Qt::KeyboardModifier>)
#19   Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc615a169, in QCoreApplication::notifyInternal2(QObject*, QEvent*)
#18   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6c466b2, in QApplicationPrivate::notify_helper(QObject*, QEvent*)
#17   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6ca5e7f, in QDesktopWidget::qt_metacall(QMetaObject::Call, int, void**)
#16   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6ca5071, in QDesktopWidget::qt_metacall(QMetaObject::Call, int, void**)
#15   Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc615a169, in QCoreApplication::notifyInternal2(QObject*, QEvent*)
#14   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6c4f5ff, in QApplication::notify(QObject*, QEvent*)
#13   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6c466b2, in QApplicationPrivate::notify_helper(QObject*, QEvent*)
#12   Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/3rdparty/qwt/src/qwt_plot.cpp", line 239, in QwtPlot::event(QEvent*) [0x55a4a70f766b]
        236:  */
        237: bool QwtPlot::event( QEvent* event )
        238: {
      > 239:     bool ok = QFrame::event( event );
        240:     switch ( event->type() )
        241:     {
        242:         case QEvent::LayoutRequest:
#11   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6d36b51, in QFrame::event(QEvent*)
#10   Object "/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7f2cc6c8917d, in QWidget::event(QEvent*)
#9  | Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/plotjuggler_base/src/plotwidget_base.cpp", line 145, in PJ::PlotWidgetBase::QwtPlotPimpl::dropEvent(QDropEvent*)
    |   143:   void dropEvent(QDropEvent* event) override
    |   144:   {
    | > 145:     event_callback(event);
    |   146:   }
    |   147: };
      Source "/usr/include/c++/11/bits/std_function.h", line 560, in std::function<void (QEvent*)>::operator()(QEvent*) const [0x7f2cc7408fbc]
        557:       {
        558:    if (_M_empty())
        559:      __throw_bad_function_call();
      > 560:    return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...);
        561:       }
        562:
        563: #if __cpp_rtti
#8    Source "/home/henrik/ws_plotjuggler/build/plotjuggler/plotjuggler_base/include/PlotJuggler/moc_plotwidget_base.cpp", line 215, in PJ::PlotWidgetBase::dropSignal(QDropEvent*) [0x7f2cc73f6c63]
        212: void PJ::PlotWidgetBase::dropSignal(QDropEvent * _t1)
        213: {
        214:     void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
      > 215:     QMetaObject::activate(this, &staticMetaObject, 3, _a);
        216: }
        217:
        218: // SIGNAL 4
#7    Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc6191a52, in QObject::setProperty(char const*, QVariant const&)
#6    Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/plotjuggler_app/plotwidget.cpp", line 507, in PlotWidget::onDropEvent(QDropEvent*) [0x55a4a70185e0]
        504:   if (curves_changed)
        505:   {
        506:     emit curvesDropped();
      > 507:     emit curveListChanged();
        508:     zoomOut(true);
        509:   }
        510:   _dragging.mode = DragInfo::NONE;
#5    Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc6191a52, in QObject::setProperty(char const*, QVariant const&)
#4  | Source "/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h", line 443, in impl
    |   441:                 break;
    |   442:             case Call:
    | > 443:                 FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
    |   444:                 break;
    |   445:             case Compare: // not implemented
    | Source "/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h", line 256, in call<QtPrivate::List<>, void>
    |   254:         template <typename SignalArgs, typename R>
    |   255:         static void call(Function &f, void *, void **arg) {
    | > 256:             FunctorCall<typename Indexes<N>::Value, SignalArgs, R, Function>::call(f, arg);
    |   257:         }
    |   258:     };
    | Source "/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h", line 146, in call
    |   144:     struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, Function> {
    |   145:         static void call(Function &f, void **arg) {
    | > 146:             f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]);
    |   147:         }
    |   148:     };
      Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/plotjuggler_app/mainwindow.cpp", line 893, in QtPrivate::QFunctorSlotObject<MainWindow::onPlotAdded(PlotWidget*)::{lambda()#1}, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) [0x55a4a6fd3e42]
        890:   connect(this, &MainWindow::dataSourceRemoved, plot, &PlotWidget::onSourceDataRemoved);
        891:
        892:   connect(plot, &PlotWidget::curveListChanged, this, [this]() {
      > 893:     updateTimeOffset();
        894:     updateTimeSlider();
        895:   });
#3  | Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/plotjuggler_app/mainwindow.cpp", line 2183, in MainWindow::updateTimeOffset()
    |  2181:   else
    |  2182:   {
    | >2183:     _time_offset.set(0.0);
    |  2184:   }
    |  2185: }
      Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/plotjuggler_app/utils.h", line 23, in MonitoredValue::set(double) [0x55a4a6fd3e11]
         20:     _value = newValue;
         21:     if (fabs(newValue - prev) > std::numeric_limits<double>::epsilon())
         22:     {
      >  23:       emit valueChanged(_value);
         24:     }
         25:   }
#2    Source "/home/henrik/ws_plotjuggler/build/plotjuggler/plotjuggler_app/plotjuggler_autogen/EWIEGA46WW/moc_utils.cpp", line 131, in MonitoredValue::valueChanged(double) [0x55a4a6fb04e1]
        128: void MonitoredValue::valueChanged(double _t1)
        129: {
        130:     void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
      > 131:     QMetaObject::activate(this, &staticMetaObject, 0, _a);
        132: }
        133: QT_WARNING_POP
        134: QT_END_MOC_NAMESPACE
#1    Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f2cc6191a87, in QObject::setProperty(char const*, QVariant const&)
#0  | Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/plotjuggler_app/plotwidget.cpp", line 909, in PlotWidget::on_changeTimeOffset(double)
    |   907:     for (auto& it : curveList())
    |   908:     {
    | > 909:       auto series = dynamic_cast<QwtSeriesWrapper*>(it.curve->data());
    |   910:       series->setTimeOffset(_time_offset);
    |   911:     }
      Source "/home/henrik/ws_plotjuggler/src/PlotJuggler/./3rdparty/qwt/src/qwt_series_store.h", line 148, in QwtSeriesStore<QPointF>::data() [0x55a4a7010ef0]
        145: template< typename T >
        146: inline QwtSeriesData< T >* QwtSeriesStore< T >::data()
        147: {
      > 148:     return m_series;
        149: }
        150:
        151: template< typename T >
Segmentation fault (Address not mapped to object [0x30])
@facontidavide
Copy link
Owner

if you give me a way to reproduce consistently this, I would be infinitely grateful

@facontidavide facontidavide self-assigned this Oct 29, 2021
@facontidavide
Copy link
Owner

facontidavide commented Oct 30, 2021

I think this might fix your issue.

2ca9a91 (latest main branch)

Can you please confirm?

@facontidavide
Copy link
Owner

closing for insactivity. Feel free to open it again if problem persist in main branch

@henrikkunzelmann
Copy link
Author

henrikkunzelmann commented Dec 14, 2021

Had some time to debug that issue. I could find an easy pattern to reproduce the crash (latest main branch):

  • Split plot vertically (over context menu)
  • Add some XY plot data by creating a new XY curve (right click drag)
  • Close the plot by clicking on the X
  • Split plot vertically again
  • Add single variable to newly created plot

I also got more debug output:

==5956==ERROR: AddressSanitizer: heap-use-after-free on address 0x6110006c7ec0 at pc 0x558cdb8b7049 bp 0x7ffe99cb5900 sp 0x7ffe99cb58f0
READ of size 8 at 0x6110006c7ec0 thread T0
    #0 0x558cdb8b7048 in std::__cxx11::list<PJ::PlotWidgetBase::CurveInfo, std::allocator<PJ::PlotWidgetBase::CurveInfo> >::begin() /usr/include/c++/11/bits/stl_list.h:946
    #1 0x558cdb8aabba in PlotWidget::on_changeTimeOffset(double) /mnt/f/ROS/PlotJuggler/plotjuggler_app/plotwidget.cpp:907
    #2 0x558cdb6e555a in PlotWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/plotjuggler_app/plotjuggler_autogen/EWIEGA46WW/moc_plotwidget.cpp:237
    #3 0x7fcab8c38a87  (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2f0a87)
    #4 0x558cdb6ebabc in MonitoredValue::valueChanged(double) /mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/plotjuggler_app/plotjuggler_autogen/EWIEGA46WW/moc_utils.cpp:131
    #5 0x558cdb7da09f in MonitoredValue::set(double) /mnt/f/ROS/PlotJuggler/plotjuggler_app/utils.h:23
    #6 0x558cdb7a43fe in MainWindow::updateTimeOffset() /mnt/f/ROS/PlotJuggler/plotjuggler_app/mainwindow.cpp:2218
    #7 0x558cdb78364f in operator() /mnt/f/ROS/PlotJuggler/plotjuggler_app/mainwindow.cpp:890
    #8 0x558cdb7d0b4a in call /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:146
    #9 0x558cdb7cc1be in call<QtPrivate::List<>, void> /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:256
    #10 0x558cdb7c830d in impl /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:443
    #11 0x7fcab8c38a52  (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2f0a52)
    #12 0x558cdb6e7076 in PlotWidget::curveListChanged() /mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/plotjuggler_app/plotjuggler_autogen/EWIEGA46WW/moc_plotwidget.cpp:399
    #13 0x558cdb8a1744 in PlotWidget::onDropEvent(QDropEvent*) /mnt/f/ROS/PlotJuggler/plotjuggler_app/plotwidget.cpp:507
    #14 0x558cdb8bab57 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<QDropEvent*>, void, void (PlotWidget::*)(QDropEvent*)>::call(void (PlotWidget::*)(QDropEvent*), PlotWidget*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152
    #15 0x558cdb8b9fe1 in void QtPrivate::FunctionPointer<void (PlotWidget::*)(QDropEvent*)>::call<QtPrivate::List<QDropEvent*>, void>(void (PlotWidget::*)(QDropEvent*), PlotWidget*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185
    #16 0x558cdb8b93bb in QtPrivate::QSlotObject<void (PlotWidget::*)(QDropEvent*), QtPrivate::List<QDropEvent*>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418
    #17 0x7fcab8c38a52  (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2f0a52)
    #18 0x7fcaba5cca8c in PJ::PlotWidgetBase::dropSignal(QDropEvent*) /mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/plotjuggler_base/include/PlotJuggler/moc_plotwidget_base.cpp:215
    #19 0x7fcaba6182c5 in operator() /mnt/f/ROS/PlotJuggler/plotjuggler_base/src/plotwidget_base.cpp:313
    #20 0x7fcaba61fffd in __invoke_impl<void, PJ::PlotWidgetBase::PlotWidgetBase(QWidget*)::<lambda(QEvent*)>&, QEvent*> /usr/include/c++/11/bits/invoke.h:61
    #21 0x7fcaba61fa44 in __invoke_r<void, PJ::PlotWidgetBase::PlotWidgetBase(QWidget*)::<lambda(QEvent*)>&, QEvent*> /usr/include/c++/11/bits/invoke.h:111
    #22 0x7fcaba61f37c in _M_invoke /usr/include/c++/11/bits/std_function.h:291
    #23 0x7fcaba627534 in std::function<void (QEvent*)>::operator()(QEvent*) const (/mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/devel/lib/libplotjuggler_base.so+0x12f534)
    #24 0x7fcaba62585b in PJ::PlotWidgetBase::QwtPlotPimpl::dropEvent(QDropEvent*) (/mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/devel/lib/libplotjuggler_base.so+0x12d85b)
    #25 0x7fcab973017d in QWidget::event(QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1af17d)
    #26 0x7fcab97ddb51 in QFrame::event(QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x25cb51)
    #27 0x558cdbb913a0 in QwtPlot::event(QEvent*) /mnt/f/ROS/PlotJuggler/3rdparty/qwt/src/qwt_plot.cpp:239
    #28 0x7fcab96ed6b2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x16c6b2)
    #29 0x7fcab96f65ff in QApplication::notify(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1755ff)
    #30 0x7fcab8c01169 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b9169)
    #31 0x7fcab974c071  (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1cb071)
    #32 0x7fcab974ce7f  (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1cbe7f)
    #33 0x7fcab96ed6b2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x16c6b2)
    #34 0x7fcab8c01169 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b9169)
    #35 0x7fcab8fe8162 in QGuiApplicationPrivate::processDrop(QWindow*, QMimeData const*, QPoint const&, QFlags<Qt::DropAction>, QFlags<Qt::MouseButton>, QFlags<Qt::KeyboardModifier>) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x143162)
    #36 0x7fcab8fbb22b in QWindowSystemInterface::handleDrop(QWindow*, QMimeData const*, QPoint const&, QFlags<Qt::DropAction>, QFlags<Qt::MouseButton>, QFlags<Qt::KeyboardModifier>) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x11622b)
    #37 0x7fcab14ae43b  (/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5+0x8543b)
    #38 0x7fcab14b231d  (/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5+0x8931d)
    #39 0x7fcab9026c1a in QBasicDrag::eventFilter(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x181c1a)
    #40 0x7fcab8c00d8d in QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b8d8d)
    #41 0x7fcab96ed6ef in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x16c6ef)
    #42 0x7fcab8c01169 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b9169)
    #43 0x7fcab8fe6256 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x141256)
    #44 0x7fcab8fbb9bb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x1169bb)
    #45 0x7fcab149cb9d  (/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5+0x73b9d)
    #46 0x7fcab7a5b8ba in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x558ba)
    #47 0x7fcab7aaef07  (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0xa8f07)
    #48 0x7fcab7a59002 in g_main_context_iteration (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x53002)
    #49 0x7fcab8c5a547 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x312547)
    #50 0x7fcab8bffa9a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b7a9a)
    #51 0x7fcab9025f06 in QBasicDrag::drag(QDrag*) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x180f06)
    #52 0x7fcab9023338 in QDragManager::drag(QDrag*) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x17e338)
    #53 0x7fcab902368e in QDrag::exec(QFlags<Qt::DropAction>, Qt::DropAction) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x17e68e)
    #54 0x558cdb7380d1 in CurvesView::eventFilterBase(QObject*, QEvent*) /mnt/f/ROS/PlotJuggler/plotjuggler_app/curvelist_view.cpp:306
    #55 0x558cdb74551a in CurveTreeView::eventFilter(QObject*, QEvent*) /mnt/f/ROS/PlotJuggler/plotjuggler_app/curvetree_view.cpp:287
    #56 0x7fcab8c00ec9 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b8ec9)
    #57 0x7fcab96ed6a1 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x16c6a1)
    #58 0x7fcab96f52e3 in QApplication::notify(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1742e3)
    #59 0x7fcab8c01169 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b9169)
    #60 0x7fcab96f3dc6 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x172dc6)
    #61 0x7fcab97499af  (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1c89af)
    #62 0x7fcab974cc44  (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1cbc44)
    #63 0x7fcab96ed6b2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x16c6b2)
    #64 0x7fcab8c01169 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b9169)
    #65 0x7fcab8fe6256 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x141256)
    #66 0x7fcab8fbb9bb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt5Gui.so.5+0x1169bb)
    #67 0x7fcab149cb9d  (/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5+0x73b9d)
    #68 0x7fcab7a5b8ba in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x558ba)
    #69 0x7fcab7aaef07  (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0xa8f07)
    #70 0x7fcab7a59002 in g_main_context_iteration (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x53002)
    #71 0x7fcab8c5a547 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x312547)
    #72 0x7fcab8bffa9a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b7a9a)
    #73 0x7fcab8c08023 in QCoreApplication::exec() (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2c0023)
    #74 0x558cdb7589e2 in main /mnt/f/ROS/PlotJuggler/plotjuggler_app/main.cpp:365
    #75 0x7fcab8434fcf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #76 0x7fcab843507c in __libc_start_main_impl ../csu/libc-start.c:409
    #77 0x558cdb6de594 in _start (/mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/devel/lib/plotjuggler/plotjuggler+0x2e5594)

0x6110006c7ec0 is located 192 bytes inside of 224-byte region [0x6110006c7e00,0x6110006c7ee0)
freed by thread T0 here:
    #0 0x7fcabaa3e22f in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:172
    #1 0x7fcaba624e80 in PJ::PlotWidgetBase::QwtPlotPimpl::~QwtPlotPimpl() (/mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/devel/lib/libplotjuggler_base.so+0x12ce80)
    #2 0x7fcab8c2bd9d in QObjectPrivate::deleteChildren() (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2e3d9d)

previously allocated by thread T0 here:
    #0 0x7fcabaa3d1c7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7fcaba61898e in PJ::PlotWidgetBase::PlotWidgetBase(QWidget*) /mnt/f/ROS/PlotJuggler/plotjuggler_base/src/plotwidget_base.cpp:342
    #2 0x558cdb897f5d in PlotWidget::PlotWidget(PJ::PlotDataMapRef&, QWidget*) /mnt/f/ROS/PlotJuggler/plotjuggler_app/plotwidget.cpp:74
    #3 0x558cdb8e1700 in DockWidget::DockWidget(PJ::PlotDataMapRef&, QWidget*) /mnt/f/ROS/PlotJuggler/plotjuggler_app/plot_docker.cpp:278
    #4 0x558cdb8e2759 in DockWidget::splitVertical() /mnt/f/ROS/PlotJuggler/plotjuggler_app/plot_docker.cpp:350
    #5 0x558cdb8eee9c in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, DockWidget* (DockWidget::*)()>::call(DockWidget* (DockWidget::*)(), DockWidget*, void**) (/mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/devel/lib/plotjuggler/plotjuggler+0x4f5e9c)
    #6 0x558cdb8ee6e6 in void QtPrivate::FunctionPointer<DockWidget* (DockWidget::*)()>::call<QtPrivate::List<>, void>(DockWidget* (DockWidget::*)(), DockWidget*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185
    #7 0x558cdb8ed687 in QtPrivate::QSlotObject<DockWidget* (DockWidget::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (/mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/devel/lib/plotjuggler/plotjuggler+0x4f4687)
    #8 0x7fcab8c38a52  (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2f0a52)
    #9 0x558cdb6e7106 in PlotWidget::splitVertical() /mnt/f/ROS/PlotJuggler/cmake-build-debug-wsl/plotjuggler_app/plotjuggler_autogen/EWIEGA46WW/moc_plotwidget.cpp:417
    #10 0x558cdb8bae03 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (PlotWidget::*)()>::call(void (PlotWidget::*)(), PlotWidget*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152
    #11 0x558cdb8ba02a in void QtPrivate::FunctionPointer<void (PlotWidget::*)()>::call<QtPrivate::List<>, void>(void (PlotWidget::*)(), PlotWidget*, void**) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185
    #12 0x558cdb8b95a7 in QtPrivate::QSlotObject<void (PlotWidget::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418
    #13 0x7fcab8c38a52  (/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2f0a52)
    #14 0x7fcab96e6b85 in QAction::triggered(bool) (/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x165b85)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/11/bits/stl_list.h:946 in std::__cxx11::list<PJ::PlotWidgetBase::CurveInfo, std::allocator<PJ::PlotWidgetBase::CurveInfo> >::begin()
Shadow bytes around the buggy address:
  0x0c22800d0f80: fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa
  0x0c22800d0f90: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c22800d0fa0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c22800d0fb0: fd fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa
  0x0c22800d0fc0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c22800d0fd0: fd fd fd fd fd fd fd fd[fd]fd fd fd fa fa fa fa
  0x0c22800d0fe0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c22800d0ff0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c22800d1000: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
  0x0c22800d1010: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c22800d1020: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==5956==ABORTING

By debugging a bit more, I found out that PlotWidget::on_changeTimeOffset() is still being called, even if the plot widget is no longer visible, i.e. after the steps above, not two calls are being made, but rather three. This could mean that the event is not correctly disconnected, but I don't know much about Qt event handling. Doing some print debugging it was clear that ~DockWidget() and ~QwtPlotPimpl() is being called, but not ~PlotWidget(). A simple fix for this was adding a delete call to DockWidget:

henrikkunzelmann@1e805bc

I will do a pull request if no other issues pop up. But I think this delete call maybe masks the real issue, such that somehow the created XY curve holds a reference to the PlotWidget.

@facontidavide
Copy link
Owner

thanks, this really helps a lot. @henrik1235 I appreciate a lot that you investigated this yourself and found a solution

@facontidavide facontidavide reopened this Dec 14, 2021
@NavKai
Copy link

NavKai commented Dec 17, 2021

i found the signel:valueChange will invoke all plot widget even we close someone;but when we close a plot widget.it seem that DockWidget wont be delete automatic.so tht close objects slot will be invoke,this will cause problem;

facontidavide added a commit that referenced this issue Jan 4, 2022
@facontidavide
Copy link
Owner

The previous was not a solution, but this is: 7a0df31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants