From 621498f88e882dbe8cc3a2c8373bb342bb0dbe77 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 9 Dec 2017 18:34:31 +0100 Subject: [PATCH] qt: follow stream: fix crash during close The Follow Stream dialogue's button "Filter out this stream" filters out the stream's packets and then closes the Follow Stream dialogue. This may take a moment. If the user presses the Close button while the filtering is still running, the dialogue will be closed twice. This causes a crash which can be seen in ASAN builds. ==9485==ERROR: AddressSanitizer: SEGV on unknown address 0x60205e80001b (pc 0x7f923e672b8c sp 0x7fff73104600 bp 0x7fff73104600 T0) #0 0x7f923e672b8b in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2d9b8b) #1 0x7f924f46010b in QApplicationPrivate::notify_helper(QObject*, QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x13f10b) #2 0x7f924f4655ff in QApplication::notify(QObject*, QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x1445ff) #3 0x7f923e672dca in QCoreApplication::notifyInternal(QObject*, QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2d9dca) #4 0x7f924f49ae54 in QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x179e54) #5 0x55f3e249582f in FollowStreamDialog::close() /media/sf_wireshark.git/ui/qt/follow_stream_dialog.cpp:327 #6 0x55f3e236e534 in FollowStreamDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ui/qt/moc_follow_stream_dialog.cpp:155 ... SUMMARY: AddressSanitizer: SEGV ??:0 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) ==9485==ABORTING Ignore the Close button if we know that we'll be closing the dialogue shortly. Change-Id: Ibf1684fd75937e6b24fcb9ea62ae6acb038260e6 Reviewed-on: https://code.wireshark.org/review/24777 Reviewed-by: Martin Kaiser Petri-Dish: Martin Kaiser Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- ui/qt/follow_stream_dialog.cpp | 10 ++++++++-- ui/qt/follow_stream_dialog.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index 6e0bf460b4..d316b8a7d1 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -83,7 +83,8 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_ last_from_server_(0), turns_(0), save_as_(false), - use_regex_find_(false) + use_regex_find_(false), + terminating_(false) { ui->setupUi(this); loadGeometry(parent.width() * 2 / 3, parent.height()); @@ -318,6 +319,8 @@ void FollowStreamDialog::filterOut() void FollowStreamDialog::close() { + terminating_ = true; + // Update filter - Use: // previous_filter if 'Close' (passed in follow() method) // filter_out_filter_ if 'Filter Out This Stream' (built by appending !current_stream to previous_filter) @@ -373,9 +376,12 @@ void FollowStreamDialog::on_streamNumberSpinBox_valueChanged(int stream_num) } } -// Not sure why we have to do this manually. void FollowStreamDialog::on_buttonBox_rejected() { + // Ignore the close button if FollowStreamDialog::close() is running. + if (terminating_) + return; + WiresharkDialog::reject(); } diff --git a/ui/qt/follow_stream_dialog.h b/ui/qt/follow_stream_dialog.h index 0c6996b783..2c644c7e3a 100644 --- a/ui/qt/follow_stream_dialog.h +++ b/ui/qt/follow_stream_dialog.h @@ -134,6 +134,8 @@ private: bool save_as_; bool use_regex_find_; QFile file_; + + bool terminating_; }; #endif // FOLLOW_STREAM_DIALOG_H