Unsolved QTextCursor causes segmentation fault
-
Hi,
Might be a silly question but are you sure that
qte_Log
is a valid pointer ?Otherwise, what does the stack trace tell you ?
-
@bs55 said in QTextCursor causes segmentation fault:
qte_Log
Yes, this pointer is valid.
I forgot to specify that the code works but sometimes causes segmentation fault.
Here is the debuger stack trace:
1 ?? 0x7ffff3df5aac
2 ?? 0x7ffff3dea28e
3 ?? 0x7ffff3dea2e5
4 QTextEngine::itemize() const 0x7ffff3dee69c
5 QTextEngine::lineNumberForTextPosition(int) 0x7ffff3df0bed
6 QTextLayout::lineForTextPosition(int) const 0x7ffff3df785c
7 QTextCursorPrivate::setX() 0x7ffff3e47c4e
8 QTextCursor::insertText(QString const&, QTextCharFormat const&) 0x7ffff3e49775
9 QTextCursor::insertText(QString const&) 0x7ffff3e4a704
10 MainWindow::log mainwindow.cpp 843 0x416edb
11 MainWindow::captureProgressHandler mainwindow.cpp 600 0x414309
12 QtPrivate::FunctorCall<QtPrivate::IndexesList<0, 1>, QtPrivate::List<int, double>, void, void (MainWindow:: *)(int, double)>::call qobjectdefs_impl.h 136 0x425cf0
13 QtPrivate::FunctionPointer<void (MainWindow:: *)(int, double)>::call<QtPrivate::List<int, double>, void> qobjectdefs_impl.h 169 0x4251bf
14 QtPrivate::QSlotObject<void (MainWindow:: *)(int, double), QtPrivate::List<int, double>, void>::impl qobject_impl.h 120 0x4243c6
15 QMetaObject::activate(QObject *, int, int, void * *) 0x7ffff3756b96
16 CaptureThread::signalCaptureProgress moc_capturethread.cpp 158 0x42d414
17 CaptureThread::run capturethread.cpp 98 0x427dc8
18 ?? 0x7ffff355d70a
19 start_thread pthread_create.c 333 0x7ffff1b926ba
20 clone clone.S 109 0x7ffff2c5841d
... <More> -
The try catch does not seems to catch the error.
Just to be clear,
try ... catch
will only catch genuine, recoverable "errors". Once you have something like a Seg Fault, nothing will catch that. -
-
@bs55 said in QTextCursor causes segmentation fault:
Note: I don't know if it's relevant but my program is heavily multithreaded.
Is
MainWindow::logWarning
called directly from a secondary thread? -
@jsulm said in QTextCursor causes segmentation fault:
@bs55 To add to @JonB : Qt itself does not use (throw) exceptions.
OK. But if the underlying OS/windowing system does throw exceptions, would Qt catch them guaranteed or would they pass through to the calling code?
-
Qt by default is build without exception support disabled.
For the rest see the Exception Safety chapter in Qt's documentation.
-
@VRonin No the threads emit signals connected to a slot that uses the logWarning function.
-
@bs55 Did you use QueuedConnection in connect?
-
@bs55 said in QTextCursor causes segmentation fault:
No the threads emit signals connected to a slot that uses the logWarning function
Looks like they are connected with
Qt::DirectConnection
though which is equal to calling the slot from another thread11 MainWindow::captureProgressHandler mainwindow.cpp 600 0x414309 [...] 16 CaptureThread::signalCaptureProgress moc_capturethread.cpp 158 0x42d414 17 CaptureThread::run capturethread.cpp 98 0x427dc8