SIGSEGV in ~QMessageBox on Plasma - native message dialog helper is used after free

Đang mở Phù hợp với người mới
#68 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@wehrwolfmann đang làm issue này rồi.

Từ ngày 22/8/2026.

  • #69 của @wehrwolfmann — đang mở
  • #71 của @myakupozluk — đã đóng, không merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
desktop

Hướng nghiên cứu

Bắt đầu trong src/main.cpp, quanh main(), nơi các thuộc tính của ứng dụng được cấu hình, và xem xét cài đặt hộp thoại native đã được báo cáo. Chạy thử các hộp thoại About và License dưới trình gỡ lỗi, như trong báo cáo. Được xem là hoàn tất khi Plasma helper QMessageBox không được khởi tạo, setNativeDialogVisible không được gọi và việc lặp lại các chu kỳ hộp thoại không gây crash.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

cachyos-pi 1.6.2, Qt 6.11.2, plasma-integration 6.7.4, Plasma 6 / Wayland.

What I did: a package install was running (pkexec pacman -S krita), I pressed "About" and
closed the About box. The app died with SIGSEGV. The core dump is kept, key frames below.

What happens: on Plasma our message boxes are shown as native dialogs.
KDEPlatformMessageDialogHelper::show() creates its own QMessageBox, sets Qt::WA_DeleteOnClose
on it and keeps a raw pointer to it. QDialog::exec() deletes that dialog when it closes, so
the helper keeps a dangling pointer. Later, when our QMessageBox is destroyed,
~QMessageBox -> QMessageBoxPrivate::setVisible(false) -> QDialogPrivate::setNativeDialogVisible(false)
-> helper->hide() -> m_dialog->hide() reads the freed object and calls through a garbage vtable.

Key frames from the core:

  #0  0x0000000000000071            <- jump through freed vtable
  #1  QDialogPrivate::setNativeDialogVisible(bool)
  #2  QMessageBoxPrivate::setVisible(bool)
  #3  QMessageBox::~QMessageBox()
  #4  about::display_about_msgbox()   (src/about.cpp:16)
In the core: nativeDialogInUse = 1, m_platformHelper is a KDEPlatformMessageDialogHelper, and
its m_dialog member points into a freed 40-byte block. Its hide() is literally
`mov 0x20(%rdi),%rdi; jmp QWidget::hide` - no null check, no QPointer.

The defect itself is in plasma-integration and I am reporting it there too, but every
QMessageBox in the app is exposed to it, so the patch below simply keeps Qt's own dialogs.
Nothing changes visually - the "native" Plasma dialog is a QMessageBox as well.

What I measured: with the patch the helper dialog is never created - 10 About/License cycles
under a debugger, zero helper QMessageBox constructions and zero setNativeDialogVisible calls,
app alive. Without the patch the helper dialog is created and destroyed before our own box on
every single About click, i.e. the dangling pointer is there every time.

Patch

diff --git a/src/main.cpp b/src/main.cpp
index bd9fb40..a1b964a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -138,6 +138,12 @@ auto main(int argc, char** argv) -> std::int32_t {
     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
 #endif

+    // Keep using Qt's own dialogs. The Plasma platform theme creates a helper QMessageBox
+    // for every native message dialog, marks it WA_DeleteOnClose and keeps a raw pointer
+    // to it. QDialog::exec() deletes that helper dialog when it closes, so the later
+    // hide() call from ~QMessageBox dereferences freed memory and can kill the app.
+    QApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
+
     /// 2. Application identification
     QApplication::setOrganizationName("cachyos");
     QApplication::setOrganizationDomain("cachyos.org");
Ngôn ngữ chính
C++
Star
43
Fork
39
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CachyOS/packageinstaller

Tất cả issue của CachyOS/packageinstaller

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.