Skip to content

Commit b90f387

Browse files
committed
Merge #774: [GUI] Do not use Qt's debugging information in the log handler.
5416ae0 Do not use Qt's debugging information in the log handler. (sinetek) Pull request description: (Commit cherry picked from #766 for fast tracking) ### Problem ### CaveSpectre and mimir (others?) have reported a crash on recent macOS builds. The crash is a segmentation fault in a debug handler named DebugMessageHandler(), at runtime, before the slash screen, or main window, is shown. ### Root Cause ### The issue has been tracked down to incorrect usage of the debug.log message handler override. This is a part of Qt that allows us to log to debug.log, using a bypassed message handler in the form of a callback function. The issue is that we should not access some of the “context” information, passed in the form of a QmessageLogContext. If we peruse the Qt documentation: Note: By default, this information is recorded only in debug builds. You can overwrite this explicitly by defining QT_MESSAGELOGCONTEXT or QT_NO_MESSAGELOGCONTEXT. ### Solution ### The correct way to fix this is to not make use of any of the potentially unavailable debugging information. ### Unit Testing Results ### Build on a relatively recent version of macOS, and see if: 1) The build is successful. 2) The user succeeds in launching the application to the main window. Tree-SHA512: 7d15d01ecd406ba2738becd9d477a78aaa69babe77557927b6a8d4fd7535822b12c2ee38a3868946b8a41353ffbee2a5e413d631f350f523eba65cbc6138bf5e
2 parents 69d7e1d + 5416ae0 commit b90f387

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/qt/veil.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,19 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
146146
/* qDebug() message handler --> debug.log */
147147
void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
148148
{
149-
#ifndef QT_MESSAGELOGCONTEXT
150-
Q_UNUSED(context);
149+
//#ifndef QT_MESSAGELOGCONTEXT
150+
// ^ Do not use this except in debugging environments as some OSs don't handle it properly
151+
152+
Q_UNUSED(context);
151153
if (type == QtDebugMsg) {
152154
LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString());
153155
} else {
154156
LogPrintf("GUI: %s\n", msg.toStdString());
155157
}
156-
#else // QT_MESSAGELOGCONTEXT needs to be added to the DEFS line of the Makefile
157-
LogPrintf("GUI: %s:%d %s\n", context.file, context.line, msg.toStdString());
158-
#endif
158+
159+
//#else // QT_MESSAGELOGCONTEXT needs to be added to the DEFS line of the Makefile
160+
// LogPrintf("GUI: %s:%d %s\n", context.file, context.line, msg.toStdString());
161+
//#endif
159162
}
160163

161164
/** Class encapsulating Bitcoin Core startup and shutdown.

0 commit comments

Comments
 (0)