Hello,
My program crashes sometimes (SIGSEGV - Segmentation fault). This is (a part of) the code:
This shows the error message when the connection with the server was broken or stopped.
andQt Code:
void Window_Login_Busy::show_errors(int sort_error) { close(); window_login->show(); progressbar->setValue(0); if(sort_error == 1) text += ": Disconnected from server."; else if (sort_error == 2) text += ": Gebruikersnaam of wachtwoord is fout."; QMessageBox err; err.setWindowTitle("QQMsn: Error"); err.setText(text); err.exec(); //debug->setData("bla"); }To copy to clipboard, switch view to plain text mode
Here someone entered the wrong password, I break the connection with the server.
andQt Code:
while(ssl_sck_dalogin->canReadLine()) { [...] else if(line.contains("HTTP/1.1 302 FOUND")) { debug->setData("Redirect"); break; } [...] }To copy to clipboard, switch view to plain text mode
This is the emited slot when I close the connection, it uses the standard Qt signal:
connect(socket, SIGNAL(disconnected()), SLOT(isDisconnected()));
login_busy->show_errors(1); is the function in the first code I posted.
When someone enters the wrong password, I get an error dialog with an Ok button, the login screen is showed and the login_busy is closed. But when you close that screen or press the Ok button, the program receives the SIGSEGV signal and crashes.Qt Code:
void cmsn::isDisconnected() { debug->setData("\nDisconnected from host (Notification server)."); if(login_busy->change_lbl) login_busy->show_errors(1); }To copy to clipboard, switch view to plain text mode
gdb says:
When I don't show an MessageBox, the program does not crash and gdb says:`/home/quinten/QQMsn_build/QQMsn' has changed; re-reading symbols.
Starting program: /home/quinten/QQMsn_build/QQMsn
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
[New Thread -1223088432 (LWP 4881)]
[New Thread -1225602160 (LWP 4882)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223088432 (LWP 4881)]
There are some cases where the server closes the connection (e.g. entering a wrong username). In that case, the same slot is emited, theStarting program: /home/quinten/QQMsn_build/QQMsn
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
[New Thread -1222646064 (LWP 4927)]
[New Thread -1225159792 (LWP 4928)]
[Thread -1225159792 (LWP 4928) exited]
Program exited normally.
MessageBox shows, and when pressing OK, the MessageBox closes and the program doesn't crash.
Why does my program crash? How can I solve it? I don't understand where the error is, in my ssl class, in my window_login class, in Qt, in OpenSSL or somewhere else? When you need the whole source code, I'll post it.
Bookmarks