[Solved] SIGSEGV -> Segmentation fault --- Error in Custom Framework (with GDB Screenshot and Results)
-
I need help with my Custom Framework, i have add a screenshot of the GDB Result and a part of the Source Code
-> Segmentation fault!http://www.keppe.org/img/sigsegv.png(Screenshot)!
KMsgFw11Q.cpp
@#include "KMsgFw11Q.h"
#include <QFile>
#include <QSslError>
#include <QSslSocket>
#include <QStringList>
#include <QSslCertificate>KMsgFw11Q::KMsgFw11Q(QObject *parent) :
QObject(parent)
{
tcpSocket = new QSslSocket();
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String(":/messenger.pem"));
if (cert.length() >= 1)
{
QSslError HostNameMismatch = QSslError(QSslError::HostNameMismatch, cert.at(0));
QSslError SelfSignedCertificate = QSslError(QSslError::SelfSignedCertificate, cert.at(0));
QSslError UnableToGetLocalIssuerCertificate = QSslError(QSslError::UnableToGetLocalIssuerCertificate, cert.at(0));
QSslError CertificateUntrusted = QSslError(QSslError::CertificateUntrusted, cert.at(0));
QSslError UnableToVerifyFirstCertificate = QSslError(QSslError::UnableToVerifyFirstCertificate, cert.at(0));
QSslError CertificateExpired = QSslError(QSslError::CertificateExpired, cert.at(0));
sslErrors.append(HostNameMismatch);
sslErrors.append(SelfSignedCertificate);
sslErrors.append(UnableToGetLocalIssuerCertificate);
sslErrors.append(CertificateUntrusted);
sslErrors.append(UnableToVerifyFirstCertificate);
sslErrors.append(CertificateExpired);
}
loggedIn = false;
}
/// More is excluded@KMsgFw11Q.h
@#ifndef KMSGFW11Q_H
#define KMSGFW11Q_H
#include <QString>
#include <QSslError>
#include <QSslSocket>
#include "KMsgFw_shared.h"class KMSGFWSHARED_EXPORT KMsgFw11Q : public QObject
{
Q_OBJECTpublic:
KMsgFw11Q(QObject *parent = 0);
int loginUser(QString username, QString password);
int logoutUser();
bool isLoggedIn();
bool requestGetUserContacts();
bool requestGetUserContactsLength();
bool requestGetUserContactsRequests();
bool requestGetUserContactsWithStates();
bool requestGetUserFriendRequests();
bool requestGetUserFriendRequestsLength();
bool actionAddUserContact(QString username);
bool actionDelUserContact(QString username);
bool actionRemoveUserContact(QString username);
bool requestGetAnotherUserOnlineState(QString username);
bool requestGetUserOnlineState();
bool actionSetUserOnlineState(int state);
bool requestGetAnotherUserMessageState(QString username);
bool requestGetUserMessageState();
bool actionSetUserMessageState(QString message);
bool requestGetAnotherUserAvatar(QString username);
bool requestGetUserAvatar();
bool actionSetUserAvatar(QString base64, QString format);
bool requestGetAnotherUserNick(QString username);
bool requestGetUserNick();
bool actionSetUserNick(QString nick);
bool requestGetAnotherUserMail(QString username);
bool requestGetUserMail();
bool actionSetUserMail(QString mail, bool vfo);
bool actionSetUserPassword(QString oldpassword, QString newpassword);
bool actionSendPokeToUser(QString username);
bool actionSendMessageToUser(QString username, QString message, int id=-1);
QString getUserContacts();
QString getUserContactsLength();
QString getUserContactsRequests();
QString getUserContactsWithStates();
QString getUserFriendRequests();
QString getUserFriendRequestsLength();
int addUserContact(QString username);
int delUserContact(QString username);
int removeUserContact(QString username);
int getAnotherUserOnlineState(QString username);
int getUserOnlineState();
int setUserOnlineState(int state);
QString getAnotherUserMessageState(QString username);
QString getUserMessageState();
int setUserMessageState(QString message);
QString getAnotherUserNick(QString username);
QString getUserNick();
int setUserNick(QString nick);
QString getAnotherUserMail(QString username);
QString getUserMail();
int setUserMail(QString mail, bool vfo);
int setUserPassword(QString oldpassword, QString newpassword);
int sendPokeToUser(QString username);
int sendMessageToUser(QString username, QString message);
bool isObjectIncoming();
QString readObject();signals:
void objectIncomed(QString object);private:
QString workWithObjectWithEmit(QByteArray readed);
QString workWithObject(QByteArray readed);
QList<QSslError> sslErrors;
QSslSocket *tcpSocket;
bool loggedIn;
};#endif // KMSGFW11Q_H
@If you have any idea, it's nice if you me help
(If you are german please made a german part for me, i am not perfect in english)
-
Hi and welcome to devnet,
Please re-run your program in debug mode, you'll have more information about what triggers the crash. One thing that I see that might be doing this is that you don't verify that list of certificate is not empty.
Hope it helps
-
Sorry, i have no idea what is really needed, my Windows Version works fine
http://www.keppe.org/gdboutput.html <- the contains is to long for a Post
-
You are still running your program in release mode, change that. Have a look at the computer icon just above the green arrow, click on it change release to debug. Then start again using the debugger
-
I have made a screenshot, it's more needed?
-
i have made the Object KMsgFw11Q *fw;
fw = new KMsgFw11Q(this);Now have that
!http://www.keppe.org/img/debugmode2.png(Screenshot)!
Windows Debugger say me: QWidget: Must construct a QApplication before a QPaintDevice...
-
Can you show your main.cpp ?
-
@#include <QApplication>
#ifdef WIN32
#include <QUrl>
#include <QTimer>
#include <QProcess>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#endif
#include <QStyleFactory>
#include <QMessageBox>
#include <QSettings>
#include <QFileInfo>
#include <QWidget>
#include <QStyle>
#include <QDir>
#include "frmLogin.h"
#include "frmUpdate.h"
#include "UpdateThread.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);#ifdef Q_WS_WIN64
a.setApplicationName("Keppe Messenger (64bit)");
#else
a.setApplicationName("Keppe Messenger");
#endif
a.setApplicationVersion("1.0.0-19");bool noupdate = false; bool regupdate = false; bool minimized = false; bool resetstyle = false; foreach (const QString& argument, a.arguments()) { if (argument == "--noupdate" || argument.left(11) == "--noupdate=") { noupdate = true; } if (argument == "--regupdate" || argument.left(12) == "--regupdate=") { regupdate = true; } if (argument == "--minimized" || argument.left(12) == "--minimized=") { minimized = true; } if (argument == "--resetstyle" || argument.left(13) == "--resetstyle=") { resetstyle = true; } }
#ifdef SHARED
QDir pluginsDir = QFileInfo(a.applicationFilePath()).absoluteDir();
QDir::setCurrent(pluginsDir.path());
pluginsDir.cd("plugins");
a.addLibraryPath(pluginsDir.path());
pluginsDir.cd("styles");
a.addLibraryPath(pluginsDir.path());#ifdef WIN32
if (regupdate)
{
QString applicationID;
#ifdef QT5
applicationID = "{490D16AC-E002-40EA-A563-94B5AC5B5D21}";
#else
#ifdef WIN64
applicationID = "{6932EC7F-0EB0-4C59-A93C-4D266B8D26DC}";
#elif defined(MSVC)
applicationID = "";
#else
applicationID = "{EE2292A2-0CCC-492F-BB0E-F104F972DC1B}";
#endif
#endif
QSettings regNormal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"+applicationID+"_is1",QSettings::NativeFormat);
if (regNormal.contains("DisplayName"))
{
regNormal.setValue("DisplayName",a.applicationName() + " " + a.applicationVersion());
}
if (regNormal.contains("DisplayVersion"))
{
regNormal.setValue("DisplayVersion",a.applicationVersion());
}
QSettings reg6432Node("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"+applicationID+"_is1",QSettings::NativeFormat);
if (reg6432Node.contains("DisplayName"))
{
reg6432Node.setValue("DisplayName",a.applicationName() + " " + a.applicationVersion());
}
if (reg6432Node.contains("DisplayVersion"))
{
reg6432Node.setValue("DisplayVersion",a.applicationVersion());
}
}
#else
Q_UNUSED(noupdate);
Q_UNUSED(regupdate);
#endifif (resetstyle) { QSettings settings("Keppe","Keppe Messenger"); settings.beginGroup("Style"); settings.setValue("Custom", false); settings.setValue("showBug", true); settings.endGroup(); } QString versionType;
#ifdef QT5
versionType = "32qt5";
#else
#ifdef WIN64
versionType = "64qt4";
#elif defined(MSVC)
versionType = "vcqt4";
#else
versionType = "32qt4";
#endif
#endif#ifdef WIN32
if (!noupdate) { bool updateAvailable = false; QString newVersion; QNetworkAccessManager *http = new QNetworkAccessManager(); QNetworkReply *treply = http->get(QNetworkRequest(QUrl("http://msg.keppe.org/update/stable" + versionType))); QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); QObject::connect(treply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); newVersion = QString::fromUtf8(treply->readAll()); newVersion = newVersion.remove("\n"); newVersion = newVersion.remove("\r"); newVersion = newVersion.trimmed(); if (a.applicationVersion() != newVersion && newVersion != "") {updateAvailable = true;} if (updateAvailable) { QStringList args; args.append("/C"); args.append("KeppeScriptUpdater.exe --path=network --script=http://msg.keppe.org/update/" + versionType + "_" + newVersion + ".lua --version=" + a.applicationVersion()); QProcess *process = new QProcess(); process->startDetached("cmd",args); return 0; } }
#endif
#endifQSettings settings("Keppe","Keppe Messenger"); settings.beginGroup("Style"); bool loadCustom = settings.value("Custom",false).toBool(); if (loadCustom) { QString style = settings.value("Name","System-defined").toString(); if (style != "System-defined") { if (style.trimmed() != "") { a.setStyle(style); } } } settings.endGroup();
#ifdef WIN32
settings.beginGroup("Update");
bool updateNotificationEnabled = settings.value("UpdateNotification",true).toBool();if (updateNotificationEnabled) { frmUpdate *uw = new frmUpdate(); uw->setVersionType(versionType); UpdateThread *ut = new UpdateThread(versionType, a.applicationVersion()); ut->start(); QObject::connect(ut,SIGNAL(setNewVersion(QString)),uw,SLOT(setNewVersion(QString))); QObject::connect(ut,SIGNAL(updateIsNowAvailable()),uw,SLOT(show())); QObject::connect(uw,SIGNAL(disableUpdateNotification()),ut,SLOT(disableUpdateNotification())); } settings.endGroup();
#endif
frmLogin w; if (minimized) {goto minimized;} w.show(); goto appexec;
minimized:
w.showMinimized();appexec:
return a.exec();
}
@ -
No need for goto
@
if (minimized) {
w.showMinimized();
} else {
w.show();
}
return a.exec();
}
@I also don't see anything really suspicious. Since you are using K in some of your classes are you using KDE's framework ? Or is it just because of the name of your software ?
-
I have build my own K Class'es for (K)eppe (I know has KDE have K)
I have a Bug with the Visual Studio 2010 Compiler, i have fixed it with Q_DECL_EXPORT and Q_DECL_IMPORT, i testing that on Linux if i have results i edit my post.Edit:
No, Q_DECL_EXPORT and Q_DECL_IMPORT is not the Problem on LinuxSecond Edit:
i have resolved this Problem, my KGuiFw used a function is only enabled on Windows, i have used now #ifdef WIN32 to resolve it -
Nice you found out !
You should rather use
@#ifdef Q_OS_WIN@
It will be valid for the various version of windows you might encounter
Since it's working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)