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 occurs when plugins are continuously deleted from the Display panel #1658

Closed
tsukione opened this issue Aug 26, 2021 · 6 comments
Closed

Comments

@tsukione
Copy link

tsukione commented Aug 26, 2021

Perform the following operations to delete the plug-in from the Display panel to reproduce the problem:
1.Select the last row;
2.Press Ctrl and select the penultimate line;
3.Then double click the Remove button, rviz crash here.

The gdb backtrace:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `rviz'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f354e79cc40 in rviz::Property::getParent() const () from /opt/ros/melodic/lib/librviz.so
[Current thread is 1 (Thread 0x7f354eb38840 (LWP 1762))]
(gdb) bt
#0  0x00007f354e79cc40 in rviz::Property::getParent() const () at /opt/ros/melodic/lib/librviz.so
#1  0x00007f354e79d459 in rviz::Property::rowNumberInParent() const () at /opt/ros/melodic/lib/librviz.so
#2  0x00007f354e79e9d0 in rviz::PropertyTreeModel::indexOf(rviz::Property*) const ()
    at /opt/ros/melodic/lib/librviz.so
#3  0x00007f354e79ea52 in rviz::PropertyTreeModel::parentIndex(rviz::Property const*) const ()
    at /opt/ros/melodic/lib/librviz.so
#4  0x00007f354e79ead9 in rviz::PropertyTreeModel::parent(QModelIndex const&) const ()
    at /opt/ros/melodic/lib/librviz.so
#5  0x00007f354d8d176f in QPersistentModelIndex::parent() const () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f354d8e2772 in QItemSelection::contains(QModelIndex const&) const ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f354d8e2ba4 in QItemSelectionModel::isSelected(QModelIndex const&) const ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f354e1fb496 in QTreeView::drawRow(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x00007f354e200b6d in QTreeView::drawTree(QPainter*, QRegion const&) const ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x00007f354e205615 in QTreeView::paintEvent(QPaintEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#11 0x00007f354df89048 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007f354e02a4de in QFrame::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007f354e19db8b in QAbstractItemView::viewportEvent(QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007f354e20652c in QTreeView::viewportEvent(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007f354d9355bc in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007f354df4a815 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007f354df52104 in QApplication::notify(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007f354d9358d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007f354df8219a in QWidgetPrivate::sendPaintEvent(QRegion const&) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
---Type <return> to continue, or q <return> to quit---
QWidgetBackingStore*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007f354df833c0 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007f354df83549 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007f354df82366 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007f354df833c0 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007f354df82366 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#26 0x00007f354df833c0 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#27 0x00007f354df83549 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#28 0x00007f354df83549 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#29 0x00007f354df83549 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#30 0x00007f354df83549 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#31 0x00007f354df82366 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#32 0x00007f354df833c0 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#33 0x00007f354df82366 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#34 0x00007f354df833c0 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#35 0x00007f354df82366 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#36 0x00007f354df59e64 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#37 0x00007f354df5a0a5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#38 0x00007f354df7167f in QWidgetPrivate::syncBackingStore() () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#39 0x00007f354df891b8 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#40 0x00007f354e09cc6b in QMainWindow::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#41 0x00007f354df4a83c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#42 0x00007f354df52104 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#43 0x00007f354d9358d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#44 0x00007f354d93804d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#45 0x00007f354d98f263 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#46 0x00007f3546ac8537 in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#47 0x00007f3546ac8770 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#48 0x00007f3546ac87fc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#49 0x00007f354d98e88f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#50 0x00007f354d93390a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#51 0x00007f354d93c9b4 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52 0x000055b7e3258dcf in main ()

Your environment

  • OS Version: Ubuntu 18.04
  • ROS Distro: [Melodic]
  • RViz, Qt, OGRE, OpenGl version as printed by rviz:
[ INFO] [1629963731.348498100]: rviz version 1.13.18
[ INFO] [1629963731.348569900]: compiled against Qt version 5.9.5
[ INFO] [1629963731.348584100]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [1629963731.352838400]: Forcing OpenGl version 0.
[ INFO] [1629963731.476697900]: Stereo is NOT SUPPORTED
[ INFO] [1629963731.476782900]: OpenGL device: llvmpipe (LLVM 10.0.0, 256 bits)
[ INFO] [1629963731.476819200]: OpenGl version: 3.1 (GLSL 1.4).
@rhaschke
Copy link
Contributor

I cannot reproduce this with a simple Grid display. Can you provide more detailed instructions to reproduce, please. Ideally a rviz config file.

@tsukione
Copy link
Author

tsukione commented Aug 26, 2021

image
image
Double click Remove
image
image

@rhaschke
Copy link
Contributor

I understood the procedure. What I meant with "I cannot reproduce this": rviz doesn't crash for me if following your procedure.
Please, note that you don't need to double-click the button, a simple click is sufficient. Nevertheless, rviz shouldn't crash.

@tsukione
Copy link
Author

But I can reproduce the issue on multiple devices. It is 100% reproducible. I know it's not necessary to double-click remove under normal circumstances, and I only stumbled upon this issue by accident. I'm guessing something goes wrong with the indexing after the plug-in is removed.

@tsukione
Copy link
Author

tsukione commented Aug 27, 2021

I've found the root cause of the problem.
The returned list by getSelectedObjects is stored in the same order as the mouse clicks.
So if I select the last item and then select the penultimate item, the "new_selected" in line 183 will store the index of the penultimate item. So the second time I click the Remove button, it will cause an crash.

void DisplaysPanel::onDeleteDisplay()
{
QList<Display*> displays_to_delete = property_grid_->getSelectedObjects<Display>();
QModelIndex new_selected;
for (int i = 0; i < displays_to_delete.size(); i++)
{
if (i == 0)
{
QModelIndex first = property_grid_->getModel()->indexOf(displays_to_delete[i]);
// This is safe because the first few rows cannot be deleted (they aren't "displays").
new_selected = first.sibling(first.row() - 1, first.column());
}
// Displays can emit signals from other threads with self pointers. We're
// freeing the display now, so ensure no one is listening to those signals.
displays_to_delete[i]->disconnect();
// Remove dipslay from property tree to avoid memory access after deletion
displays_to_delete[i]->getParent()->takeChild(displays_to_delete[i]);
// Delete display later in case there are pending signals to it.
displays_to_delete[i]->deleteLater();
}
QItemSelection selection(new_selected, new_selected);
property_grid_->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
vis_manager_->notifyConfigChanged();
}

@rhaschke
Copy link
Contributor

Thanks for clarifying. I can reproduce now. I will have a look for a fix.

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

No branches or pull requests

2 participants