Application crashes at subclassed QMainWindow argv reading
-
I am using macOS 13.4 (Ventura) developing projects in Qt 6.5.1.
When I am developing my own Qt project, while its app modifier and controller is by subclassing QApplication, the app crashes at the point where the application starts with an argument that the Qt builtin's one doesn't recognized. For example,
./App.app/Contents/MacOs/App --reverse
This command works without exit abnormally. However,
./App.app/Contents/MacOs/App asdf
It crashes, saying it's caused by a segment fault (exit code 11 with BAD_ACCESS, and of course without a proper display of help message saying that the
asdf
parameter is not recognized. It just crashed. This also greatly affects the initial file path to be processed contained in theargv
pointer list, like:./App.app/Contents/MacOs/App /Users/User/Desktop/test.txt
Crashed.
Here are the Minimal Reproducible Example:
BrStormTextApplication.hpp
#ifndef BRSTORMTEXTAPPLICATION_HPP #define BRSTORMTEXTAPPLICATION_HPP #include <QApplication> #include <QEvent> class BrStormTextApplication : public QApplication { Q_OBJECT public: BrStormTextApplication(int argc, char *argv[]); public slots: void setConstructed(bool c) {m_c = c;} public: bool event(QEvent *event) override; signals: void fileOpened(QString file); private: bool m_c = false; }; #endif // BRSTORMTEXTAPPLICATION_HPP
BrStormTextApplication.cpp
#include "BrStormTextApplication.hpp" #include "BrStormTextMainWindow.hpp" #include <QFile> #include <QFileOpenEvent> BrStormTextApplication::BrStormTextApplication(int argc, char *argv[]) : QApplication(argc, argv) { setApplicationDisplayName(tr("StormText")); setApplicationName("BrStormText"); setApplicationVersion(tr("0.7.0 (beta)")); setObjectName("BrStormTextApplication"); } bool BrStormTextApplication::event(QEvent *event) { if (event->type() == QEvent::FileOpen && m_c) { QFileOpenEvent *e = static_cast<QFileOpenEvent*>(event); emit fileOpened(e->file()); } return QApplication::event(event); }
BrStormTextMainWindow.hpp
#ifndef BRSTORMTEXTMAINWINDOW_HPP #define BRSTORMTEXTMAINWINDOW_HPP #include <QAction> #include <QActionGroup> #include <QDockWidget> #include <QFileSystemModel> #include <QMainWindow> #include <QMenu> #include <QMenuBar> #include <QToolButton> #include <QTreeView> #include "BrStormTextTab.hpp" #include "BrStormTextStatusBar.hpp" #include "BrStormTextDialogs/BrStormTextAboutApplicationDialog.hpp" #include "BrStormTextDialogs/BrStormTextAboutDialog.hpp" #include "BrStormTextDialogs/BrStormTextGotoDialog.hpp" #include "BrStormTextFindDock.hpp" class BrStormTextApplication; class BrStormTextMainWindow : public QMainWindow { Q_OBJECT public: BrStormTextMainWindow(QList<QString> argv, BrStormTextApplication *app, int u = 0, bool o = false, QWidget *parent = nullptr); public: void closeEvent(QCloseEvent *event); public slots: void openThroughArgs(QString path); private: void initUi(); void initMenus(); void initFileMenu(); ... void initHelpMenu(); void initActionGroups(); void initTabs(); void initStatusBar(); void initFileBrowser(); void initFindDock(); void initSignals(); private slots: ... // Other non-related methods private: ... // Menus, tree views and list views BrStormTextTab *m_tab; private: int m_untitled; BrStormTextApplication *m_app; }; #endif // BRSTORMTEXTMAINWINDOW_HPP
BrStormTextMainWindow.cpp
#include "BrStormTextMainWindow.hpp" #include "BrStormTextEditor.hpp" #include "BrStormTextDialogs/BrStormTextOpenDialog.hpp" #include "BrStormTextDialogs/BrStormTextSaveCopyToDialog.hpp" #include "BrStormTextDialogs/BrStormTextSaveDialog.hpp" #include "BrStormTextApplication.hpp" #include <QCloseEvent> #include <QDir> #include <QFile> #include <QFileInfo> #include <QFileIconProvider> #include <QHeaderView> #include <QMessageBox> #include <Qsci/qscilexer.h> #include <QTextStream> BrStormTextMainWindow::BrStormTextMainWindow(QList<QString> argv, BrStormTextApplication *app, int u, bool o, QWidget *parent) : QMainWindow(parent) { m_untitled = u; m_app = app; initUi(); if (o) openFile(true); for (const QString &str : argv) { openThroughArgs(str); } } void BrStormTextMainWindow::openThroughArgs(QString path) { QFile f(path); if (!m_tab) return; if (!f.exists()) { QMessageBox msg = QMessageBox(this); msg.setWindowModality(Qt::WindowModal); msg.setWindowTitle(tr("FileNoutFoundError")); msg.setIcon(QMessageBox::Critical); msg.setText(tr("Sorry, the file you have selected does not exists.")); msg.setInformativeText(tr("Check if you have misspelt the file name," "the file path or check your network connections. \n" "BR_STORMTEXT_0x00003855")); msg.setStandardButtons(QMessageBox::Ok); msg.exec(); return; } if (f.open(QFile::ReadOnly | QFile::Text)) { QTextStream ts(&f); QString c = ts.readAll(); QFileInfo fi(f); QFileIconProvider fip; QIcon icns = fip.icon(fi); QString ce = fi.completeSuffix().toLower(); BrStormTextEditor *ed; ed = new BrStormTextEditor(); ed->setText(c); connect(ed, &BrStormTextEditor::modificationChanged, this, [=](bool m){setWindowModified(m);}); if (ce == "avs") { ed->setLexerAVS(true); } else if (ce == "sh" || ce == "bash") { ed->setLexerBash(true); } else if (ce == "bat" || ce =="cmd" || ce == "btm") { ed->setLexerBatch(true); } else if (ce == "cpp" || ce == "cxx" || ce == "cc" || ce == "ii" || ce == "h" || ce == "hpp" || ce == "hxx") { ed->setLexerCPP(true); } ...... else if (ce == "xml" || ce == "svg" || ce == "svgx" || ce == "plist" || ce == "string" || ce == "qrc" || ce == "rc" || ce == "ui" || c.startsWith("<?xml version=")) { ed->setLexerXML(true); } else if (ce == "yml") { ed->setLexerYAML(true); } int i = m_tab->addTab(ed, icns, fi.fileName()); m_tab->setTabToolTip(i, fi.absoluteFilePath()); m_tab->setCurrentIndex(i); m_tab->currentTab()->setModified(false); setWindowModified(m_tab->currentTab()->isModified()); } else { QMessageBox msg = QMessageBox(this); msg.setWindowModality(Qt::WindowModal); msg.setWindowTitle(tr("OSError")); msg.setIcon(QMessageBox::Critical); msg.setText(tr("Sorry, the file you have selected cannot be opened.")); msg.setInformativeText(tr("This might be caused by inconsistence file access," "Or the disconnection of your current network " "condition. Try to contact your technical manager / " "system administrator for more information / solution. \n" "BR_STORMTEXT_0x00000094")); msg.setStandardButtons(QMessageBox::Ok); msg.exec(); return; } f.close(); return; } void BrStormTextMainWindow::initUi() { m_aAppD = new BrStormTextAboutApplicationDialog(this); ... initMenus(); initTabs(); initStatusBar(); initFileBrowser(); initFindDock(); initSignals(); connect(m_app, SIGNAL(fileOpened(QString)), this, SLOT(openThroughArgs(QString))); } ...
main.cpp
#include "BrStormTextApplication.hpp" #include "BrStormTextMainWindow.hpp" int main(int argc, char *argv[]) { try { QList<QString> argvFiles = {}; if (argc >= 2) { for (int i = 1; i < argc; i++) { if (QFile(QString(argv[i])).exists()) argvFiles.push_back(QString(argv[i])); } } BrStormTextApplication app(argc, argv); BrStormTextMainWindow mw(argvFiles, &app); app.setConstructed(true); mw.showMaximized(); return app.exec(); } catch (std::exception &e) { Q_UNUSED(e) return 1; } }
PS I am making a text editor using the QScintilla framework. Document at https://brdocumentation.github.io/qscintilla/index.html for reference.
I am very wondering what I am wrong. Thanks for every work and views! Appreciate.
-
Your argc is wrong. It must be a reference according to the documentation. There is even a big red note. Reading the docs sometimes helps.
-
Here are the crash report:
------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: StormText [7554] Path: /Users/USER/*/StormText.app/Contents/MacOS/StormText Identifier: org.**************************.StormText Version: ??? Code Type: X86-64 (Native) Parent Process: zsh [5594] Responsible: Terminal [3425] User ID: 501 Date/Time: 2023-08-03 17:16:41.2890 +0800 OS Version: macOS 13.4 (22F66) Report Version: 12 Anonymous UUID: 4566117B-****-****-****-07A965E31605 Time Awake Since Boot: 21000 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: UNKNOWN_0xD at 0x0000000000000000 Exception Codes: 0x000000000000000d, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [7554] VM Region Info: 0 is not in any region. Bytes before following region: 4543410176 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 10ecef000-10ed87000 [ 608K] r-x/r-x SM=COW ...cOS/StormText Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_platform.dylib 0x7ff81b4c1f12 _platform_strlen + 18 1 QtCore 0x111f1a062 QCoreApplication::arguments() + 146 2 libqcocoa.dylib 0x10f17703f 0x10f16c000 + 45119 3 AppKit 0x7ff81ea214af -[NSApplication _doOpenFile:ok:tryTemp:] + 267 4 AppKit 0x7ff81e5f7463 -[NSApplication finishLaunching] + 2076 5 AppKit 0x7ff81e5f6998 -[NSApplication run] + 250 6 libqcocoa.dylib 0x10f1835b7 0x10f16c000 + 95671 7 QtCore 0x111f20f36 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 486 8 QtCore 0x111f17d27 QCoreApplication::exec() + 119 9 StormText 0x10ed36a57 main + 919 10 dyld 0x10f6ad41f start + 1903 Thread 1: 0 libsystem_pthread.dylib 0x7ff81b492bb0 start_wqthread + 0 Thread 2: 0 libsystem_pthread.dylib 0x7ff81b492bb0 start_wqthread + 0 Thread 3: 0 libsystem_pthread.dylib 0x7ff81b492bb0 start_wqthread + 0 Thread 4: 0 libsystem_pthread.dylib 0x7ff81b492bb0 start_wqthread + 0 Thread 5: 0 libsystem_pthread.dylib 0x7ff81b492bb0 start_wqthread + 0 Thread 6:: Thread (pooled) 0 libsystem_kernel.dylib 0x10ee200ee __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff81b497758 _pthread_cond_wait + 1242 2 QtCore 0x1120b5fac 0x111ea9000 + 2150316 3 QtCore 0x1120b5cae 0x111ea9000 + 2149550 4 QtCore 0x1120b5bfe QWaitCondition::wait(QMutex*, QDeadlineTimer) + 94 5 QtCore 0x1120affd5 0x111ea9000 + 2125781 6 QtCore 0x1120abab3 0x111ea9000 + 2108083 7 libsystem_pthread.dylib 0x7ff81b4971d3 _pthread_start + 125 8 libsystem_pthread.dylib 0x7ff81b492bd3 thread_start + 15 Thread 7:: Thread (pooled) 0 libsystem_kernel.dylib 0x10ee200ee __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff81b497758 _pthread_cond_wait + 1242 2 QtCore 0x1120b5fac 0x111ea9000 + 2150316 3 QtCore 0x1120b5cae 0x111ea9000 + 2149550 4 QtCore 0x1120b5bfe QWaitCondition::wait(QMutex*, QDeadlineTimer) + 94 5 QtCore 0x1120affd5 0x111ea9000 + 2125781 6 QtCore 0x1120abab3 0x111ea9000 + 2108083 7 libsystem_pthread.dylib 0x7ff81b4971d3 _pthread_start + 125 8 libsystem_pthread.dylib 0x7ff81b492bd3 thread_start + 15 Thread 8:: Thread (pooled) 0 libsystem_kernel.dylib 0x10ee200ee __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff81b497758 _pthread_cond_wait + 1242 2 QtCore 0x1120b5fac 0x111ea9000 + 2150316 3 QtCore 0x1120b5cae 0x111ea9000 + 2149550 4 QtCore 0x1120b5bfe QWaitCondition::wait(QMutex*, QDeadlineTimer) + 94 5 QtCore 0x1120affd5 0x111ea9000 + 2125781 6 QtCore 0x1120abab3 0x111ea9000 + 2108083 7 libsystem_pthread.dylib 0x7ff81b4971d3 _pthread_start + 125 8 libsystem_pthread.dylib 0x7ff81b492bd3 thread_start + 15 Thread 9:: Thread (pooled) 0 libsystem_kernel.dylib 0x10ee200ee __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff81b497758 _pthread_cond_wait + 1242 2 QtCore 0x1120b5fac 0x111ea9000 + 2150316 3 QtCore 0x1120b5cae 0x111ea9000 + 2149550 4 QtCore 0x1120b5bfe QWaitCondition::wait(QMutex*, QDeadlineTimer) + 94 5 QtCore 0x1120affd5 0x111ea9000 + 2125781 6 QtCore 0x1120abab3 0x111ea9000 + 2108083 7 libsystem_pthread.dylib 0x7ff81b4971d3 _pthread_start + 125 8 libsystem_pthread.dylib 0x7ff81b492bd3 thread_start + 15 Thread 10:: QFileInfoGatherer 0 libsystem_kernel.dylib 0x10ee200ee __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff81b497758 _pthread_cond_wait + 1242 2 QtCore 0x1120b5c8b 0x111ea9000 + 2149515 3 QtCore 0x1120b5bfe QWaitCondition::wait(QMutex*, QDeadlineTimer) + 94 4 QtGui 0x10fc21e6d QFileInfoGatherer::run() + 125 5 QtCore 0x1120abab3 0x111ea9000 + 2108083 6 libsystem_pthread.dylib 0x7ff81b4971d3 _pthread_start + 125 7 libsystem_pthread.dylib 0x7ff81b492bd3 thread_start + 15 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x00007ff7b1210938 rbx: 0x6261747563657865 rcx: 0x6261747563657865 rdx: 0x6261747563657865 rdi: 0x6261747563657860 rsi: 0x0000000000007fd7 rbp: 0x00007ff7b120fb50 rsp: 0x00007ff7b120fb50 r8: 0x00007fb3863ae010 r9: 0x00007ff7b120fc10 r10: 0x00000000000004e0 r11: 0x00006000003c193c r12: 0x0000000000000021 r13: 0x0000000000007ff7 r14: 0x00007ff7b120fb68 r15: 0x00007ff7b120fc00 rip: 0x00007ff81b4c1f12 rfl: 0x0000000000010206 cr2: 0x00007fb3863ae000 Logical CPU: 0 Error Code: 0x00000000 Trap Number: 13 Thread 0 instruction stream: 29 07 c5 fc 29 47 20 48-83 c7 40 48 83 ea 40 77 )...)G H..@H..@w ed c5 fc 11 04 17 c5 fc-11 44 17 20 c5 f8 77 5d .........D. ..w] c3 48 89 34 17 48 83 ea-08 73 f6 48 83 c2 08 74 .H.4.H...s.H...t 0b 40 88 74 17 ff 48 83-ea 01 75 f5 5d c3 90 90 .@.t..H...u.]... 90 90 90 90 90 90 90 90-90 90 90 90 90 90 55 48 ..............UH 89 e5 48 89 f9 48 89 fa-48 83 e7 f0 66 0f ef c0 ..H..H..H...f... [66]0f 74 07 66 0f d7 f0-48 83 e1 0f 48 83 c8 ff f.t.f...H...H... <== 48 d3 e0 21 c6 74 17 0f-bc c6 48 29 d7 48 01 f8 H..!.t....H).H.. 5d c3 66 2e 0f 1f 84 00-00 00 00 00 66 90 48 83 ].f.........f.H. c7 10 66 0f ef c0 66 0f-74 07 66 0f d7 f0 85 f6 ..f...f.t.f..... 74 ec eb d3 65 48 8b 0c-25 18 00 00 00 41 89 c8 t...eH..%....A.. 31 c0 f0 4c 0f b1 07 0f-85 7a 1f 00 00 e9 00 00 1..L.....z...... Binary Images: 0x10f6a7000 - 0x10f742fff dyld (*) <5db85b72-c63a-3182-91e5-5c942ec30e48> /usr/lib/dyld 0x10ecef000 - 0x10ed86fff org.BrightSoftwareFoundation.StormText (0.7.0 (beta)) <00940740-e0d2-3a3e-ae3d-7e7061aac7ec> /Users/USER/*/StormText.app/Contents/MacOS/StormText 0x10f2de000 - 0x10f501fff libqscintilla2_qt6.15.2.0.dylib (*) <ac050aa8-5999-3d76-a862-44b353aea2fa> /Users/USER/*/libqscintilla2_qt6.15.2.0.dylib 0x10ef08000 - 0x10ef4ffff org.qt-project.QtPrintSupport (6.5) <d82cf849-dcbb-3952-9df7-b3e49d987965> /Users/USER/*/QtPrintSupport.framework/Versions/A/QtPrintSupport 0x110365000 - 0x11081cfff org.qt-project.QtWidgets (6.5) <76764adf-2707-3561-a2d4-9d1ea12d1646> /Users/USER/*/QtWidgets.framework/Versions/A/QtWidgets 0x10f7a7000 - 0x10fe86fff org.qt-project.QtGui (6.5) <38f8e919-bceb-3ecc-9459-4678276a9bfb> /Users/USER/*/QtGui.framework/Versions/A/QtGui 0x110e84000 - 0x111063fff com.apple.Metal (306.7.4) <6581cd53-8583-38d1-b4b9-773f1dc3f551> /System/Library/Frameworks/Metal.framework/Versions/A/Metal 0x111ea9000 - 0x1123b0fff org.qt-project.QtCore (6.5) <34a0b888-75de-3b10-871f-c88de823daed> /Users/USER/*/QtCore.framework/Versions/A/QtCore 0x10ee1c000 - 0x10ee57fff libsystem_kernel.dylib (*) <eb4e80a0-99da-32dc-b9ad-394fbb50a0ac> /usr/lib/system/libsystem_kernel.dylib 0x112471000 - 0x1124b8fff libllvm-flatbuffers.dylib (*) <d5ce0002-b92a-3d76-9549-1fb7bc428091> /System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/libllvm-flatbuffers.dylib 0x18bf15000 - 0x18bf18fff libGPUCompilerUtils.dylib (*) <d5ce0002-b778-37c5-917b-186e88376470> /System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/libGPUCompilerUtils.dylib 0x10f0c6000 - 0x10f14dfff org.qt-project.QtDBus (6.5) <116736a0-a8f5-3df9-939f-3b90528c1ad9> /Users/USER/*/QtDBus.framework/Versions/A/QtDBus 0x10efeb000 - 0x10f002fff com.apple.security.csparser (3.0) <75cf9d81-d8fa-3241-8a6c-188e6d92aa81> /System/Library/Frameworks/Security.framework/Versions/A/PlugIns/csparser.bundle/Contents/MacOS/csparser 0x10f16c000 - 0x10f20bfff libqcocoa.dylib (*) <f9819bed-8274-3782-b072-434406572ff6> /Users/USER/*/libqcocoa.dylib 0x10f5f5000 - 0x10f61cfff libqmacstyle.dylib (*) <e07f1838-042f-32eb-a93c-57f520f94ebe> /Users/USER/*/libqmacstyle.dylib 0x10f2c5000 - 0x10f2d4fff libobjc-trampolines.dylib (*) <48a76ddd-8a45-3498-a5a3-86a9976e68e5> /usr/lib/libobjc-trampolines.dylib 0x10f5e3000 - 0x10f5eafff libqgif.dylib (*) <e75e34b4-1ff2-347c-ad6f-f83e21dca2d1> /Users/USER/*/libqgif.dylib 0x10f677000 - 0x10f67efff libqwbmp.dylib (*) <0c996e4c-e5ec-3853-8f0d-be6e27192938> /Users/USER/*/libqwbmp.dylib 0x110d9d000 - 0x110e2cfff libqwebp.dylib (*) <83aa8873-d2b5-310a-816e-77a08d2e9802> /Users/USER/*/libqwebp.dylib 0x10f64d000 - 0x10f654fff libqico.dylib (*) <2c8be3b5-a5be-3938-a1cf-6b6805467008> /Users/USER/*/libqico.dylib 0x10f660000 - 0x10f667fff libqmacheif.dylib (*) <c5552b5e-ae15-3bfa-a7b2-ad3d1d6cc794> /Users/USER/*/libqmacheif.dylib 0x111e28000 - 0x111e97fff libqjpeg.dylib (*) <cd91086e-f2b9-3c0a-915f-9f798d020539> /Users/USER/*/libqjpeg.dylib 0x111d5c000 - 0x111dc7fff libqtiff.dylib (*) <44803655-9eed-3505-9578-b0df99061637> /Users/USER/*/libqtiff.dylib 0x10f689000 - 0x10f690fff libqsvg.dylib (*) <f707818c-446d-3d0e-b81a-4b47ff614a9d> /Users/USER/*/libqsvg.dylib 0x209536000 - 0x209571fff org.qt-project.QtSvg (6.5) <7a844e24-d780-35b4-b9ac-05229591c71d> /Users/USER/*/QtSvg.framework/Versions/A/QtSvg 0x110e3a000 - 0x110e41fff libqpdf.dylib (*) <0e9afbad-0d10-3988-970d-63f1e612e087> /Users/USER/*/libqpdf.dylib 0x20a5ef000 - 0x20ae0efff org.qt-project.QtPdf (6.5) <1f7d9fd6-ba98-3b95-9b30-611688a4f537> /Users/USER/*/QtPdf.framework/Versions/A/QtPdf 0x209858000 - 0x20996ffff org.qt-project.QtNetwork (6.5) <ef83d5ee-a5c8-3ebd-9879-47054b8f3182> /Users/USER/*/QtNetwork.framework/Versions/A/QtNetwork 0x110e4d000 - 0x110e54fff libqicns.dylib (*) <94ee651a-f511-3936-8ff8-07c6e4d7ff85> /Users/USER/*/libqicns.dylib 0x110e60000 - 0x110e67fff libqtga.dylib (*) <6725362e-fb88-3d2d-8cd5-ec9bfe11c4d2> /Users/USER/*/libqtga.dylib 0x111dd4000 - 0x111ddbfff libqmacjp2.dylib (*) <6bed9f44-9778-3075-acaf-c4d23f54d856> /Users/USER/*/libqmacjp2.dylib 0x7ff81b4c1000 - 0x7ff81b4cafef libsystem_platform.dylib (*) <4ff3bd2f-2167-3ee6-a55d-384703bdf1f5> /usr/lib/system/libsystem_platform.dylib 0x7ff81e5c7000 - 0x7ff81f5ceff8 com.apple.AppKit (6.9) <935dfca1-61f9-377d-895a-99ef90266c86> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7ff81b491000 - 0x7ff81b49cfff libsystem_pthread.dylib (*) <8cb0b396-011f-31f2-8915-94cde1abae84> /usr/lib/system/libsystem_pthread.dylib External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 1 thread_create: 0 thread_set_state: 4 VM Region Summary: ReadOnly portion of Libraries: Total=463.6M resident=0K(0%) swapped_out_or_unallocated=463.6M(100%) Writable regions: Total=4.4G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=4.4G(100%) VIRTUAL REGION REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Accelerate framework 128K 1 Activity Tracing 256K 1 CG image 36K 1 ColorSync 252K 27 CoreUI image data 260K 4 Foundation 16K 1 Kernel Alloc Once 8K 1 MALLOC 189.5M 55 MALLOC guard page 32K 8 MALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated) STACK GUARD 56.0M 11 Stack 13.1M 12 VM_ALLOCATE 80K 5 VM_ALLOCATE (reserved) 3.8G 4 reserved VM address space (unallocated) __CTF 824 1 __DATA 18.2M 357 __DATA_CONST 15.4M 226 __DATA_DIRTY 676K 108 __FONT_DATA 2352 1 __LINKEDIT 178.4M 32 __OBJC_RO 66.3M 1 __OBJC_RW 2013K 2 __TEXT 285.2M 375 dyld private memory 260K 2 mapped file 181.2M 31 shared memory 776K 16 =========== ======= ======= TOTAL 5.2G 1284 TOTAL, minus reserved VM space 1.0G 1284 ----------- Full Report ----------- {"app_name":"StormText","timestamp":"2023-08-03 17:16:41.00 +0800","app_version":"0.7.0 (beta)","slice_uuid":"00940740-e0d2-3a3e-ae3d-7e7061aac7ec","build_version":"0.7","platform":1,"bundleID":"org.BrightSoftwareFoundation.StormText","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.4 (22F66)","roots_installed":0,"name":"StormText","incident_id":"2640A77B-C820-4036-B0F6-76A472FFAB44"} { "uptime" : 21000, "procRole" : "Background", "version" : 2, "userID" : 501, "deployVersion" : 210, "modelCode" : "MacBookAir6,1", "coalitionID" : 2616, "osVersion" : { "train" : "macOS 13.4", "build" : "22F66", "releaseType" : "User" }, "captureTime" : "2023-08-03 17:16:41.2890 +0800", "incident" : "2640A77B-C820-4036-B0F6-76A472FFAB44", "pid" : 7554, "cpuType" : "X86-64", "roots_installed" : 0, "bug_type" : "309", "procLaunch" : "2023-08-03 17:16:40.4817 +0800", "procStartAbsTime" : 21150685922820, "procExitAbsTime" : 21151491852648, "procName" : "StormText", "procPath" : "\/Users\/USER\/*\/StormText.app\/Contents\/MacOS\/StormText", "bundleInfo" : {"CFBundleShortVersionString":"0.7.0 (beta)","CFBundleVersion":"0.7","CFBundleIdentifier":"org.BrightSoftwareFoundation.StormText"}, "storeInfo" : {"deviceIdentifierForVendor":"3AF01067-5158-5C8F-9FB0-05F8F401B1DD","thirdParty":true}, "parentProc" : "zsh", "parentPid" : 5594, "coalitionName" : "com.apple.Terminal", "crashReporterKey" : "4566117B-6536-0C74-6A7F-07A965E31605", "responsiblePid" : 3425, "responsibleProc" : "Terminal", "codeSigningID" : "", "codeSigningTeamID" : "", "codeSigningValidationCategory" : 0, "codeSigningTrustLevel" : 0, "sip" : "enabled", "vmRegionInfo" : "0 is not in any region. Bytes before following region: 4543410176\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n __TEXT 10ecef000-10ed87000 [ 608K] r-x\/r-x SM=COW ...cOS\/StormText", "exception" : {"codes":"0x000000000000000d, 0x0000000000000000","rawCodes":[13,0],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"UNKNOWN_0xD at 0x0000000000000000"}, "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":7554}, "vmregioninfo" : "0 is not in any region. Bytes before following region: 4543410176\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n __TEXT 10ecef000-10ed87000 [ 608K] r-x\/r-x SM=COW ...cOS\/StormText", "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":4,"task_for_pid":1},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0}, "faultingThread" : 0, "threads" : [{"triggered":true,"id":182907,"instructionState":{"instructionStream":{"bytes": ... "vmSummary" : "ReadOnly portion of Libraries: Total=463.6M resident=0K(0%) swapped_out_or_unallocated=463.6M(100%)\nWritable regions: Total=4.4G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=4.4G(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nAccelerate framework 128K 1 \nActivity Tracing 256K 1 \nCG image 36K 1 \nColorSync 252K 27 \nCoreUI image data 260K 4 \nFoundation 16K 1 \nKernel Alloc Once 8K 1 \nMALLOC 189.5M 55 \nMALLOC guard page 32K 8 \nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nSTACK GUARD 56.0M 11 \nStack 13.1M 12 \nVM_ALLOCATE 80K 5 \nVM_ALLOCATE (reserved) 3.8G 4 reserved VM address space (unallocated)\n__CTF 824 1 \n__DATA 18.2M 357 \n__DATA_CONST 15.4M 226 \n__DATA_DIRTY 676K 108 \n__FONT_DATA 2352 1 \n__LINKEDIT 178.4M 32 \n__OBJC_RO 66.3M 1 \n__OBJC_RW 2013K 2 \n__TEXT 285.2M 375 \ndyld private memory 260K 2 \nmapped file 181.2M 31 \nshared memory 776K 16 \n=========== ======= ======= \nTOTAL 5.2G 1284 \nTOTAL, minus reserved VM space 1.0G 1284 \n", "legacyInfo" : { "threadTriggered" : { "queue" : "com.apple.main-thread" } }, "logWritingSignature" : "04c74f291e613f274b54935ee1b4361d4d44874b", "trialInfo" : { "rollouts" : [ { "rolloutId" : "60da5e84ab0ca017dace9abf", "factorPackIds" : { }, "deploymentId" : 240000008 }, { "rolloutId" : "60186475825c62000ccf5450", "factorPackIds" : { }, "deploymentId" : 240000055 } ], "experiments" : [ ] } }
-
By the way even if I use the
QCoreApplication::arguments().at(for i in range(...))
instead of using rawargv
directly it still gave me the exactly 100% same crash report, sayingCODE_11__BAD_ACCESS segment fault
:... BrStormTextApplication app(argc, argv); QList<QString> argvFiles = {}; if (app.arguments().length() >= 2) { for (const QString &str : app.arguments()) { if (QFile(str).exists()) argvFiles.push_back(str); } } BrStormTextMainWindow mw(argvFiles, &app); app.setConstructed(true); mw.showMaximized(); return app.exec(); } ...
-
@JackMyson said in Application crashes at subclassed QMainWindow argv reading:
if (argc >= 2)
{
for (int i = 1; i < argc; i++)
{
if (QFile(QString(argv[i])).exists()) argvFiles.push_back(QString(argv[i]));
}
}Why are you doing this? Your main window can get the application parameters from QApplication (using qApp) at any time. Also, stack trace after the crash could help to identify the issue.
-
@jsulm
've removed the line:QList<QString> argvFiles = {}; /*if (argc >= 2) { for (int i = 1; i < argc; i++) { if (QFile(QString(argv[i])).exists()) argvFiles.push_back(QString(argv[i])); } }*/
But still the same error:
zsh: segmentation fault ./StormText /Users/.../lang-avs.avs
-
Your argc is wrong. It must be a reference according to the documentation. There is even a big red note. Reading the docs sometimes helps.
-
Hi @JackMyson,
Among other issues, your
BrStormTextMainWindow::m_tab
pointer is being dereferenced without ever being initialised (unless you've dropped the initialisation code out of the sample).Have you tried running this with the debugger?
Cheers.
-
Hi @Paul-Colby ,
Even my Qt Creator 4 built-in debugger ran out of luck: crashed because of the same segment fault, before even the application window has shown.
Also thanks for your meticulous observations, I have really dropped the initialisation statement “m_tab = tabs;” out of the MRE.
-