Fixed structure viewer crash in "Locals" tab.

This commit is contained in:
Ernie Pasveer
2023-11-12 12:11:38 -06:00
parent 2d949ce822
commit 4403b58a3c
5 changed files with 65 additions and 2 deletions
+22 -1
View File
@@ -7,6 +7,7 @@
#include <QtGui/QFontDatabase>
#include <QAction>
#include <QtCore/QDebug>
#include <QtGlobal>
SeerStackLocalsBrowserWidget::SeerStackLocalsBrowserWidget (QWidget* parent) : QWidget(parent) {
@@ -84,9 +85,27 @@ void SeerStackLocalsBrowserWidget::handleText (const QString& text) {
// At this point, there are some new entries, some reused entries, and some unused ones.
// Delete the unused ones. They are obsolete.
// Don't use qDeleteAll() here. It doesn't work as expected for items that are "found".
// Instead, get a list of matches and delete them from the bottom up.
QList<QTreeWidgetItem*> matches = localsTreeWidget->findItems("unused", Qt::MatchExactly|Qt::MatchRecursive, 3);
qDeleteAll(matches);
while (matches.isEmpty() == false) {
foreach (QTreeWidgetItem* item, matches) {
if (item->childCount() == 0) {
QTreeWidgetItem* parent = item->parent();
if (parent) {
parent->removeChild(item);
}
bool f = matches.removeOne(item);
Q_ASSERT(f != false);
delete item;
break;
}
}
}
}else if (text.startsWith("^error,msg=\"No registers.\"")) {
localsTreeWidget->clear();
@@ -549,7 +568,9 @@ void SeerStackLocalsBrowserWidget::handleItemCreate (QTreeWidgetItem* parentItem
// Simple entries don't have children. Delete them.
QList<QTreeWidgetItem*> children = item->takeChildren();
if (matches.size() > 0) {
qDeleteAll(children);
}
// Populate the item.
item->setText(0, name_text);
+3
View File
@@ -0,0 +1,3 @@
mnwe
rrun
*.seer
+10
View File
@@ -0,0 +1,10 @@
.PHONY: all
all: mnwe
mnwe: mnwe.cpp
g++ -g -O0 -o mnwe mnwe.cpp
.PHONY: clean
clean:
rm -f mnwe mnwe.o
+23
View File
@@ -0,0 +1,23 @@
https://github.com/epasveer/seer/issues/181
I can reproduce it like this:
Create a segfaulting file, e.g. this mnwe.cpp file:
int main() {
int * i = nullptr;
*i = 42;
return 0;
}
Compile as g++ -g -O0 mnwe.cpp -o mnwe
Record the trace using rr: rr record --output-trace-dir=rrrun ./mnwe (you should see the segfault)
Start seergdb with this trace: seergdb --rr rrrun
When seergbd stops before main(), make sure that the 'Locals' tab is open
Hit F8 to run the trace
+6
View File
@@ -0,0 +1,6 @@
int main() {
int * i = nullptr;
*i = 42;
return 0;
}